DXGL r114 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r113‎ | r114 | r115 >
Date:20:00, 6 March 2012
Author:admin
Status:new
Tags:
Comment:
Create unified primitive drawing function.
Implement IDirect3DDevice7::DrawPrimitive
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -16,6 +16,7 @@
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919 #include "common.h"
 20+#include "glRenderer.h"
2021 #include "glDirect3D.h"
2122 #include "glDirect3DDevice.h"
2223 #include "glDirectDraw.h"
Index: ddraw/glDirect3DDevice.cpp
@@ -17,11 +17,11 @@
1818
1919 #include "common.h"
2020 #include "glDirect3D.h"
 21+#include "glRenderer.h"
2122 #include "glDirectDraw.h"
2223 #include "glDirectDrawSurface.h"
2324 #include "glDirect3DDevice.h"
2425 #include "glDirect3DLight.h"
25 -#include "glRenderer.h"
2626 #include "shadergen.h"
2727 #include "glutil.h"
2828 #include "matrix.h"
@@ -120,7 +120,28 @@
121121 FALSE, //clipplaneenable
122122 };
123123
 124+int setdrawmode(D3DPRIMITIVETYPE d3dptPrimitiveType)
 125+{
 126+ switch(d3dptPrimitiveType)
 127+ {
 128+ case D3DPT_POINTLIST:
 129+ return GL_POINTS;
 130+ case D3DPT_LINELIST:
 131+ return GL_LINES;
 132+ case D3DPT_LINESTRIP:
 133+ return GL_LINE_STRIP;
 134+ case D3DPT_TRIANGLELIST:
 135+ return GL_TRIANGLES;
 136+ case D3DPT_TRIANGLESTRIP:
 137+ return GL_TRIANGLE_STRIP;
 138+ case D3DPT_TRIANGLEFAN:
 139+ return GL_TRIANGLE_FAN;
 140+ default:
 141+ return -1;
 142+ }
 143+}
124144
 145+
