DXGL r325 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r324‎ | r325 | r326 >
Date:16:07, 16 February 2013
Author:admin
Status:new
Tags:
Comment:
Implement several execute buffer opcodes.
Add software transform (untested) for execute buffers. (no lights yet)
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirect3DExecuteBuffer.cpp (modified) (history)
  • /ddraw/glDirect3DExecuteBuffer.h (modified) (history)
  • /ddraw/matrix.cpp (modified) (history)
  • /ddraw/matrix.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -287,11 +287,16 @@
288288 ZeroMemory(viewports,32*sizeof(glDirect3DViewport3*));
289289 vertices = normals = NULL;
290290 diffuse = specular = NULL;
 291+ ebBuffer = NULL;
 292+ ebBufferSize = 0;
 293+ outbuffer = NULL;
 294+ outbuffersize = 0;
291295 ZeroMemory(texcoords,8*sizeof(GLfloat*));
292296 memcpy(renderstate,renderstate_default,153*sizeof(DWORD));
293297 __gluMakeIdentityf(matWorld);
294298 __gluMakeIdentityf(matView);
295299 __gluMakeIdentityf(matProjection);
 300+ transform_dirty = true;
296301 matrices = NULL;
297302 matrixcount = 0;
298303 texstages[0] = texstagedefault0;
@@ -1436,14 +1441,17 @@
14371442 case D3DTRANSFORMSTATE_WORLD:
14381443 memcpy(&matWorld,lpD3DMatrix,sizeof(D3DMATRIX));
14391444 modelview_dirty = true;
 1445+ transform_dirty = true;
14401446 return D3D_OK;
14411447 case D3DTRANSFORMSTATE_VIEW:
14421448 memcpy(&matView,lpD3DMatrix,sizeof(D3DMATRIX));
14431449 modelview_dirty = true;
 1450+ transform_dirty = true;
14441451 return D3D_OK;
14451452 case D3DTRANSFORMSTATE_PROJECTION:
14461453 memcpy(&matProjection,lpD3DMatrix,sizeof(D3DMATRIX));
14471454 projection_dirty = true;
 1455+ transform_dirty = true;
