mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- refactored fog and depth func setting into GLInterface.
This commit is contained in:
parent
204abab724
commit
cb80e877ff
5 changed files with 68 additions and 43 deletions
|
@ -1989,7 +1989,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
{
|
||||
double f = (double) (tspr->owner + 1) * (std::numeric_limits<double>::epsilon() * 8.0);
|
||||
if (f != 0.0) f *= 1.0/(double) (sepldist(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||
}
|
||||
|
||||
if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) glFrontFace(GL_CW); else glFrontFace(GL_CCW);
|
||||
|
|
|
@ -942,23 +942,20 @@ void calc_and_apply_fog(int32_t shade, int32_t vis, int32_t pal)
|
|||
fogresult2 = -GL_FOG_MAX; // hide fog behind the camera
|
||||
}
|
||||
|
||||
glFogf(GL_FOG_START, fogresult);
|
||||
glFogf(GL_FOG_END, fogresult2);
|
||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
||||
|
||||
GLInterface.SetFogLinear((float*)&fogcol, fogresult, fogresult2);
|
||||
return;
|
||||
}
|
||||
|
||||
fogcalc(shade, vis, pal);
|
||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
||||
|
||||
if (r_usenewshading < 2)
|
||||
glFogf(GL_FOG_DENSITY, fogresult);
|
||||
else
|
||||
if (r_usenewshading < 2)
|
||||
{
|
||||
GLInterface.SetFogExp2((float*)& fogcol, fogresult);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFogf(GL_FOG_START, fogresult);
|
||||
glFogf(GL_FOG_END, fogresult2);
|
||||
}
|
||||
GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2);
|
||||
}
|
||||
}
|
||||
|
||||
void calc_and_apply_fog_factor(int32_t shade, int32_t vis, int32_t pal, float factor)
|
||||
|
@ -987,25 +984,21 @@ void calc_and_apply_fog_factor(int32_t shade, int32_t vis, int32_t pal, float fa
|
|||
fogresult2 = -GL_FOG_MAX; // hide fog behind the camera
|
||||
}
|
||||
|
||||
glFogf(GL_FOG_START, fogresult);
|
||||
glFogf(GL_FOG_END, fogresult2);
|
||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
||||
|
||||
return;
|
||||
GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2);
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: for r_usenewshading >= 2, the fog beginning/ending distance results are
|
||||
// unused.
|
||||
fogcalc(shade, vis, pal);
|
||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
||||
|
||||
if (r_usenewshading < 2)
|
||||
glFogf(GL_FOG_DENSITY, fogresult*factor);
|
||||
else
|
||||
{
|
||||
glFogf(GL_FOG_START, (GLfloat) FULLVIS_BEGIN);
|
||||
glFogf(GL_FOG_END, (GLfloat) FULLVIS_END);
|
||||
}
|
||||
if (r_usenewshading < 2)
|
||||
{
|
||||
GLInterface.SetFogExp2((float*)& fogcol, fogresult*factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLInterface.SetFogLinear((float*)& fogcol, FULLVIS_BEGIN, FULLVIS_END);
|
||||
}
|
||||
}
|
||||
////////////////////
|
||||
|
||||
|
@ -2397,11 +2390,11 @@ do
|
|||
|
||||
polymost_setFogEnabled(false);
|
||||
|
||||
glDepthFunc(GL_EQUAL);
|
||||
GLInterface.SetDepthFunc(Depth_Equal);
|
||||
|
||||
polymost_drawpoly(dpxy, n, method_);
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||
|
||||
if (!nofog)
|
||||
polymost_setFogEnabled(true);
|
||||
|
@ -5266,8 +5259,7 @@ void polymost_drawrooms()
|
|||
GLInterface.EnableBlend(false);
|
||||
GLInterface.EnableAlphaTest(false);
|
||||
GLInterface.EnableDepthTest(true);
|
||||
glDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
|
||||
GLInterface.SetDepthFunc(Depth_Always);
|
||||
|
||||
polymost_setBrightness(r_brightnesshack);
|
||||
|
||||
|
@ -5375,7 +5367,12 @@ void polymost_drawrooms()
|
|||
}
|
||||
}
|
||||
|
||||
if (n < 3) { glDepthFunc(GL_LEQUAL); videoEndDrawing(); return; }
|
||||
if (n < 3)
|
||||
{
|
||||
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||
videoEndDrawing();
|
||||
return;
|
||||
}
|
||||
|
||||
float sx[6], sy[6];
|
||||
|
||||
|
@ -5506,9 +5503,8 @@ void polymost_drawrooms()
|
|||
bunchlast[closest] = bunchlast[numbunches];
|
||||
}
|
||||
|
||||
glDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
|
||||
polymost_identityrotmat();
|
||||
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||
polymost_identityrotmat();
|
||||
|
||||
videoEndDrawing();
|
||||
}
|
||||
|
@ -7474,8 +7470,6 @@ static int osdcmd_cvar_set_polymost(osdcmdptr_t parm)
|
|||
gltexapplyprops();
|
||||
else if (!Bstrcasecmp(parm->name, "r_texfilter"))
|
||||
gltexturemode(parm);
|
||||
else if (!Bstrcasecmp(parm->name, "r_usenewshading"))
|
||||
glFogi(GL_FOG_MODE, (r_usenewshading < 2) ? GL_EXP2 : GL_LINEAR);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
@ -1081,8 +1081,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
|
||||
if (shadowHack)
|
||||
{
|
||||
glDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
}
|
||||
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||
}
|
||||
|
||||
|
||||
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0))
|
||||
|
@ -1193,9 +1193,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
|
||||
if (shadowHack)
|
||||
{
|
||||
glDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
// glDepthRange(0.0, 0.99999);
|
||||
}
|
||||
GLInterface.SetDepthFunc(Depth_Less);
|
||||
}
|
||||
VSMatrix identity(0);
|
||||
GLInterface.SetMatrix(Matrix_ModelView, &identity);
|
||||
return 1;
|
||||
|
|
|
@ -22,7 +22,6 @@ void GLInstance::InitGLState(int fogmode, int multisample)
|
|||
glDisable(GL_DITHER);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glHint(GL_FOG_HINT, GL_NICEST);
|
||||
glFogi(GL_FOG_MODE, (fogmode < 2) ? GL_EXP2 : GL_LINEAR);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
@ -201,3 +200,24 @@ void GLInstance::SetColor(float r, float g, float b, float a)
|
|||
{
|
||||
glColor4f(r, g, b, a);
|
||||
}
|
||||
|
||||
void GLInstance::SetDepthFunc(int func)
|
||||
{
|
||||
int f[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL };
|
||||
glDepthFunc(f[func]);
|
||||
}
|
||||
|
||||
void GLInstance::SetFogLinear(float* color, float start, float end)
|
||||
{
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, start);
|
||||
glFogf(GL_FOG_END, end);
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
}
|
||||
|
||||
void GLInstance::SetFogExp2(float* color, float coefficient)
|
||||
{
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
glFogf(GL_FOG_DENSITY, coefficient);
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,14 @@ enum ECull
|
|||
Cull_Back
|
||||
};
|
||||
|
||||
enum EDepthFunc
|
||||
{
|
||||
Depth_Always,
|
||||
Depth_Less,
|
||||
Depth_Equal,
|
||||
Depth_LessEqual
|
||||
};
|
||||
|
||||
class GLInstance
|
||||
{
|
||||
enum
|
||||
|
@ -128,6 +136,10 @@ public:
|
|||
{
|
||||
SetColor(r * (1 / 255.f), g * (1 / 255.f), b * (1 / 255.f), a * (1 / 255.f));
|
||||
}
|
||||
|
||||
void SetDepthFunc(int func);
|
||||
void SetFogLinear(float* color, float start, float end);
|
||||
void SetFogExp2(float* color, float coefficient);
|
||||
};
|
||||
|
||||
extern GLInstance GLInterface;
|
||||
|
|
Loading…
Reference in a new issue