DXGL r431 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r430‎ | r431 | r432 >
Date:00:42, 18 April 2014
Author:admin
Status:new
Tags:
Comment:
Move GL fog state to glRenderer class.
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/fog.cpp (deleted) (history)
  • /ddraw/fog.h (deleted) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/fog.h
@@ -1,21 +0,0 @@
2 -// DXGL
3 -// Copyright (C) 2012 William Feely
4 -
5 -// This library is free software; you can redistribute it and/or
6 -// modify it under the terms of the GNU Lesser General Public
7 -// License as published by the Free Software Foundation; either
8 -// version 2.1 of the License, or (at your option) any later version.
9 -
10 -// This library is distributed in the hope that it will be useful,
11 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 -// Lesser General Public License for more details.
14 -
15 -// You should have received a copy of the GNU Lesser General Public
16 -// License along with this library; if not, write to the Free Software
17 -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 -
19 -void SetFogColor(DWORD color);
20 -void SetFogStart(GLfloat start);
21 -void SetFogEnd(GLfloat end);
22 -void SetFogDensity(GLfloat density);
\ No newline at end of file
Index: ddraw/fog.cpp
@@ -1,57 +0,0 @@
2 -// DXGL
3 -// Copyright (C) 2012 William Feely
4 -
5 -// This library is free software; you can redistribute it and/or
6 -// modify it under the terms of the GNU Lesser General Public
7 -// License as published by the Free Software Foundation; either
8 -// version 2.1 of the License, or (at your option) any later version.
9 -
10 -// This library is distributed in the hope that it will be useful,
11 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 -// Lesser General Public License for more details.
14 -
15 -// You should have received a copy of the GNU Lesser General Public
16 -// License along with this library; if not, write to the Free Software
17 -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 -
19 -#include "common.h"
20 -#include "fog.h"
21 -
22 -static DWORD fogcolor = 0;
23 -static GLfloat fogstart = 0;
24 -static GLfloat fogend = 1;
25 -static GLfloat fogdensity = 1;
26 -
27 -void SetFogColor(DWORD color)
28 -{
29 - if(color == fogcolor) return;
30 - fogcolor = color;
31 - GLfloat colors[4];
32 - colors[0] = (GLfloat)((color >> 16) & 255)/255.0f;
33 - colors[1] = (GLfloat)((color >> 8) & 255)/255.0f;
34 - colors[2] = (GLfloat)(color & 255)/255.0f;
35 - colors[3] = (GLfloat)((color >> 24) & 255)/255.0f;
36 - glFogfv(GL_FOG_COLOR,colors);
37 -}
38 -
39 -void SetFogStart(GLfloat start)
40 -{
41 - if(start == fogstart) return;
42 - fogstart = start;
43 - glFogf(GL_FOG_START,start);
44 -}
45 -
46 -void SetFogEnd(GLfloat end)
47 -{
48 - if(end == fogend) return;
49 - fogend = end;
50 - glFogf(GL_FOG_END,end);
51 -}
52 -
53 -void SetFogDensity(GLfloat density)
54 -{
55 - if(density == fogdensity) return;
56 - fogdensity = density;
57 - glFogf(GL_FOG_DENSITY,density);
58 -}
\ No newline at end of file
Index: ddraw/ddraw.vcxproj
@@ -284,7 +284,6 @@
285285 <ClInclude Include="glRenderer.h" />
286286 <ClInclude Include="glRenderWindow.h" />
287287 <ClInclude Include="glutil.h" />
288 - <ClInclude Include="fog.h" />
289288 <ClInclude Include="include\d3d.h" />
290289 <ClInclude Include="include\d3dcaps.h" />
291290 <ClInclude Include="include\d3dtypes.h" />
@@ -324,7 +323,6 @@
325324 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
326325 </PrecompiledHeader>
327326 </ClCompile>
328 - <ClCompile Include="fog.cpp" />
329327 <ClCompile Include="glClassFactory.cpp" />
330328 <ClCompile Include="dxguid.cpp">
331329 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Index: ddraw/ddraw.vcxproj.filters
@@ -119,9 +119,6 @@
120120 <ClInclude Include="texture.h">
121121 <Filter>Header Files</Filter>
122122 </ClInclude>
123 - <ClInclude Include="fog.h">
124 - <Filter>Header Files</Filter>
125 - </ClInclude>
126123 <ClInclude Include="glDirect3DExecuteBuffer.h">
127124 <Filter>Header Files</Filter>
128125 </ClInclude>
@@ -214,9 +211,6 @@
215212 <ClCompile Include="texture.cpp">
216213 <Filter>Source Files</Filter>
217214 </ClCompile>
218 - <ClCompile Include="fog.cpp">
219 - <Filter>Source Files</Filter>
220 - </ClCompile>
221215 <ClCompile Include="glDirect3DExecuteBuffer.cpp">
222216 <Filter>Source Files</Filter>
223217 </ClCompile>
Index: ddraw/glRenderer.cpp
@@ -17,7 +17,6 @@
1818
1919 #include "common.h"
2020 #include "texture.h"
21 -#include "fog.h"
2221 #include "glutil.h"
2322 #include "timer.h"
2423 #include "glDirectDraw.h"
@@ -192,6 +191,10 @@
193192 */
194193 glRenderer::glRenderer(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7)
195194 {
 195+ fogcolor = 0;
 196+ fogstart = 0.0f;
 197+ fogend = 1.0f;
 198+ fogdensity = 1.0f;
196199 backbuffer = NULL;
197200 hDC = NULL;
198201 hRC = NULL;
@@ -821,10 +824,10 @@
822825 glEnable(GL_CULL_FACE);
823826 SwapBuffers(hDC);
824827 SetActiveTexture(0);
825 - SetFogColor(0);
826 - SetFogStart(0);
827 - SetFogEnd(1);
828 - SetFogDensity(1);
 828+ _SetFogColor(0);
 829+ _SetFogStart(0);
 830+ _SetFogEnd(1);
 831+ _SetFogDensity(1);
829832 SetPolyMode(D3DFILL_SOLID);
830833 SetShadeMode(D3DSHADE_GOURAUD);
831834 if(hWnd)
@@ -1625,10 +1628,10 @@
16261629 else BlendEnable(false);
16271630 SetBlend(device->renderstate[D3DRENDERSTATE_SRCBLEND],device->renderstate[D3DRENDERSTATE_DESTBLEND]);
16281631 SetCull((D3DCULL)device->renderstate[D3DRENDERSTATE_CULLMODE]);
1629 - SetFogColor(device->renderstate[D3DRENDERSTATE_FOGCOLOR]);
1630 - SetFogStart(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
1631 - SetFogEnd(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
1632 - SetFogDensity(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
 1632+ _SetFogColor(device->renderstate[D3DRENDERSTATE_FOGCOLOR]);
 1633+ _SetFogStart(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
 1634+ _SetFogEnd(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
 1635+ _SetFogDensity(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
16331636 SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
16341637 SetShadeMode((D3DSHADEMODE)device->renderstate[D3DRENDERSTATE_SHADEMODE]);
16351638 if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
@@ -1645,4 +1648,37 @@
16461649 {
16471650 ::DeleteFBO(fbo);
16481651 SetEvent(busy);
1649 -}
\ No newline at end of file
 1652+}
 1653+
 1654+void glRenderer::_SetFogColor(DWORD color)
 1655+{
 1656+ if (color == fogcolor) return;
 1657+ fogcolor = color;
 1658+ GLfloat colors[4];
 1659+ colors[0] = (GLfloat)((color >> 16) & 255) / 255.0f;
 1660+ colors[1] = (GLfloat)((color >> 8) & 255) / 255.0f;
 1661+ colors[2] = (GLfloat)(color & 255) / 255.0f;
 1662+ colors[3] = (GLfloat)((color >> 24) & 255) / 255.0f;
 1663+ glFogfv(GL_FOG_COLOR, colors);
 1664+}
 1665+
 1666+void glRenderer::_SetFogStart(GLfloat start)
 1667+{
 1668+ if (start == fogstart) return;
 1669+ fogstart = start;
 1670+ glFogf(GL_FOG_START, start);
 1671+}
 1672+
 1673+void glRenderer::_SetFogEnd(GLfloat end)
 1674+{
 1675+ if (end == fogend) return;
 1676+ fogend = end;
 1677+ glFogf(GL_FOG_END, end);
 1678+}
 1679+
 1680+void glRenderer::_SetFogDensity(GLfloat density)
 1681+{
 1682+ if (density == fogdensity) return;
 1683+ fogdensity = density;
 1684+ glFogf(GL_FOG_DENSITY, density);
 1685+}
Index: ddraw/glRenderer.h
@@ -122,6 +122,10 @@
123123 void _Flush();
124124 void _SetWnd(int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd);
125125 void _DeleteFBO(FBO *fbo);
 126+ void _SetFogColor(DWORD color);
 127+ void _SetFogStart(GLfloat start);
 128+ void _SetFogEnd(GLfloat end);
 129+ void _SetFogDensity(GLfloat density);
126130 int opcode;
127131 void* inputs[32];
128132 void* outputs[32];
@@ -140,6 +144,10 @@
141145 TEXTURE *backbuffer;
142146 int backx;
143147 int backy;
 148+ DWORD fogcolor;
 149+ GLfloat fogstart;
 150+ GLfloat fogend;
 151+ GLfloat fogdensity;
144152 };
145153
146154 #endif //_GLRENDERER_H
\ No newline at end of file