14481456 return D3D_OK;
14491457 default:
14501458 ERR(DDERR_INVALIDPARAMS);
@@ -1453,6 +1461,7 @@
14541462 {
14551463 if(!this) return DDERR_INVALIDOBJECT;
14561464 memcpy(&viewport,lpViewport,sizeof(D3DVIEWPORT7));
 1465+ transform_dirty = true;
14571466 return D3D_OK;
14581467 }
14591468 HRESULT WINAPI glDirect3DDevice7::ValidateDevice(LPDWORD lpdwPasses)
@@ -1882,7 +1891,11 @@
18831892 HRESULT glDirect3DDevice7::GetMatrix(D3DMATRIXHANDLE lpD3DMatHandle, LPD3DMATRIX lpD3DMatrix)
18841893 {
18851894 if(!this) return DDERR_INVALIDOBJECT;
1886 - if(!lpD3DMatHandle) return DDERR_INVALIDPARAMS;
 1895+ if(!lpD3DMatHandle)
 1896+ {
 1897+ __gluMakeIdentityf((GLfloat*)lpD3DMatrix);
 1898+ return D3D_OK;
 1899+ }
18871900 if(lpD3DMatHandle >= matrixcount) return DDERR_INVALIDPARAMS;
18881901 if(!matrices[lpD3DMatHandle].active) return D3DERR_MATRIX_GETDATA_FAILED;
18891902 memcpy(lpD3DMatrix,&matrices[lpD3DMatHandle].matrix,sizeof(D3DMATRIX));
@@ -1913,13 +1926,392 @@
19141927 return D3D_OK;
19151928 }
19161929
 1930+BOOL ExpandBuffer(void **buffer, DWORD *size, DWORD increment)
 1931+{
 1932+ void *ptr = realloc(*buffer,*size+increment);
 1933+ if(!ptr) return FALSE;
 1934+ *buffer = ptr;
 1935+ *size += increment;
 1936+ return TRUE;
 1937+}
 1938+
 1939+INT AddTriangle(unsigned char **buffer, DWORD *buffersize, DWORD *offset, const D3DTRIANGLE *triangle)
 1940+{
 1941+ if(*buffersize < (*offset + sizeof(D3DTRIANGLE)))
 1942+ {
 1943+ if(!ExpandBuffer((void**)buffer,buffersize,1024)) return -1;
 1944+ }
 1945+ // FIXME: Process triangle strips and fans.
 1946+ memcpy(*buffer+*offset,triangle,3*sizeof(WORD));
 1947+ *offset += 3*sizeof(WORD);
 1948+ return 0;
 1949+}
 1950+
 1951+void glDirect3DDevice7::UpdateTransform()
 1952+{
 1953+ GLfloat mat1[16];
 1954+ GLfloat mat2[16];
 1955+ GLfloat matViewport[16];
 1956+ __gluMultMatricesf(matWorld,matView,mat1);
 1957+ __gluMultMatricesf(mat1,matProjection,mat2);
 1958+ matViewport[1] = matViewport[2] = matViewport[3] = matViewport[4] = matViewport[6] = matViewport[7] =
 1959+ matViewport[8] = matViewport[9] = matViewport[11] = matViewport[15] = 0;
 1960+ matViewport[0] = (GLfloat)viewport.dwWidth / 2.0f;
 1961+ matViewport[5] = (GLfloat)viewport.dwHeight / 2.0f;
 1962+ matViewport[10] = (viewport.dvMaxZ - viewport.dvMinZ) / 2.0f;
 1963+ matViewport[12] = (GLfloat)viewport.dwX + ((GLfloat)viewport.dwWidth / 2.0f);
 1964+ matViewport[13] = (GLfloat)viewport.dwY + ((GLfloat)viewport.dwHeight / 2.0f);
 1965+ matViewport[14] = (viewport.dvMinZ + viewport.dvMaxZ) / 2.0f;
 1966+ __gluMultMatricesf(mat2,matViewport,matTransform);
 1967+ transform_dirty = false;
 1968+}
 1969+
 1970+void CalculateExtents(D3DRECT *extents, D3DTLVERTEX *vertices, DWORD count)
 1971+{
 1972+ if(!count) return;
 1973+ D3DVALUE minX,minY,maxX,maxY;
 1974+ minX = maxX = vertices[0].dvSX;
 1975+ minY = maxY = vertices[0].dvSY;
 1976+ for(int i = 0; i < count; i++)
 1977+ {
 1978+ if(vertices[i].dvSX < minX) minX = vertices[i].dvSX;
 1979+ if(vertices[i].dvSX > maxX) maxX = vertices[i].dvSX;
 1980+ if(vertices[i].dvSY < minY) minY = vertices[i].dvSY;
 1981+ if(vertices[i].dvSY > maxY) maxY = vertices[i].dvSY;
 1982+ }
 1983+ if((LONG)minX < extents->x1) extents->x1 = (LONG)minX;
 1984+ if((LONG)maxX > extents->x2) extents->x2 = (LONG)maxX;
 1985+ if((LONG)minY < extents->y1) extents->y1 = (LONG)minY;
 1986+ if((LONG)maxY > extents->y2) extents->y2 = (LONG)maxY;
 1987+}
 1988+
 1989+INT glDirect3DDevice7::TransformAndLight(D3DTLVERTEX **output, DWORD *outsize, D3DVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents)
 1990+{
 1991+ GLfloat in[4];
 1992+ in[3] = 1.0f;
 1993+ if(transform_dirty) UpdateTransform();
 1994+ if(*outsize < (dest+count)*sizeof(D3DTLVERTEX))
 1995+ {
 1996+ D3DTLVERTEX *tmpptr = (D3DTLVERTEX*)realloc(*output,(dest+count)*sizeof(D3DTLVERTEX));
 1997+ if(!tmpptr) return -1;
 1998+ *output = tmpptr;
 1999+ *outsize = (dest+count)*sizeof(D3DTLVERTEX);
 2000+ }
 2001+ for(int i = 0; i < count; i++)
 2002+ {
 2003+ in[0] = input[i+start].dvX;
 2004+ in[1] = input[i+start].dvY;
 2005+ in[2] = input[i+start].dvZ;
 2006+ __gluMultMatrixVecf(matTransform,in,&(*output)[i+dest].dvSX);
 2007+ (*output)[i+dest].dvRHW = 1.0f/(*output)[i+dest].dvRHW;
 2008+ // Do lighting
 2009+ (*output)[i+dest].dvTU = input[i+start].dvTU;
 2010+ (*output)[i+dest].dvTV = input[i+start].dvTV;
 2011+ }
 2012+ if(extents) CalculateExtents(extents,*output,count);
 2013+ return 0;
 2014+}
 2015+INT glDirect3DDevice7::TransformOnly(D3DTLVERTEX **output, DWORD *outsize, D3DVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents)
 2016+{
 2017+ GLfloat in[4];
 2018+ in[3] = 1.0f;
 2019+ if(transform_dirty) UpdateTransform();
 2020+ if(*outsize < (dest+count)*sizeof(D3DTLVERTEX))
 2021+ {
 2022+ D3DTLVERTEX *tmpptr = (D3DTLVERTEX*)realloc(*output,(dest+count)*sizeof(D3DTLVERTEX));
 2023+ if(!tmpptr) return -1;
 2024+ *output = tmpptr;
 2025+ *outsize = (dest+count)*sizeof(D3DTLVERTEX);
 2026+ }
 2027+ for(int i = 0; i < count; i++)
 2028+ {
 2029+ in[0] = input[i+start].dvX;
 2030+ in[1] = input[i+start].dvY;
 2031+ in[2] = input[i+start].dvZ;
 2032+ __gluMultMatrixVecf(matTransform,in,&(*output)[i+dest].dvSX);
 2033+ (*output)[i+dest].dvRHW = 1.0f/(*output)[i+dest].dvRHW;
 2034+ (*output)[i+dest].dcColor = 0xFFFFFFFF;
 2035+ (*output)[i+dest].dcSpecular = 0;
 2036+ (*output)[i+dest].dvTU = input[i+start].dvTU;
 2037+ (*output)[i+dest].dvTV = input[i+start].dvTV;
 2038+ }
 2039+ if(extents) CalculateExtents(extents,*output,count);
 2040+ return 0;
 2041+}
 2042+INT glDirect3DDevice7::TransformOnly(D3DTLVERTEX **output, DWORD *outsize, D3DLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents)
 2043+{
 2044+ GLfloat in[4];
 2045+ in[3] = 1.0f;
 2046+ if(transform_dirty) UpdateTransform();
 2047+ if(*outsize < (dest+count)*sizeof(D3DTLVERTEX))
 2048+ {
 2049+ D3DTLVERTEX *tmpptr = (D3DTLVERTEX*)realloc(*output,(dest+count)*sizeof(D3DTLVERTEX));
 2050+ if(!tmpptr) return -1;
 2051+ *output = tmpptr;
 2052+ *outsize = (dest+count)*sizeof(D3DTLVERTEX);
 2053+ }
 2054+ for(int i = 0; i < count; i++)
 2055+ {
 2056+ in[0] = input[i+start].dvX;
 2057+ in[1] = input[i+start].dvY;
 2058+ in[2] = input[i+start].dvZ;
 2059+ __gluMultMatrixVecf(matTransform,in,&(*output)[i+dest].dvSX);
 2060+ (*output)[i+dest].dvRHW = 1.0f/(*output)[i+dest].dvRHW;
 2061+ (*output)[i+dest].dcColor = input[i+start].dcColor;
 2062+ (*output)[i+dest].dcSpecular = input[i+start].dcSpecular;
 2063+ (*output)[i+dest].dvTU = input[i+start].dvTU;
 2064+ (*output)[i+dest].dvTV = input[i+start].dvTV;
 2065+ }
 2066+ if(extents) CalculateExtents(extents,*output,count);
 2067+ return 0;
 2068+}
 2069+INT glDirect3DDevice7::CopyVertices(D3DTLVERTEX **output, DWORD *outsize, D3DTLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents)
 2070+{
 2071+ if(transform_dirty) UpdateTransform();
 2072+ if(*outsize < (dest+count)*sizeof(D3DTLVERTEX))
 2073+ {
 2074+ D3DTLVERTEX *tmpptr = (D3DTLVERTEX*)realloc(*output,(dest+count)*sizeof(D3DTLVERTEX));
 2075+ if(!tmpptr) return -1;
 2076+ *output = tmpptr;
 2077+ *outsize = (dest+count)*sizeof(D3DTLVERTEX);
 2078+ }
 2079+ memcpy(&(*output)[dest],&input[start],count*sizeof(D3DTLVERTEX));
 2080+ if(extents) CalculateExtents(extents,*output,count);
 2081+ return 0;
 2082+}
 2083+
