Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set shadows on/off only once each time setting is changed, not each f…

…rame.

Turn lights off when no longer drawing with lighting on.
  • Loading branch information...
commit cd1edd63968e60f1d48f2351e340b0b198adf229 1 parent 454f3d3
@perim perim authored
View
7 lib/ivis_opengl/piedef.h
@@ -80,15 +80,12 @@ extern void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colo
extern void pie_GetResetCounts(unsigned int* pPieCount, unsigned int* pPolyCount, unsigned int* pStateCount);
/** Setup stencil shadows and OpenGL lighting. */
-void pie_BeginLighting(const Vector3f * light, bool drawshadows);
+void pie_BeginLighting(const Vector3f *light);
+void pie_setShadows(bool drawShadows);
/** Set light parameters */
void pie_InitLighting();
void pie_SetupLighting();
-
-/* Stop using stencil shadows and OpenGL lighting (if enabled). */
-void pie_EndLighting(void);
-
void pie_Lighting0(LIGHTING_TYPE entry, float value[4]);
void pie_RemainingPasses(void);
View
15 lib/ivis_opengl/piedraw.cpp
@@ -92,17 +92,16 @@ void pie_Lighting0(LIGHTING_TYPE entry, float value[4])
lighting0[entry][3] = value[3];
}
-void pie_BeginLighting(const Vector3f *light, bool drawshadows)
+void pie_setShadows(bool drawShadows)
+{
+ shadows = drawShadows;
+}
+
+void pie_BeginLighting(const Vector3f *light)
{
const float pos[4] = { light->x, light->y, light->z, 0.0f };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
- glEnable(GL_LIGHT0);
-
- if (drawshadows)
- {
- shadows = true;
- }
}
void pie_EndLighting(void)
@@ -546,6 +545,7 @@ static void pie_DrawShadows(void)
void pie_RemainingPasses(void)
{
GL_DEBUG("Remaining passes - shadows");
+ glEnable(GL_LIGHT0);
// Draw shadows
if (shadows)
{
@@ -572,6 +572,7 @@ void pie_RemainingPasses(void)
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_LIGHT0);
pie_DeactivateShader();
glPopMatrix();
tshapes.resize(0);
View
2  src/display.cpp
@@ -28,6 +28,7 @@
#include "lib/framework/input.h"
#include "lib/framework/strres.h"
#include "lib/ivis_opengl/piestate.h"
+#include "lib/ivis_opengl/piedef.h"
#include "lib/framework/fixedpoint.h"
#include "lib/framework/wzapp.h"
@@ -273,6 +274,7 @@ bool getDrawShadows( void )
void setDrawShadows( bool val )
{
bDrawShadows = val;
+ pie_setShadows(val);
}
void setShakeStatus( bool val )
View
4 src/display3d.cpp
@@ -976,7 +976,7 @@ static void drawTiles(iView *player)
// this also detemines the length of the shadows
theSun = getTheSun();
- pie_BeginLighting(&theSun, getDrawShadows());
+ pie_BeginLighting(&theSun);
// update the fog of war... FIXME: Remove this
for (i = -visibleTiles.y/2, idx=0; i <= visibleTiles.y/2; i++,++idx)
@@ -1059,8 +1059,6 @@ static void drawTiles(iView *player)
pie_RemainingPasses(); // draws shadows and transparent shapes
- pie_EndLighting();
-
if(!gamePaused())
{
doConstructionLines();
Please sign in to comment.
Something went wrong with that request. Please try again.