Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do not set light parameters every frame (except Sun position). Fix bug

with light parameters not being reset between games. Closes ticket:3952
  • Loading branch information...
commit d69f336ec4bbe7b3c9b9207a09c01dcd797f6f77 1 parent def1e4f
@perim perim authored
View
4 data/mp/multiplay/skirmish/semperfi.js
@@ -747,4 +747,8 @@ function eventChat(from, to, message)
{
donatePower(playerPower(me) / 2, from);
}
+ else if (message == "crazycolours")
+ {
+ setSunIntensity(0.6, 0.4, 0.3, 1.0, 0.8, 0.7, 1.2, 0.9, 0.8);
+ }
}
View
4 lib/ivis_opengl/piedef.h
@@ -82,6 +82,10 @@ extern void pie_GetResetCounts(unsigned int* pPieCount, unsigned int* pPolyCount
/** Setup stencil shadows and OpenGL lighting. */
void pie_BeginLighting(const Vector3f * light, bool drawshadows);
+/** Set light parameters */
+void pie_InitLighting();
+void pie_SetupLighting();
+
/* Stop using stencil shadows and OpenGL lighting (if enabled). */
void pie_EndLighting(void);
View
30 lib/ivis_opengl/piedraw.cpp
@@ -59,12 +59,28 @@ static GLenum ss_op_depth_pass_back = GL_DECR;
static unsigned int pieCount = 0;
static unsigned int polyCount = 0;
static bool shadows = false;
-static GLfloat lighting0[LIGHT_MAX][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}, {0.8f, 0.8f, 0.8f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
+static GLfloat lighting0[LIGHT_MAX][4];
/*
* Source
*/
+void pie_InitLighting()
+{
+ const GLfloat defaultLight[LIGHT_MAX][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}, {0.8f, 0.8f, 0.8f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
+ memcpy(lighting0, defaultLight, sizeof(lighting0));
+ pie_SetupLighting();
+}
+
+void pie_SetupLighting()
+{
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lighting0[LIGHT_EMISSIVE]);
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, lighting0[LIGHT_AMBIENT]);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, lighting0[LIGHT_DIFFUSE]);
+ glLightfv(GL_LIGHT0, GL_SPECULAR, lighting0[LIGHT_SPECULAR]);
+}
+
void pie_Lighting0(LIGHTING_TYPE entry, float value[4])
{
lighting0[entry][0] = value[0];
@@ -75,14 +91,9 @@ void pie_Lighting0(LIGHTING_TYPE entry, float value[4])
void pie_BeginLighting(const Vector3f *light, bool drawshadows)
{
- const float pos[4] = {light->x, light->y, light->z, 0.0f};
+ const float pos[4] = { light->x, light->y, light->z, 0.0f };
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lighting0[LIGHT_EMISSIVE]);
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
- glLightfv(GL_LIGHT0, GL_AMBIENT, lighting0[LIGHT_AMBIENT]);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, lighting0[LIGHT_DIFFUSE]);
- glLightfv(GL_LIGHT0, GL_SPECULAR, lighting0[LIGHT_SPECULAR]);
glEnable(GL_LIGHT0);
if (drawshadows)
@@ -91,11 +102,6 @@ void pie_BeginLighting(const Vector3f *light, bool drawshadows)
}
}
-bool pie_GetLightingState(void)
-{
- return true;
-}
-
void pie_EndLighting(void)
{
shadows = false;
View
1  src/init.cpp
@@ -1094,6 +1094,7 @@ bool stageThreeInitialise(void)
effectResetUpdates();
initLighting(0, 0, mapWidth, mapHeight);
+ pie_InitLighting();
if(bMultiPlayer)
{
View
1  src/qtscriptfuncs.cpp
@@ -3669,6 +3669,7 @@ static QScriptValue js_setSunIntensity(QScriptContext *context, QScriptEngine *)
pie_Lighting0(LIGHT_AMBIENT, ambient);
pie_Lighting0(LIGHT_DIFFUSE, diffuse);
pie_Lighting0(LIGHT_SPECULAR, specular);
+ pie_SetupLighting();
return QScriptValue();
}
View
1  src/scriptfuncs.cpp
@@ -260,6 +260,7 @@ bool scrSetSunIntensity(void)
pie_Lighting0(LIGHT_AMBIENT, ambient);
pie_Lighting0(LIGHT_DIFFUSE, diffuse);
pie_Lighting0(LIGHT_SPECULAR, specular);
+ pie_SetupLighting();
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.