DXGL r300 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r299‎ | r300 | r301 >
Date:02:41, 5 January 2013
Author:admin
Status:new
Tags:
Comment:
Add polygon fill modes. (currently broken)
Clamp fog coordinates.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glutil.cpp (modified) (history)
  • /ddraw/glutil.h (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012 William Feely
 3+// Copyright (C) 2012-2013 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -793,6 +793,7 @@
794794 SetFogStart(0);
795795 SetFogEnd(1);
796796 SetFogDensity(1);
 797+ SetPolyMode(D3DFILL_SOLID);
797798 if(hWnd)
798799 {
799800 dib.enabled = true;
@@ -1570,6 +1571,7 @@
15711572 SetFogStart(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
15721573 SetFogEnd(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
15731574 SetFogDensity(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
 1575+ SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
15741576 if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
15751577 else glDrawArrays(mode,0,count);
15761578 if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
Index: ddraw/glutil.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012 William Feely
 3+// Copyright (C) 2012-2013 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -57,6 +57,7 @@
5858 bool arrays[42];
5959 D3DCULL cullmode = D3DCULL_NONE;
6060 bool cullenabled = false;
 61+D3DFILLMODE polymode = D3DFILL_SOLID;
6162
6263 void InitFBO()
6364 {
@@ -390,4 +391,24 @@
391392 break;
392393 }
393394 }
 395+}
 396+void SetPolyMode(D3DFILLMODE mode)
 397+{
 398+ if(polymode != mode)
 399+ {
 400+ polymode = mode;
 401+ switch(mode)
 402+ {
 403+ case D3DFILL_POINT:
 404+ glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
 405+ break;
 406+ case D3DFILL_WIREFRAME:
 407+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
 408+ break;
 409+ case D3DFILL_SOLID:
 410+ default:
 411+ glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
 412+ break;
 413+ }
 414+ }
394415 }
\ No newline at end of file
Index: ddraw/glutil.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012 William Feely
 3+// Copyright (C) 2012-2013 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -45,5 +45,6 @@
4646 void BlendEnable(bool enabled);
4747 void EnableCull(bool enabled);
4848 void SetCull(D3DCULL mode);
 49+void SetPolyMode(D3DFILLMODE mode);
4950
5051 #endif //_GLUTIL_H
\ No newline at end of file
Index: ddraw/shadergen.cpp
@@ -268,7 +268,7 @@
269269 static const char var_common[] = "vec4 diffuse;\n\
270270 vec4 specular;\n\
271271 vec4 ambient;\n\
272 -vec3 N;";
 272+vec3 N;\n";
273273 static const char var_color[] = "vec4 color;\n";
274274 static const char var_xyzw[] = "vec4 xyzw;\n";
275275 static const char var_fogfactorvertex[] = "varying float fogfactor;\n";
@@ -632,6 +632,7 @@
633633 vsrc->append(op_fogexp2);
634634 break;
635635 }
 636+ vsrc->append(op_fogclamp);
636637 }
637638 vsrc->append(mainend);
638639 #ifdef _DEBUG