DXGL r197 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r196‎ | r197 | r198 >
Date:15:08, 4 July 2012
Author:admin
Status:new
Tags:
Comment:
Support clearing rects.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glutil.cpp (modified) (history)
  • /ddraw/glutil.h (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -808,6 +808,8 @@
809809 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
810810 glClear(GL_COLOR_BUFFER_BIT);
811811 glFlush();
 812+ SetScissor(false,0,0,0,0);
 813+ glDisable(GL_SCISSOR_TEST);
812814 SwapBuffers(hDC);
813815 SetActiveTexture(0);
814816 if(hWnd)
@@ -1216,13 +1218,6 @@
12171219
12181220 void glRenderer::_Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
12191221 {
1220 - if(dwCount)
1221 - {
1222 - outputs[0] = (void*)DDERR_INVALIDPARAMS;
1223 - FIXME("glDirect3DDevice7::Clear: Cannot clear rects yet.");
1224 - SetEvent(busy);
1225 - return;
1226 - }
12271222 outputs[0] = (void*)D3D_OK;
12281223 GLfloat color[4];
12291224 dwordto4float(dwColor,color);
@@ -1244,7 +1239,16 @@
12451240 clearbits |= GL_STENCIL_BUFFER_BIT;
12461241 glClearStencil(dwStencil);
12471242 }
1248 - glClear(clearbits);
 1243+ if(dwCount)
 1244+ {
 1245+ for(int i = 0; i < dwCount; i++)
 1246+ {
 1247+ SetScissor(true,lpRects[i].x1,lpRects[i].y1,lpRects[i].x2,lpRects[i].y2);
 1248+ glClear(clearbits);
 1249+ }
 1250+ SetScissor(false,0,0,0,0);
 1251+ }
 1252+ else glClear(clearbits);
12491253 if(target->zbuffer) target->zbuffer->dirty |= 2;
12501254 target->dirty |= 2;
12511255 SetEvent(busy);
Index: ddraw/glutil.cpp
@@ -25,6 +25,11 @@
2626 GLuint fbcolor = 0;
2727 GLuint fbz = 0;
2828 GLuint fbo = 0;
 29+GLint scissorx = 0;
 30+GLint scissory = 0;
 31+GLsizei scissorwidth = 0;
 32+GLsizei scissorheight = 0;
 33+bool scissorenabled = false;
2934 bool stencil = false;
3035 GLint texlevel = 0;
3136 GLint texwrap[16];
@@ -188,4 +193,22 @@
189194 depthcomp = comp;
190195 glDepthFunc(comp);
191196 }
 197+}
 198+
 199+void SetScissor(bool enabled, GLint x, GLint y, GLsizei width, GLsizei height)
 200+{
 201+ if(enabled != scissorenabled)
 202+ {
 203+ scissorenabled = enabled;
 204+ if(enabled) glEnable(GL_SCISSOR_TEST);
 205+ else glDisable(GL_SCISSOR_TEST);
 206+ }
 207+ if((x != scissorx) || (y != scissory) || (width != scissorwidth) || (height != scissorheight))
 208+ {
 209+ scissorx = x;
 210+ scissory = y;
 211+ scissorwidth = width;
 212+ scissorheight = height;
 213+ glScissor(x,y,width,height);
 214+ }
192215 }
\ No newline at end of file
Index: ddraw/glutil.h
@@ -31,5 +31,6 @@
3232 void SetDepthComp(GLenum comp);
3333 void DepthWrite(bool enabled);
3434 void DepthTest(bool enabled);
 35+void SetScissor(bool enabled, GLint x, GLint y, GLsizei width, GLsizei height);
3536
3637 #endif //_GLUTIL_H
\ No newline at end of file