DXGL r328 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r327‎ | r328 | r329 >
Date:17:26, 18 February 2013
Author:admin
Status:new
Tags:
Comment:
Fix Z-buffer surface creation for IDirectDraw interface.
Fix Clear command flags.
Only call DrawIndexedPrimitive in D3DOP_TRIANGLE if wCount is greater than 0.
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -2201,8 +2201,8 @@
22022202 if(result == -1) return DDERR_OUTOFMEMORY;
22032203 opptr += instruction->bSize;
22042204 }
2205 - DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_TLVERTEX,vert_ptr,(desc.dwBufferSize-data.dwVertexOffset)/sizeof(D3DVERTEX),
2206 - (WORD*)ebBuffer,instruction->wCount*3,0);
 2205+ if(instruction->wCount) DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_TLVERTEX,vert_ptr,
 2206+ (desc.dwBufferSize-data.dwVertexOffset)/sizeof(D3DVERTEX), (WORD*)ebBuffer,instruction->wCount*3,0);
22072207 break;
22082208 case D3DOP_MATRIXLOAD:
22092209 opptr += sizeof(D3DINSTRUCTION);
Index: ddraw/glDirectDrawSurface.cpp
@@ -216,6 +216,28 @@
217217 buffer = NULL;
218218 if((dxglcfg.scalingfilter == 0) || (ddInterface->GetBPP() == 8)) magfilter = minfilter = GL_NEAREST;
219219 else magfilter = minfilter = GL_LINEAR;
 220+ if(ddsd.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
 221+ {
 222+ ddsd.dwFlags |= DDSD_PIXELFORMAT;
 223+ ddsd.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
 224+ ddsd.ddpfPixelFormat.dwZBufferBitDepth = ddsd.dwRefreshRate;
 225+ switch(ddsd.ddpfPixelFormat.dwZBufferBitDepth)
 226+ {
 227+ case 8:
 228+ ddsd.ddpfPixelFormat.dwZBitMask = 0xFF;
 229+ break;
 230+ case 16:
 231+ ddsd.ddpfPixelFormat.dwZBitMask = 0xFFFF;
 232+ break;
 233+ case 24:
 234+ ddsd.ddpfPixelFormat.dwZBitMask = 0xFFFFFF;
 235+ break;
 236+ case 32:
 237+ default:
 238+ ddsd.ddpfPixelFormat.dwZBitMask = 0xFFFFFFFF;
 239+ break;
 240+ }
 241+ }
220242 if(!(ddsd.dwFlags & DDSD_PIXELFORMAT))
221243 {
222244 ZeroMemory(&ddsd.ddpfPixelFormat,sizeof(DDPIXELFORMAT));
Index: ddraw/glRenderer.cpp
@@ -1202,17 +1202,17 @@
12031203 if(target->zbuffer) SetFBO(target->texture,target->GetZBuffer()->texture,target->GetZBuffer()->hasstencil);
12041204 else SetFBO(target->texture,0,false);
12051205 int clearbits = 0;
1206 - if(D3DCLEAR_TARGET)
 1206+ if(dwFlags & D3DCLEAR_TARGET)
12071207 {
12081208 clearbits |= GL_COLOR_BUFFER_BIT;
12091209 ClearColor(color[0],color[1],color[2],color[3]);
12101210 }
1211 - if(D3DCLEAR_ZBUFFER)
 1211+ if(dwFlags & D3DCLEAR_ZBUFFER)
12121212 {
12131213 clearbits |= GL_DEPTH_BUFFER_BIT;
12141214 ClearDepth(dvZ);
12151215 }
1216 - if(D3DCLEAR_STENCIL)
 1216+ if(dwFlags & D3DCLEAR_STENCIL)
12171217 {
12181218 clearbits |= GL_STENCIL_BUFFER_BIT;
12191219 ClearStencil(dwStencil);