mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00: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);
|
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);
|
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);
|
if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) glFrontFace(GL_CW); else glFrontFace(GL_CCW);
|
||||||
|
|
|
@ -942,22 +942,19 @@ void calc_and_apply_fog(int32_t shade, int32_t vis, int32_t pal)
|
||||||
fogresult2 = -GL_FOG_MAX; // hide fog behind the camera
|
fogresult2 = -GL_FOG_MAX; // hide fog behind the camera
|
||||||
}
|
}
|
||||||
|
|
||||||
glFogf(GL_FOG_START, fogresult);
|
GLInterface.SetFogLinear((float*)&fogcol, fogresult, fogresult2);
|
||||||
glFogf(GL_FOG_END, fogresult2);
|
|
||||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fogcalc(shade, vis, pal);
|
fogcalc(shade, vis, pal);
|
||||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
|
||||||
|
|
||||||
if (r_usenewshading < 2)
|
if (r_usenewshading < 2)
|
||||||
glFogf(GL_FOG_DENSITY, fogresult);
|
{
|
||||||
|
GLInterface.SetFogExp2((float*)& fogcol, fogresult);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glFogf(GL_FOG_START, fogresult);
|
GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2);
|
||||||
glFogf(GL_FOG_END, fogresult2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,24 +984,20 @@ 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
|
fogresult2 = -GL_FOG_MAX; // hide fog behind the camera
|
||||||
}
|
}
|
||||||
|
|
||||||
glFogf(GL_FOG_START, fogresult);
|
GLInterface.SetFogLinear((float*)& fogcol, fogresult, fogresult2);
|
||||||
glFogf(GL_FOG_END, fogresult2);
|
|
||||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: for r_usenewshading >= 2, the fog beginning/ending distance results are
|
// NOTE: for r_usenewshading >= 2, the fog beginning/ending distance results are
|
||||||
// unused.
|
// unused.
|
||||||
fogcalc(shade, vis, pal);
|
fogcalc(shade, vis, pal);
|
||||||
glFogfv(GL_FOG_COLOR, (GLfloat *)&fogcol);
|
|
||||||
|
|
||||||
if (r_usenewshading < 2)
|
if (r_usenewshading < 2)
|
||||||
glFogf(GL_FOG_DENSITY, fogresult*factor);
|
{
|
||||||
|
GLInterface.SetFogExp2((float*)& fogcol, fogresult*factor);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glFogf(GL_FOG_START, (GLfloat) FULLVIS_BEGIN);
|
GLInterface.SetFogLinear((float*)& fogcol, FULLVIS_BEGIN, FULLVIS_END);
|
||||||
glFogf(GL_FOG_END, (GLfloat) FULLVIS_END);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
////////////////////
|
////////////////////
|
||||||
|
@ -2397,11 +2390,11 @@ do
|
||||||
|
|
||||||
polymost_setFogEnabled(false);
|
polymost_setFogEnabled(false);
|
||||||
|
|
||||||
glDepthFunc(GL_EQUAL);
|
GLInterface.SetDepthFunc(Depth_Equal);
|
||||||
|
|
||||||
polymost_drawpoly(dpxy, n, method_);
|
polymost_drawpoly(dpxy, n, method_);
|
||||||
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||||
|
|
||||||
if (!nofog)
|
if (!nofog)
|
||||||
polymost_setFogEnabled(true);
|
polymost_setFogEnabled(true);
|
||||||
|
@ -5266,8 +5259,7 @@ void polymost_drawrooms()
|
||||||
GLInterface.EnableBlend(false);
|
GLInterface.EnableBlend(false);
|
||||||
GLInterface.EnableAlphaTest(false);
|
GLInterface.EnableAlphaTest(false);
|
||||||
GLInterface.EnableDepthTest(true);
|
GLInterface.EnableDepthTest(true);
|
||||||
glDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
GLInterface.SetDepthFunc(Depth_Always);
|
||||||
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
|
|
||||||
|
|
||||||
polymost_setBrightness(r_brightnesshack);
|
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];
|
float sx[6], sy[6];
|
||||||
|
|
||||||
|
@ -5506,8 +5503,7 @@ void polymost_drawrooms()
|
||||||
bunchlast[closest] = bunchlast[numbunches];
|
bunchlast[closest] = bunchlast[numbunches];
|
||||||
}
|
}
|
||||||
|
|
||||||
glDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||||
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
|
|
||||||
polymost_identityrotmat();
|
polymost_identityrotmat();
|
||||||
|
|
||||||
videoEndDrawing();
|
videoEndDrawing();
|
||||||
|
@ -7474,8 +7470,6 @@ static int osdcmd_cvar_set_polymost(osdcmdptr_t parm)
|
||||||
gltexapplyprops();
|
gltexapplyprops();
|
||||||
else if (!Bstrcasecmp(parm->name, "r_texfilter"))
|
else if (!Bstrcasecmp(parm->name, "r_texfilter"))
|
||||||
gltexturemode(parm);
|
gltexturemode(parm);
|
||||||
else if (!Bstrcasecmp(parm->name, "r_usenewshading"))
|
|
||||||
glFogi(GL_FOG_MODE, (r_usenewshading < 2) ? GL_EXP2 : GL_LINEAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
|
|
||||||
if (shadowHack)
|
if (shadowHack)
|
||||||
{
|
{
|
||||||
glDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
GLInterface.SetDepthFunc(Depth_LessEqual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1193,8 +1193,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
||||||
|
|
||||||
if (shadowHack)
|
if (shadowHack)
|
||||||
{
|
{
|
||||||
glDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
GLInterface.SetDepthFunc(Depth_Less);
|
||||||
// glDepthRange(0.0, 0.99999);
|
|
||||||
}
|
}
|
||||||
VSMatrix identity(0);
|
VSMatrix identity(0);
|
||||||
GLInterface.SetMatrix(Matrix_ModelView, &identity);
|
GLInterface.SetMatrix(Matrix_ModelView, &identity);
|
||||||
|
|
|
@ -22,7 +22,6 @@ void GLInstance::InitGLState(int fogmode, int multisample)
|
||||||
glDisable(GL_DITHER);
|
glDisable(GL_DITHER);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glHint(GL_FOG_HINT, GL_NICEST);
|
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);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
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);
|
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
|
Cull_Back
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EDepthFunc
|
||||||
|
{
|
||||||
|
Depth_Always,
|
||||||
|
Depth_Less,
|
||||||
|
Depth_Equal,
|
||||||
|
Depth_LessEqual
|
||||||
|
};
|
||||||
|
|
||||||
class GLInstance
|
class GLInstance
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
|
@ -128,6 +136,10 @@ public:
|
||||||
{
|
{
|
||||||
SetColor(r * (1 / 255.f), g * (1 / 255.f), b * (1 / 255.f), a * (1 / 255.f));
|
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;
|
extern GLInstance GLInterface;
|
||||||
|
|
Loading…
Reference in a new issue