125146 glDirect3DDevice7::glDirect3DDevice7(glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
126147 {
127148 int zbuffer = 0;
@@ -249,7 +270,7 @@
250271 else if(size > maxarray) normals = (GLfloat*)realloc(normals,size*4*sizeof(GLfloat));
251272 }
252273
253 -__int64 glDirect3DDevice7::SelectShader(DWORD VertexType)
 274+__int64 glDirect3DDevice7::SelectShader(GLVERTEX *VertexType)
254275 {
255276 int i;
256277 __int64 shader = 0;
@@ -284,12 +305,14 @@
285306 shader |= ((renderstate[D3DRENDERSTATE_SPECULARMATERIALSOURCE] & 3) << 25);
286307 shader |= ((renderstate[D3DRENDERSTATE_AMBIENTMATERIALSOURCE] & 3) << 27);
287308 shader |= ((renderstate[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE] & 3) << 29);
288 - int numtextures = (VertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
 309+ int numtextures = 0;
 310+ for(int i = 0; i < 8; i++)
 311+ if(VertexType[i+10].data) numtextures++;
289312 shader |= (__int64)numtextures << 31;
290 - if(VertexType & D3DFVF_XYZRHW) shader |= (1i64 << 34);
291 - if(VertexType & D3DFVF_DIFFUSE) shader |= (1i64<<35);
292 - if(VertexType & D3DFVF_SPECULAR) shader |= (1i64<<36);
293 - if(VertexType & D3DFVF_NORMAL) shader |= (1i64 << 37);
 313+ if(VertexType[1].data) shader |= (1i64 << 34);
 314+ if(VertexType[8].data) shader |= (1i64<<35);
 315+ if(VertexType[9].data) shader |= (1i64<<36);
 316+ if(VertexType[7].data) shader |= (1i64 << 37);
294317 int lightindex = 0;
295318 for(i = 0; i < 8; i++)
296319 {
@@ -300,17 +323,98 @@
301324 lightindex++;
302325 }
303326 }
304 - if(((VertexType >> 1) & 7) >= 3) shader |= (__int64)(((VertexType >> 1) & 7) - 2) << 46;
305 -
 327+ int blendweights = 0;
 328+ for(i = 0; i < 5; i++)
 329+ if(VertexType[i+2].data) blendweights++;
 330+ shader |= (__int64)blendweights << 46;
 331+ //TODO: Implement texture stages.
306332 return shader;
307333 }
308334
 335+HRESULT glDirect3DDevice7::fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr)
 336+{
 337+ int i;
 338+ int ptr = 0;
 339+ if((dwVertexTypeDesc & D3DFVF_XYZ) && (dwVertexTypeDesc & D3DFVF_XYZRHW))
 340+ return DDERR_INVALIDPARAMS;
 341+ if(dwVertexTypeDesc & D3DFVF_XYZ)
 342+ {
 343+ vertdata[0].data = vertptr;
 344+ vertdata[1].data = NULL;
 345+ ptr += 3;
 346+ }
 347+ else if(dwVertexTypeDesc & D3DFVF_XYZRHW)
 348+ {
 349+ vertdata[0].data = vertptr;
 350+ vertdata[1].data = &vertptr[3];
 351+ ptr += 4;
 352+ }
 353+ else return DDERR_INVALIDPARAMS;
 354+ for(i = 0; i < 5; i++)
 355+ vertdata[i+2].data = NULL;
 356+ if(((dwVertexTypeDesc >> 1) & 7) >= 3)
 357+ {
 358+ for(i = 0; i < (signed)(((dwVertexTypeDesc >> 1) & 7) - 2); i++)
 359+ {
 360+ vertdata[((dwVertexTypeDesc >> 1) & 7)].data = &vertptr[ptr];
 361+ ptr++;
 362+ }
 363+ }
 364+ if(dwVertexTypeDesc & D3DFVF_NORMAL)
 365+ {
 366+ vertdata[7].data = &vertptr[ptr];
 367+ ptr += 3;
 368+ }
 369+ else vertdata[7].data = NULL;
 370+ if(dwVertexTypeDesc & D3DFVF_DIFFUSE)
 371+ {
 372+ vertdata[8].data = &vertptr[ptr];
 373+ ptr++;
 374+ }
 375+ else vertdata[8].data = NULL;
 376+ if(dwVertexTypeDesc & D3DFVF_SPECULAR)
 377+ {
 378+ vertdata[9].data = &vertptr[ptr];
 379+ ptr++;
 380+ }
 381+ else vertdata[9].data = NULL;
 382+ for(i = 0; i < 8; i++)
 383+ vertdata[i+10].data = NULL;
 384+ int numtex = (dwVertexTypeDesc&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT;
 385+ for(i = 0; i < numtex; i++)
 386+ {
 387+ vertdata[i+10].data = &vertptr[ptr];
 388+ texformats[i] = (dwVertexTypeDesc>>(16+(2*i))&3);
 389+ switch(texformats[i])
 390+ {
 391+ case 0: // st
 392+ ptr += 2;
 393+ break;
 394+ case 1: // str
 395+ ptr += 3;
 396+ break;
 397+ case 2: // strq
 398+ ptr += 4;
 399+ break;
 400+ case 3: // s
 401+ ptr++;
 402+ break;
 403+ }
 404+ }
 405+ int stride = NextMultipleOf8(ptr*4);
 406+ for(i = 0; i < 17; i++)
 407+ vertdata[i].stride = stride;
 408+ return D3D_OK;
 409+}
 410+
309411 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
310412 LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
311413 {
312414 if(!this) return DDERR_INVALIDPARAMS;
313415 if(!inscene) return D3DERR_SCENE_NOT_IN_SCENE;
314 - return glD3D7->glDD7->renderer->DrawIndexedPrimitive(this,d3dptPrimitiveType,dwVertexTypeDesc,lpvVertices,
 416+ HRESULT err = fvftoglvertex(dwVertexTypeDesc,(LPDWORD)lpvVertices);
 417+ if(err != D3D_OK) return err;
 418+ return glD3D7->glDD7->renderer->DrawPrimitives(this,setdrawmode(d3dptPrimitiveType),vertdata,texformats,
315419 dwVertexCount,lpwIndices,dwIndexCount,dwFlags);
316420 }
317421 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
@@ -330,9 +434,7 @@
331435 HRESULT WINAPI glDirect3DDevice7::DrawPrimitive(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpVertices,
332436 DWORD dwVertexCount, DWORD dwFlags)
333437 {
334 - if(!this) return DDERR_INVALIDPARAMS;
335 - FIXME("glDirect3DDevice7::DrawPrimitive: stub");
336 - ERR(DDERR_GENERIC);
 438+ return DrawIndexedPrimitive(dptPrimitiveType,dwVertexTypeDesc,lpVertices,dwVertexCount,NULL,0,dwFlags);
337439 }
338440 HRESULT WINAPI glDirect3DDevice7::DrawPrimitiveStrided(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc,
339441 LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwVertexCount, DWORD dwFlags)
Index: ddraw/glDirect3DDevice.h
@@ -86,7 +86,7 @@
8787 HRESULT WINAPI SetViewport(LPD3DVIEWPORT7 lpViewport);
8888 HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
8989 void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
90 - __int64 SelectShader(DWORD VertexType);
 90+ __int64 SelectShader(GLVERTEX *VertexType);
9191 void UpdateNormalMatrix();
9292 GLfloat matWorld[16];
9393 GLfloat matView[16];
@@ -101,6 +101,7 @@
102102 DWORD renderstate[153];
103103
104104 private:
 105+ HRESULT fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr);
105106 glDirect3D7 *glD3D7;
106107 ULONG refcount;
107108 GLuint gltextures[8];
@@ -115,6 +116,8 @@
116117 GLubyte *specular;
117118 GLubyte *ambient;
118119 GLfloat *texcoords[8];
 120+ GLVERTEX vertdata[17];
 121+ int texformats[8];
119122 };
120123
121124 #endif //__GLDIRECT3DDEVICE_H
\ No newline at end of file
Index: ddraw/glRenderer.cpp
@@ -19,9 +19,9 @@
2020 #include "glDirectDraw.h"
2121 #include "glDirectDrawSurface.h"
2222 #include "glDirectDrawPalette.h"
 23+#include "glRenderer.h"
2324 #include "glDirect3DDevice.h"
2425 #include "glDirect3DLight.h"
25 -#include "glRenderer.h"
2626 #include "glutil.h"
2727 #include "ddraw.h"
2828 #include "scalers.h"
@@ -46,28 +46,6 @@
4747 return (number<<2)+(number>>4);
4848 }
4949
50 -int setdrawmode(D3DPRIMITIVETYPE d3dptPrimitiveType)
51 -{
52 - switch(d3dptPrimitiveType)
53 - {
54 - case D3DPT_POINTLIST:
55 - return GL_POINTS;
56 - case D3DPT_LINELIST:
57 - return GL_LINES;
58 - case D3DPT_LINESTRIP:
59 - return GL_LINE_STRIP;
60 - case D3DPT_TRIANGLELIST:
61 - return GL_TRIANGLES;
62 - case D3DPT_TRIANGLESTRIP:
63 - return GL_TRIANGLE_STRIP;
64 - case D3DPT_TRIANGLEFAN:
65 - return GL_TRIANGLE_FAN;
66 - default:
67 - return -1;
68 - }
69 -}
70 -
71 -
7250 int oldswap = 0;
7351 int swapinterval = 0;
7452 inline void SetSwap(int swap)
@@ -412,21 +390,21 @@
413391 LeaveCriticalSection(&cs);
414392 }
415393
416 -HRESULT glRenderer::DrawIndexedPrimitive(glDirect3DDevice7 *device, D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
417 - LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
 394+HRESULT glRenderer::DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 395+ DWORD indexcount, DWORD flags)
418396 {
419397 MSG Msg;
420398 EnterCriticalSection(&cs);
421399 wndbusy = true;
422400 inputs[0] = device;
423 - inputs[1] = (void*)d3dptPrimitiveType;
424 - inputs[2] = (void*)dwVertexTypeDesc;
425 - inputs[3] = lpvVertices;
426 - inputs[4] = (void*)dwVertexCount;
427 - inputs[5] = lpwIndices;
428 - inputs[6] = (void*)dwIndexCount;
429 - inputs[7] = (void*)dwFlags;
430 - SendMessage(hRenderWnd,GLEVENT_DRAWINDEXEDPRIMITIVE,0,0);
 401+ inputs[1] = (void*)mode;
 402+ inputs[2] = vertices;
 403+ inputs[3] = texformats;
 404+ inputs[4] = (void*)count;
 405+ inputs[5] = indices;
 406+ inputs[6] = (void*)indexcount;
 407+ inputs[7] = (void*)flags;
 408+ SendMessage(hRenderWnd,GLEVENT_DRAWPRIMITIVES,0,0);
431409 while(wndbusy)
432410 {
433411 while(PeekMessage(&Msg,hRenderWnd,0,0,PM_REMOVE))
@@ -436,7 +414,6 @@
437415 }
438416 Sleep(0);
439417 }
440 - LeaveCriticalSection(&cs);
441418 return (HRESULT)outputs[0];
442419 }
443420
@@ -1031,15 +1008,11 @@
10321009 glFlush();
10331010 }
10341011
1035 -void glRenderer::_DrawIndexedPrimitive(glDirect3DDevice7 *device, D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
1036 - LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
 1012+void glRenderer::_DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 1013+ DWORD indexcount, DWORD flags)