19172084 HRESULT glDirect3DDevice7::Execute(LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, LPDIRECT3DVIEWPORT lpDirect3DViewport, DWORD dwFlags)
19182085 {
19192086 if(!this) return DDERR_INVALIDOBJECT;
19202087 if(!lpDirect3DExecuteBuffer) return DDERR_INVALIDPARAMS;
19212088 if(!lpDirect3DViewport) return DDERR_INVALIDPARAMS;
1922 - FIXME("glDirect3DDevice1::Execute: stub");
1923 - ERR(DDERR_GENERIC);
 2089+ D3DEXECUTEBUFFERDESC desc;
 2090+ D3DEXECUTEDATA data;
 2091+ HRESULT err = ((glDirect3DExecuteBuffer*)lpDirect3DExecuteBuffer)->ExecuteLock(&desc,&data);
 2092+ if(FAILED(err)) return err;
 2093+ unsigned char *opptr = (unsigned char *)desc.lpData + data.dwInstructionOffset;
 2094+ unsigned char *in_vertptr = (unsigned char *)desc.lpData + data.dwVertexOffset;
 2095+ DWORD offset;
 2096+ INT result;
 2097+ D3DMATRIX mat1,mat2,mat3;
 2098+ bool ebExit = false;
 2099+ int i;
 2100+ if(outbuffersize < desc.dwBufferSize)
 2101+ {
 2102+ unsigned char *tmpbuffer = (unsigned char *)realloc(outbuffer,desc.dwBufferSize);
 2103+ if(!tmpbuffer) return DDERR_OUTOFMEMORY;
 2104+ outbuffer = tmpbuffer;
 2105+ outbuffersize = desc.dwBufferSize;
 2106+ }
 2107+ D3DVERTEX *vert_ptr = (D3DVERTEX*)outbuffer;
 2108+ while(1)
 2109+ {
 2110+ D3DINSTRUCTION *instruction = (D3DINSTRUCTION*) opptr;
 2111+ offset = 0;
 2112+ switch(instruction->bOpcode)
 2113+ {
 2114+ case D3DOP_POINT:
 2115+ opptr += sizeof(D3DINSTRUCTION);
 2116+ if(instruction->bSize < sizeof(D3DPOINT))
 2117+ {
 2118+ opptr += (instruction->bSize*instruction->wCount);
 2119+ break;
 2120+ }
 2121+ for(i = 0; i < instruction->wCount; i++)
 2122+ {
 2123+ if(ebBufferSize < (offset + ((D3DPOINT*)opptr)->wCount*sizeof(D3DVERTEX)))
 2124+ {
 2125+ if(!ExpandBuffer((void**)&ebBuffer,&ebBufferSize,(((D3DPOINT*)opptr)->wCount*sizeof(D3DVERTEX) > 1024) ?
 2126+ ((D3DPOINT*)opptr)->wCount*sizeof(D3DVERTEX) : 1024))
 2127+ return DDERR_OUTOFMEMORY;
 2128+ }
 2129+ memcpy(&ebBuffer+offset,&vert_ptr[((D3DPOINT*)opptr)->wFirst],((D3DPOINT*)opptr)->wCount*sizeof(D3DVERTEX));
 2130+ offset+=((D3DPOINT*)opptr)->wCount;
 2131+ opptr += instruction->bSize;
 2132+ }
 2133+ DrawPrimitive(D3DPT_POINTLIST,D3DFVF_TLVERTEX,ebBuffer,offset/sizeof(D3DVERTEX),0);
 2134+ break;
 2135+ case D3DOP_LINE:
 2136+ opptr += sizeof(D3DINSTRUCTION);
 2137+ if(instruction->bSize < sizeof(D3DLINE))
 2138+ {
 2139+ opptr += (instruction->bSize*instruction->wCount);
 2140+ break;
 2141+ }
 2142+ for(i = 0; i < instruction->wCount; i++)
 2143+ {
 2144+ if(ebBufferSize < (offset + sizeof(D3DLINE)))
 2145+ {
 2146+ if(!ExpandBuffer((void**)&ebBuffer,&ebBufferSize,1024)) return DDERR_OUTOFMEMORY;
 2147+ }
 2148+ memcpy(&ebBuffer+offset,opptr,sizeof(D3DLINE));
 2149+ offset += sizeof(D3DLINE);
 2150+ opptr += instruction->bSize;
 2151+ }
 2152+ DrawIndexedPrimitive(D3DPT_LINELIST,D3DFVF_TLVERTEX,vert_ptr,(desc.dwBufferSize-data.dwVertexOffset)/sizeof(D3DVERTEX),
 2153+ (WORD*)ebBuffer,instruction->wCount*2,0);
 2154+ break;
 2155+ case D3DOP_TRIANGLE:
 2156+ opptr += sizeof(D3DINSTRUCTION);
 2157+ if(instruction->bSize < sizeof(D3DTRIANGLE))
 2158+ {
 2159+ opptr += (instruction->bSize*instruction->wCount);
 2160+ break;
 2161+ }
 2162+ for(i = 0; i < instruction->wCount; i++)
 2163+ {
 2164+ result = AddTriangle(&ebBuffer,&ebBufferSize,&offset,(D3DTRIANGLE*)opptr);
 2165+ if(result == -1) return DDERR_OUTOFMEMORY;
 2166+ opptr += instruction->bSize;
 2167+ }
 2168+ DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_TLVERTEX,vert_ptr,(desc.dwBufferSize-data.dwVertexOffset)/sizeof(D3DVERTEX),
 2169+ (WORD*)ebBuffer,instruction->wCount*3,0);
 2170+ break;
 2171+ case D3DOP_MATRIXLOAD:
 2172+ opptr += sizeof(D3DINSTRUCTION);
 2173+ if(instruction->bSize < sizeof(D3DMATRIXLOAD))
 2174+ {
 2175+ opptr += (instruction->bSize*instruction->wCount);
 2176+ break;
 2177+ }
 2178+ for(i = 0; i < instruction->wCount; i++)
 2179+ {
 2180+ GetMatrix(((D3DMATRIXLOAD*)opptr)->hSrcMatrix,&mat1);
 2181+ SetMatrix(((D3DMATRIXLOAD*)opptr)->hDestMatrix,&mat1);
 2182+ opptr += instruction->bSize;
 2183+ }
 2184+ break;
 2185+ case D3DOP_MATRIXMULTIPLY:
 2186+ opptr += sizeof(D3DINSTRUCTION);
 2187+ if(instruction->bSize < sizeof(D3DMATRIXMULTIPLY))
 2188+ {
 2189+ opptr += (instruction->bSize*instruction->wCount);
 2190+ break;
 2191+ }
 2192+ for(i = 0; i < instruction->wCount; i++)
 2193+ {
 2194+ GetMatrix(((D3DMATRIXMULTIPLY*)opptr)->hSrcMatrix1,&mat1);
 2195+ GetMatrix(((D3DMATRIXMULTIPLY*)opptr)->hSrcMatrix2,&mat2);
 2196+ __gluMultMatricesf((GLfloat*)&mat1,(GLfloat*)&mat2,(GLfloat*)&mat3);
 2197+ SetMatrix(((D3DMATRIXMULTIPLY*)opptr)->hDestMatrix,&mat3);
 2198+ opptr += instruction->bSize;
 2199+ }
 2200+ break;
 2201+ case D3DOP_STATETRANSFORM:
 2202+ opptr += sizeof(D3DINSTRUCTION);
 2203+ if(instruction->bSize < sizeof(D3DSTATE))
 2204+ {
 2205+ opptr += (instruction->bSize*instruction->wCount);
 2206+ break;
 2207+ }
 2208+ for(i = 0; i < instruction->wCount; i++)
 2209+ {
 2210+ GetMatrix(((D3DSTATE*)opptr)->dwArg[0],&mat1);
 2211+ SetTransform(((D3DSTATE*)opptr)->dtstTransformStateType,&mat1);
 2212+ opptr += instruction->bSize;
 2213+ }
 2214+ break;
 2215+ case D3DOP_STATELIGHT:
 2216+ opptr += sizeof(D3DINSTRUCTION);
 2217+ if(instruction->bSize < sizeof(D3DSTATE))
 2218+ {
 2219+ opptr += (instruction->bSize*instruction->wCount);
 2220+ break;
 2221+ }
 2222+ for(i = 0; i < instruction->wCount; i++)
 2223+ {
 2224+ SetLightState(((D3DSTATE*)opptr)->dlstLightStateType,((D3DSTATE*)opptr)->dwArg[0]);
 2225+ opptr += instruction->bSize;
 2226+ }
 2227+ break;
 2228+ case D3DOP_STATERENDER:
 2229+ opptr += sizeof(D3DINSTRUCTION);
 2230+ if(instruction->bSize < sizeof(D3DSTATE))
 2231+ {
 2232+ opptr += (instruction->bSize*instruction->wCount);
 2233+ break;
 2234+ }
 2235+ for(i = 0; i < instruction->wCount; i++)
 2236+ {
 2237+ SetRenderState(((D3DSTATE*)opptr)->drstRenderStateType,((D3DSTATE*)opptr)->dwArg[0]);
 2238+ opptr += instruction->bSize;
 2239+ }
 2240+ break;
 2241+ case D3DOP_PROCESSVERTICES:
 2242+ opptr += sizeof(D3DINSTRUCTION);
 2243+ if(instruction->bSize < sizeof(D3DPROCESSVERTICES))
 2244+ {
 2245+ opptr += (instruction->bSize*instruction->wCount);
 2246+ break;
 2247+ }
 2248+ for(i = 0; i < instruction->wCount; i++)
 2249+ {
 2250+ switch(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_OPMASK)
 2251+ {
 2252+ case D3DPROCESSVERTICES_TRANSFORM:
 2253+ if(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
 2254+ TransformOnly((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DLVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2255+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2256+ else TransformOnly((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DLVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2257+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2258+ break;
 2259+ case D3DPROCESSVERTICES_TRANSFORMLIGHT:
 2260+ if(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
 2261+ {
 2262+ if(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
 2263+ TransformOnly((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2264+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2265+ else TransformOnly((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2266+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2267+ }
 2268+ else
 2269+ {
 2270+ if(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
 2271+ TransformAndLight((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2272+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2273+ else TransformAndLight((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2274+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2275+ }
 2276+ case D3DPROCESSVERTICES_COPY:
 2277+ if(((D3DPROCESSVERTICES*)opptr)->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
 2278+ CopyVertices((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DTLVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2279+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2280+ else CopyVertices((D3DTLVERTEX**)&outbuffer,&outbuffersize,(D3DTLVERTEX*)in_vertptr,((D3DPROCESSVERTICES*)opptr)->wStart,
 2281+ ((D3DPROCESSVERTICES*)opptr)->wDest,((D3DPROCESSVERTICES*)opptr)->dwCount,&data.dsStatus.drExtent);
 2282+ break;
 2283+ default:
 2284+ break;
 2285+ }
 2286+ opptr += instruction->bSize;
 2287+ }
 2288+ break;
 2289+ case D3DOP_TEXTURELOAD:
 2290+ opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
 2291+ FIXME("D3DOP_TEXTURELOAD: stub");
 2292+ break;
 2293+ case D3DOP_EXIT:
 2294+ ebExit = true;
 2295+ break;
 2296+ case D3DOP_BRANCHFORWARD:
 2297+ opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
 2298+ FIXME("D3DOP_BRANCHFORWARD: stub");
 2299+ break;
 2300+ case D3DOP_SPAN:
 2301+ opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
 2302+ FIXME("D3DOP_SPAN: stub");
 2303+ break;
 2304+ case D3DOP_SETSTATUS:
 2305+ opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
 2306+ FIXME("D3DOP_SETSTATUS: stub");
 2307+ break;
 2308+ default:
 2309+ opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
 2310+ break;
 2311+ }
 2312+ if(ebExit) break;
 2313+ }
 2314+ ((glDirect3DExecuteBuffer*)lpDirect3DExecuteBuffer)->ExecuteUnlock(&data);
 2315+ return D3D_OK;
19242316 }
19252317
19262318 HRESULT glDirect3DDevice7::GetPickRecords(LPDWORD lpCount, LPD3DPICKRECORD lpD3DPickRec)
Index: ddraw/glDirect3DDevice.h
@@ -162,11 +162,18 @@
163163 HRESULT GetPickRecords(LPDWORD lpCount, LPD3DPICKRECORD lpD3DPickRec);
164164 HRESULT Pick(LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, LPDIRECT3DVIEWPORT lpDirect3DViewport, DWORD dwFlags,
165165 LPD3DRECT lpRect);
 166+ INT TransformAndLight(D3DTLVERTEX **output, DWORD *outsize, D3DVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
 167+ INT TransformOnly(D3DTLVERTEX **output, DWORD *outsize, D3DVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
 168+ INT TransformOnly(D3DTLVERTEX **output, DWORD *outsize, D3DLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
 169+ INT CopyVertices(D3DTLVERTEX **output, DWORD *outsize, D3DTLVERTEX *input, WORD start, WORD dest, DWORD count, D3DRECT *extents);
 170+ void UpdateTransform();
166171 void InitDX5();
167172 __int64 SelectShader(GLVERTEX *VertexType);
168173 GLfloat matWorld[16];
169174 GLfloat matView[16];
170175 GLfloat matProjection[16];
 176+ GLfloat matTransform[16];
 177+ bool transform_dirty;
171178 D3D1MATRIX *matrices;
172179 int matrixcount;
173180 D3DMATERIAL7 material;
@@ -211,6 +218,10 @@
212219 glDirect3DViewport3 *currentviewport;
213220 int viewportcount;
214221 int maxviewports;
 222+ unsigned char *ebBuffer;
 223+ DWORD ebBufferSize;
 224+ unsigned char *outbuffer;
 225+ DWORD outbuffersize;
215226 };
216227
217228 #endif //__GLDIRECT3DDEVICE_H
Index: ddraw/glDirect3DExecuteBuffer.cpp
@@ -154,11 +154,13 @@
155155 return D3D_OK;
156156 }
157157
158 -HRESULT glDirect3DExecuteBuffer::ExecuteUnlock()
 158+HRESULT glDirect3DExecuteBuffer::ExecuteUnlock(LPD3DEXECUTEDATA lpData)
159159 {
160160 if(!this) return DDERR_INVALIDOBJECT;
 161+ if(!lpData) return DDERR_INVALIDPARAMS;
161162 if(!inuse) return D3DERR_EXECUTE_NOT_LOCKED;
162163 inuse = false;
163164 locked = false;
 165+ memcpy(&datadesc,lpData,sizeof(D3DEXECUTEDATA));
164166 return D3D_OK;
165167 }
\ No newline at end of file
Index: ddraw/glDirect3DExecuteBuffer.h
@@ -32,7 +32,7 @@
3333 HRESULT WINAPI Unlock();
3434 HRESULT WINAPI Validate(LPDWORD lpdwOffset, LPD3DVALIDATECALLBACK lpFunc, LPVOID lpUserArg, DWORD dwReserved);
3535 HRESULT ExecuteLock(LPD3DEXECUTEBUFFERDESC lpDesc,LPD3DEXECUTEDATA lpData);
36 - HRESULT ExecuteUnlock();
 36+ HRESULT ExecuteUnlock(LPD3DEXECUTEDATA lpData);
3737 private:
3838 ULONG refcount;
3939 D3DEXECUTEBUFFERDESC desc;
Index: ddraw/matrix.cpp
@@ -127,4 +127,17 @@
128128 m[1+4*0] = 0; m[1+4*1] = 1; m[1+4*2] = 0; m[1+4*3] = 0;
129129 m[2+4*0] = 0; m[2+4*1] = 0; m[2+4*2] = 1; m[2+4*3] = 0;
130130 m[3+4*0] = 0; m[3+4*1] = 0; m[3+4*2] = 0; m[3+4*3] = 1;
131 -}
\ No newline at end of file
 131+}
 132+
 133+void __gluMultMatrixVecf(const GLfloat matrix[16], const GLfloat in[4], GLfloat out[4])
 134+{
 135+ int i;
 136+
 137+ for (i=0; i<4; i++) {
 138+ out[i] =
 139+ in[0] * matrix[0*4+i] +
 140+ in[1] * matrix[1*4+i] +
 141+ in[2] * matrix[2*4+i] +
 142+ in[3] * matrix[3*4+i];
 143+ }
 144+}
Index: ddraw/matrix.h
@@ -54,5 +54,6 @@
5555 void __gluMultMatricesf(const GLfloat a[16], const GLfloat b[16],
5656 GLfloat r[16]);
5757 void __gluMakeIdentityf(GLfloat m[16]);
 58+void __gluMultMatrixVecf(const GLfloat matrix[16], const GLfloat in[4], GLfloat out[4]);
5859
5960 #endif //_MATRIX_H
\ No newline at end of file