DXGL r295 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r294‎ | r295 | r296 >
Date:18:33, 31 December 2012
Author:admin
Status:new
Tags:
Comment:
Add GL fog state functions.
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/fog.cpp (added) (history)
  • /ddraw/fog.h (added) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/ddraw.vcxproj
@@ -245,6 +245,7 @@
246246 <ClInclude Include="glRenderer.h" />
247247 <ClInclude Include="glRenderWindow.h" />
248248 <ClInclude Include="glutil.h" />
 249+ <ClInclude Include="fog.h" />
249250 <ClInclude Include="include\d3d.h" />
250251 <ClInclude Include="include\d3dcaps.h" />
251252 <ClInclude Include="include\d3dtypes.h" />
@@ -277,6 +278,7 @@
278279 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
279280 </PrecompiledHeader>
280281 </ClCompile>
 282+ <ClCompile Include="fog.cpp" />
281283 <ClCompile Include="glClassFactory.cpp" />
282284 <ClCompile Include="dxguid.cpp">
283285 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Index: ddraw/ddraw.vcxproj.filters
@@ -119,6 +119,9 @@
120120 <ClInclude Include="texture.h">
121121 <Filter>Header Files</Filter>
122122 </ClInclude>
 123+ <ClInclude Include="fog.h">
 124+ <Filter>Header Files</Filter>
 125+ </ClInclude>
123126 </ItemGroup>
124127 <ItemGroup>
125128 <ClCompile Include="ddraw.cpp">
@@ -196,6 +199,9 @@
197200 <ClCompile Include="texture.cpp">
198201 <Filter>Source Files</Filter>
199202 </ClCompile>
 203+ <ClCompile Include="fog.cpp">
 204+ <Filter>Source Files</Filter>
 205+ </ClCompile>
200206 </ItemGroup>
201207 <ItemGroup>
202208 <ResourceCompile Include="ddraw.rc">
Index: ddraw/fog.cpp
@@ -0,0 +1,57 @@
 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] = (color >> 16) & 255;
 33+ colors[1] = (color >> 8) & 255;
 34+ colors[2] = color & 255;
 35+ colors[3] = (color >> 24) & 255;
 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/fog.h
@@ -0,0 +1,21 @@
 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/glRenderer.cpp
@@ -17,6 +17,7 @@
1818
1919 #include "common.h"
2020 #include "texture.h"
 21+#include "fog.h"
2122 #include "glDirectDraw.h"
2223 #include "glDirectDrawSurface.h"
2324 #include "glDirectDrawPalette.h"
@@ -788,6 +789,10 @@
789790 glEnable(GL_CULL_FACE);
790791 SwapBuffers(hDC);
791792 SetActiveTexture(0);
 793+ SetFogColor(0);
 794+ SetFogStart(0);
 795+ SetFogEnd(1);
 796+ SetFogDensity(1);
792797 if(hWnd)
793798 {
794799 dib.enabled = true;