10371014 {
10381015 GLfloat tmpmat[16];
10391016 bool transformed;
1040 - int normalptr = 0;
1041 - int colorptr[2] = {0,0};
1042 - int blendptr[5] = {0,0,0,0,0};
1043 - int texptr[8] = {0,0,0,0,0,0,0,0};
10441017 char blendvar[] = "blendX";
10451018 char rgbavar[] = "rgbaX";
10461019 char svar[] = "sX";
@@ -1047,122 +1020,52 @@
10481021 char strvar[] = "strX";
10491022 char strqvar[] = "strqX";
10501023 int i;
1051 - GLfloat* vertices = (GLfloat*)lpvVertices;
1052 - int drawmode = setdrawmode(d3dptPrimitiveType);
1053 - if(drawmode == -1)
 1024+ if(vertices[1].data) transformed = false;
 1025+ else transformed = true;
 1026+ if(!vertices[0].data)
10541027 {
10551028 outputs[0] = (void*)DDERR_INVALIDPARAMS;
10561029 wndbusy = false;
10571030 return;
10581031 }
1059 - if((dwVertexTypeDesc & D3DFVF_XYZ) && (dwVertexTypeDesc & D3DFVF_XYZRHW))
1060 - {
1061 - outputs[0] = (void*)DDERR_INVALIDPARAMS;
1062 - wndbusy = false;
1063 - return;
1064 - }
1065 - int ptr = 0;
1066 - if(dwVertexTypeDesc & D3DFVF_XYZ)
1067 - {
1068 - transformed = false;
1069 - ptr+= 3;
1070 - }
1071 - if(dwVertexTypeDesc & D3DFVF_XYZRHW)
1072 - {
1073 - transformed = true;
1074 - ptr+= 4;
1075 - }
1076 - if(!ptr)
1077 - {
1078 - outputs[0] = (void*)DDERR_INVALIDPARAMS;
1079 - wndbusy = false;
1080 - return;
1081 - }
1082 - if(((dwVertexTypeDesc >> 1) & 7) >= 3)
1083 - {
1084 - for(i = 0; i < (signed)(((dwVertexTypeDesc >> 1) & 7) - 2); i++)
1085 - {
1086 - blendptr[(((dwVertexTypeDesc >> 1) & 7) - 2)] = ptr;
1087 - ptr++;
1088 - }
1089 - }
1090 - if(dwVertexTypeDesc & D3DFVF_NORMAL)
1091 - {
1092 - normalptr = ptr;
1093 - ptr+= 3;
1094 - }
1095 - if(dwVertexTypeDesc & D3DFVF_DIFFUSE)
1096 - {
1097 - colorptr[0] = ptr;
1098 - ptr++;
1099 - }
1100 - if(dwVertexTypeDesc & D3DFVF_SPECULAR)
1101 - {
1102 - colorptr[1] = ptr;
1103 - ptr++;
1104 - }
1105 - int numtex = (dwVertexTypeDesc&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT;
1106 - for(i = 0; i < numtex; i++)
1107 - {
1108 - texptr[0] = ptr;
1109 - switch(dwVertexTypeDesc>>(16+(2*i))&3)
1110 - {
1111 - case 0: // st
1112 - ptr += 2;
1113 - break;
1114 - case 1: // str
1115 - ptr += 3;
1116 - break;
1117 - case 2: // strq
1118 - ptr += 4;
1119 - break;
1120 - case 3: // s
1121 - ptr++;
1122 - break;
1123 - }
1124 - }
1125 - int stride = NextMultipleOf8(ptr*4);
11261032 TexState texstage;
11271033 ZeroMemory(&texstage,sizeof(TexState));
1128 - __int64 shader = device->SelectShader(dwVertexTypeDesc);
 1034+ __int64 shader = device->SelectShader(vertices);
11291035 SetShader(shader,&texstage,0);
11301036 GLuint prog = GetProgram();
 1037+ GLint xyzloc = glGetAttribLocation(prog,"xyz");
 1038+ glEnableVertexAttribArray(xyzloc);
 1039+ glVertexAttribPointer(xyzloc,3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
11311040 if(transformed)
11321041 {
1133 - GLint xyzwloc = glGetAttribLocation(prog,"xyzw");
 1042+ GLint xyzwloc = glGetAttribLocation(prog,"rhw");
11341043 glEnableVertexAttribArray(xyzwloc);
1135 - glVertexAttribPointer(xyzwloc,4,GL_FLOAT,false,stride,vertices);
 1044+ glVertexAttribPointer(xyzwloc,4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
11361045 }
1137 - else
1138 - {
1139 - GLint xyzloc = glGetAttribLocation(prog,"xyz");
1140 - glEnableVertexAttribArray(xyzloc);
1141 - glVertexAttribPointer(xyzloc,3,GL_FLOAT,false,stride,vertices);
1142 - }
11431046 for(i = 0; i < 5; i++)
11441047 {
11451048 GLint blendloc;
1146 - if(blendptr[i])
 1049+ if(vertices[i+2].data)
11471050 {
11481051 blendvar[5] = i+'0';
11491052 blendloc = glGetAttribLocation(prog,blendvar);
1150 - glVertexAttribPointer(blendloc,1,GL_FLOAT,false,stride,vertices+blendptr[i]);
 1053+ glVertexAttribPointer(blendloc,1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
11511054 }
11521055 }
1153 - if(normalptr)
 1056+ if(vertices[7].data)
11541057 {
11551058 GLint normalloc = glGetAttribLocation(prog,"nxyz");
11561059 glEnableVertexAttribArray(normalloc);
1157 - glVertexAttribPointer(normalloc,3,GL_FLOAT,false,stride,vertices+normalptr);
 1060+ glVertexAttribPointer(normalloc,3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
11581061 }
11591062 for(i = 0; i < 2; i++)
11601063 {
11611064 GLint colorloc;
1162 - if(colorptr[i])
 1065+ if(vertices[i+8].data)
11631066 {
11641067 rgbavar[4] = i + '0';
11651068 colorloc = glGetAttribLocation(prog,rgbavar);
1166 - glVertexAttribPointer(colorloc,4,GL_UNSIGNED_BYTE,true,stride,vertices+colorptr[i]);
 1069+ glVertexAttribPointer(colorloc,4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
11671070 }
11681071 }
11691072 if(device->normal_dirty) device->UpdateNormalMatrix();
@@ -1241,8 +1144,9 @@
12421145 }
12431146 SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
12441147 glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
1245 - glDrawRangeElements(drawmode,0,dwIndexCount,dwVertexCount,GL_UNSIGNED_SHORT,lpwIndices);
1246 - if(dwFlags & D3DDP_WAIT) glFlush();
 1148+ if(indices) glDrawRangeElements(mode,0,indexcount,count,GL_UNSIGNED_SHORT,indices);
 1149+ else glDrawArrays(mode,0,count);
 1150+ if(flags & D3DDP_WAIT) glFlush();
12471151 outputs[0] = (void*)D3D_OK;
12481152 wndbusy = false;
12491153 return;
@@ -1253,7 +1157,6 @@
12541158 int oldx,oldy;
12551159 float mulx, muly;
12561160 float tmpfloats[16];
1257 - D3DPRIMITIVETYPE d3dpt;
12581161 int translatex, translatey;
12591162 LPARAM newpos;
12601163 HWND hParent;
@@ -1378,10 +1281,9 @@
13791282 case GLEVENT_FLUSH:
13801283 _Flush();
13811284 return 0;
1382 - case GLEVENT_DRAWINDEXEDPRIMITIVE:
1383 - memcpy(&d3dpt,&inputs[1],4);
1384 - _DrawIndexedPrimitive((glDirect3DDevice7*)inputs[0],d3dpt,(DWORD)inputs[2],(LPVOID)inputs[3],
1385 - (DWORD)inputs[4],(LPWORD)inputs[5],(DWORD)inputs[6],(DWORD)inputs[7]);
 1285+ case GLEVENT_DRAWPRIMITIVES:
 1286+ _DrawPrimitives((glDirect3DDevice7*)inputs[0],(GLenum)inputs[1],(GLVERTEX*)inputs[2],(int*)inputs[3],(DWORD)inputs[4],
 1287+ (LPWORD)inputs[5],(DWORD)inputs[6],(DWORD)inputs[7]);
13861288 return 0;
13871289 default:
13881290 return DefWindowProc(hwnd,msg,wParam,lParam);
Index: ddraw/glRenderer.h
@@ -41,6 +41,12 @@
4242 BYTE *pixels;
4343 } DIB;
4444
 45+struct GLVERTEX
 46+{
 47+ void *data;
 48+ int stride;
 49+};
 50+
4551 struct BltVertex
4652 {
4753 GLfloat x,y;
@@ -62,18 +68,15 @@
6369 #define GLEVENT_INITD3D WM_USER+8
6470 #define GLEVENT_CLEAR WM_USER+9
6571 #define GLEVENT_FLUSH WM_USER+10
66 -#define GLEVENT_DRAWPRIMITIVE WM_USER+11
67 -#define GLEVENT_DRAWPRIMITIVESTRIDED WM_USER+12
68 -#define GLEVENT_DRAWPRIMITIVEVB WM_USER+13
69 -#define GLEVENT_DRAWINDEXEDPRIMITIVE WM_USER+14
70 -#define GLEVENT_DRAWINDEXEDPRIMITIVESTRIDED WM_USER+15
71 -#define GLEVENT_DRAWINDEXEDPRIMITIVEVB WM_USER+16
 72+#define GLEVENT_DRAWPRIMITIVES WM_USER+11
7273
7374
7475 extern int swapinterval;
7576 extern inline void SetSwap(int swap);
7677
 78+class glDirectDraw7;
7779 class glDirect3DDevice7;
 80+class glDirectDrawSurface7;
7881
7982 class glRenderer
8083 {
@@ -91,8 +94,8 @@
9295 void InitD3D(int zbuffer);
9396 void Flush();
9497 HRESULT Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
95 - HRESULT DrawIndexedPrimitive(glDirect3DDevice7 *device, D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
96 - LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
 98+ HRESULT DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 99+ DWORD indexcount, DWORD flags);
97100 HGLRC hRC;
98101 LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
99102 private:
@@ -109,8 +112,8 @@
110113 void _DrawBackbuffer(GLuint *texture, int x, int y);
111114 void _InitD3D(int zbuffer);
112115 void _Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
113 - void _DrawIndexedPrimitive(glDirect3DDevice7 *device, D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
114 - LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags);
 116+ void glRenderer::_DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
 117+ DWORD indexcount, DWORD flags);
115118 glDirectDraw7 *ddInterface;
116119 void _Flush();
117120 void* inputs[32];
Index: ddraw/shadergen.cpp
@@ -174,7 +174,7 @@
175175 static const char mainend[] = "} ";
176176 // Attributes
177177 static const char attr_xyz[] = "attribute vec3 xyz;\n";
178 -static const char attr_xyzw[] = "attribute vec4 xyzw;\n";
 178+static const char attr_rhw[] = "attribute float rhw;\n";
179179 static const char attr_nxyz[] = "attribute vec3 nxyz;\n";
180180 static const char attr_blend[] = "attribute float blendX;\n";
181181 static const char attr_rgba[] = "attribute vec4 rgbaX;\n";
@@ -278,8 +278,8 @@
279279 vsrc->append(idheader);
280280 vsrc->append(idstring);
281281 // Attributes
282 - if((id>>34)&1) vsrc->append(attr_xyzw);
283 - else vsrc->append(attr_xyz);
 282+ vsrc->append(attr_xyz);
 283+ if((id>>34)&1) vsrc->append(attr_rhw);
284284 tmp = attr_rgba;
285285 if((id>>35)&1)
286286 {