GLES only accepts GL_FRONT_AND_BACK, GL_FRONT is not needed when face culling is in use

git-svn-id: svn://www.homeworldsdl.org:3692/homeworldsdl/homeworld/trunk@906 026c9d8a-83c9-0310-a9c7-971d0a006279
This commit is contained in:
lauriebradshaw
2011-04-13 02:45:35 +00:00
parent d59c50ba11
commit 5e13cc658c
3 changed files with 6 additions and 89 deletions

View File

@ -1083,15 +1083,15 @@ void cloudRenderSystem(cloudSystem* system, sdword lod)
attrib[1] = 0.0f;
attrib[2] = 0.0f;
attrib[3] = 0.0f;
glMaterialfv(GL_FRONT, GL_AMBIENT, attrib);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, attrib);
attrib[3] = 0.5f;
glMaterialfv(GL_FRONT, GL_DIFFUSE, attrib);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, attrib);
attrib[0] = (GLfloat)colRed(cloudColor) / 255.0f;
attrib[1] = (GLfloat)colGreen(cloudColor) / 255.0f;
attrib[2] = (GLfloat)colBlue(cloudColor) / 255.0f;
glMaterialfv(GL_FRONT, GL_SPECULAR, attrib);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, attrib);
attrib[0] = 11.0f;
glMaterialfv(GL_FRONT, GL_SHININESS, attrib);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, attrib);
switch (lod)
{

View File

@ -1220,7 +1220,7 @@ void meshCurrentMaterialDefault(materialentry *material, sdword iColorScheme)
}
else
{
face = GL_FRONT;
face = GL_FRONT_AND_BACK;
rndBackFaceCullEnable(TRUE); //enable culling
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); //1-sided lightmodel
}
@ -1383,7 +1383,7 @@ void meshCurrentMaterialTex(materialentry *material, sdword iColorScheme)
}
else
{
face = GL_FRONT;
face = GL_FRONT_AND_BACK;
rndBackFaceCullEnable(TRUE); //enable culling
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); //1-sided lightmodel
}

View File

@ -4232,87 +4232,6 @@ sdword rndAdditiveBlends(sdword bAdditive)
return(oldStatus);
}
/*-----------------------------------------------------------------------------
Name : rndMaterialfv
Description : set GL material params
Inputs : face - GL_FRONT or GL_FRONT_AND_BACK
pname - GL_AMBIENT or GL_DIFFUSE
params - RGBA [0..1]
Outputs :
Return : TRUE if material was updated, FALSE if same as last
----------------------------------------------------------------------------*/
#define V4_EQUAL(A, B) (A[0] != B[0] || A[1] != B[1] || A[2] != B[2] || A[3] != B[3]) ? FALSE : TRUE
#define V4_SET(D, S) \
{ \
D[0] = S[0]; \
D[1] = S[1]; \
D[2] = S[2]; \
D[3] = S[3]; \
}
sdword rndMaterialfv(sdword face, sdword pname, real32* params)
{
static real32 ambient[2][4] = {{-1.0f, -1.0f, -1.0f, -1.0f},{-1.0f, -1.0f, -1.0f, -1.0f}};
static real32 diffuse[2][4] = {{-1.0f, -1.0f, -1.0f, -1.0f},{-1.0f, -1.0f, -1.0f, -1.0f}};
if (face == -1)
{
real32 reset[4] = {-1.0f, -1.0f, -1.0f, -1.0f};
V4_SET(ambient[0], reset);
V4_SET(ambient[1], reset);
V4_SET(diffuse[0], reset);
V4_SET(diffuse[1], reset);
return TRUE;
}
if (face == GL_FRONT)
{
if (pname == GL_AMBIENT)
{
if (!V4_EQUAL(ambient[0], params))
{
V4_SET(ambient[0], params);
glMaterialfv(face, pname, params);
return TRUE;
}
}
else
{
if (!V4_EQUAL(diffuse[0], params))
{
V4_SET(diffuse[0], params);
glMaterialfv(face, pname, params);
return TRUE;
}
}
}
else
{
if (pname == GL_AMBIENT)
{
if (!V4_EQUAL(ambient[0], params) || !V4_EQUAL(ambient[1], params))
{
V4_SET(ambient[0], params);
V4_SET(ambient[1], params);
glMaterialfv(face, pname, params);
return TRUE;
}
}
else
{
if (!V4_EQUAL(diffuse[0], params) || !V4_EQUAL(ambient[1], params))
{
V4_SET(diffuse[0], params);
V4_SET(diffuse[1], params);
glMaterialfv(face, pname, params);
return TRUE;
}
}
}
return FALSE;
}
#define vcSub(a,b,c) \
(a)->x = (b)->x - (c)->x; \
(a)->y = (b)->y - (c)->y; \
@ -4506,8 +4425,6 @@ void rndResetGLState(void)
{
trClearCurrent();
rndMaterialfv(-1, 0, NULL);
if (rndAdditiveBlending)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE);