Index: ddraw/ddraw.vcxproj |
— | — | @@ -245,6 +245,7 @@ |
246 | 246 | <ClInclude Include="glRenderer.h" />
|
247 | 247 | <ClInclude Include="glRenderWindow.h" />
|
248 | 248 | <ClInclude Include="glutil.h" />
|
| 249 | + <ClInclude Include="fog.h" />
|
249 | 250 | <ClInclude Include="include\d3d.h" />
|
250 | 251 | <ClInclude Include="include\d3dcaps.h" />
|
251 | 252 | <ClInclude Include="include\d3dtypes.h" />
|
— | — | @@ -277,6 +278,7 @@ |
278 | 279 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
|
279 | 280 | </PrecompiledHeader>
|
280 | 281 | </ClCompile>
|
| 282 | + <ClCompile Include="fog.cpp" />
|
281 | 283 | <ClCompile Include="glClassFactory.cpp" />
|
282 | 284 | <ClCompile Include="dxguid.cpp">
|
283 | 285 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -119,6 +119,9 @@ |
120 | 120 | <ClInclude Include="texture.h">
|
121 | 121 | <Filter>Header Files</Filter>
|
122 | 122 | </ClInclude>
|
| 123 | + <ClInclude Include="fog.h">
|
| 124 | + <Filter>Header Files</Filter>
|
| 125 | + </ClInclude>
|
123 | 126 | </ItemGroup>
|
124 | 127 | <ItemGroup>
|
125 | 128 | <ClCompile Include="ddraw.cpp">
|
— | — | @@ -196,6 +199,9 @@ |
197 | 200 | <ClCompile Include="texture.cpp">
|
198 | 201 | <Filter>Source Files</Filter>
|
199 | 202 | </ClCompile>
|
| 203 | + <ClCompile Include="fog.cpp">
|
| 204 | + <Filter>Source Files</Filter>
|
| 205 | + </ClCompile>
|
200 | 206 | </ItemGroup>
|
201 | 207 | <ItemGroup>
|
202 | 208 | <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 @@ |
18 | 18 |
|
19 | 19 | #include "common.h"
|
20 | 20 | #include "texture.h"
|
| 21 | +#include "fog.h"
|
21 | 22 | #include "glDirectDraw.h"
|
22 | 23 | #include "glDirectDrawSurface.h"
|
23 | 24 | #include "glDirectDrawPalette.h"
|
— | — | @@ -788,6 +789,10 @@ |
789 | 790 | glEnable(GL_CULL_FACE);
|
790 | 791 | SwapBuffers(hDC);
|
791 | 792 | SetActiveTexture(0);
|
| 793 | + SetFogColor(0);
|
| 794 | + SetFogStart(0);
|
| 795 | + SetFogEnd(1);
|
| 796 | + SetFogDensity(1);
|
792 | 797 | if(hWnd)
|
793 | 798 | {
|
794 | 799 | dib.enabled = true;
|