DXGL r310 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r309‎ | r310 | r311 >
Date:19:17, 13 January 2013
Author:admin
Status:new
Tags:
Comment:
Add flat shading.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glutil.cpp (modified) (history)
  • /ddraw/glutil.h (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -794,6 +794,7 @@
795795 SetFogEnd(1);
796796 SetFogDensity(1);
797797 SetPolyMode(D3DFILL_SOLID);
 798+ SetShadeMode(D3DSHADE_GOURAUD);
798799 if(hWnd)
799800 {
800801 dib.enabled = true;
@@ -1576,6 +1577,7 @@
15771578 SetFogEnd(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
15781579 SetFogDensity(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
15791580 SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
 1581+ SetShadeMode((D3DSHADEMODE)device->renderstate[D3DRENDERSTATE_SHADEMODE]);
15801582 if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
15811583 else glDrawArrays(mode,0,count);
15821584 if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
Index: ddraw/glutil.cpp
@@ -58,6 +58,7 @@
5959 D3DCULL cullmode = D3DCULL_NONE;
6060 bool cullenabled = false;
6161 D3DFILLMODE polymode = D3DFILL_SOLID;
 62+D3DSHADEMODE shademode = D3DSHADE_GOURAUD;
6263
6364 void InitFBO()
6465 {
@@ -412,4 +413,24 @@
413414 break;
414415 }
415416 }
 417+}
 418+
 419+void SetShadeMode(D3DSHADEMODE mode)
 420+{
 421+ if(shademode != mode)
 422+ {
 423+ shademode = mode;
 424+ switch(mode)
 425+ {
 426+ case D3DSHADE_FLAT:
 427+ case 4:
 428+ glShadeModel(GL_FLAT);
 429+ break;
 430+ case D3DSHADE_GOURAUD:
 431+ case D3DSHADE_PHONG:
 432+ default:
 433+ glShadeModel(GL_SMOOTH);
 434+ break;
 435+ }
 436+ }
416437 }
\ No newline at end of file
Index: ddraw/glutil.h
@@ -46,5 +46,6 @@
4747 void EnableCull(bool enabled);
4848 void SetCull(D3DCULL mode);
4949 void SetPolyMode(D3DFILLMODE mode);
 50+void SetShadeMode(D3DSHADEMODE mode);
5051
5152 #endif //_GLUTIL_H
\ No newline at end of file