mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
glColor calls refactored.
This commit is contained in:
parent
96c0c3197c
commit
204abab724
9 changed files with 25 additions and 31 deletions
|
@ -61,7 +61,7 @@ static void drawlinegl(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t
|
|||
GLInterface.EnableBlend(true); // When using line antialiasing, this is needed
|
||||
|
||||
polymost_useColorOnly(true);
|
||||
glColor4ub(p.r, p.g, p.b, 255);
|
||||
GLInterface.SetColorub(p.r, p.g, p.b, 255);
|
||||
|
||||
auto data = GLInterface.AllocVertices(2);
|
||||
data.second[0].Set((float) x1 * (1.f/4096.f), (float) y1 * (1.f/4096.f));
|
||||
|
|
|
@ -419,7 +419,6 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
|
|||
GLInterface.SetMatrix(Matrix_Projection, &identity);
|
||||
GLInterface.SetMatrix(Matrix_Texture0, &identity);
|
||||
|
||||
// glPushAttrib(GL_ENABLE_BIT);
|
||||
GLInterface.EnableAlphaTest(false);
|
||||
GLInterface.EnableDepthTest(false);
|
||||
GLInterface.EnableBlend(false);
|
||||
|
|
|
@ -254,18 +254,16 @@ void COMMON_doclearbackground(int numcols, int height)
|
|||
# ifdef USE_OPENGL
|
||||
if (videoGetRenderMode() >= REND_POLYMOST && in3dmode())
|
||||
{
|
||||
// glPushAttrib(GL_FOG_BIT);
|
||||
polymost_setFogEnabled(false);
|
||||
polymost_useColorOnly(true);
|
||||
|
||||
polymostSet2dView();
|
||||
glColor4f(0.f, 0.f, 0.f, 0.67f);
|
||||
GLInterface.SetColor(0.f, 0.f, 0.f, 0.67f);
|
||||
GLInterface.EnableBlend(true);
|
||||
glRecti(0, 0, xdim, height);
|
||||
glColor4f(0.f, 0.f, 0.f, 1.f);
|
||||
GLInterface.SetColor(0.f, 0.f, 0.f, 1.f);
|
||||
glRecti(0, height-4, xdim, height);
|
||||
|
||||
// glPopAttrib();
|
||||
polymost_useColorOnly(false);
|
||||
polymost_setFogEnabled(true);
|
||||
|
||||
|
|
|
@ -1987,19 +1987,11 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
|
||||
if (tspr->extra&TSPR_EXTRA_MDHACK)
|
||||
{
|
||||
#ifdef __arm__ // GL ES has a glDepthRangef and the loss of precision is OK there
|
||||
float f = (float) (tspr->owner + 1) * (std::numeric_limits<float>::epsilon() * 8.0);
|
||||
if (f != 0.0) f *= 1.f/(float) (sepldist(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
#else
|
||||
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);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
||||
#endif
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
// glDepthRange(0.0 - f, 1.0 - f);
|
||||
}
|
||||
|
||||
// glPushAttrib(GL_POLYGON_BIT);
|
||||
if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) glFrontFace(GL_CW); else glFrontFace(GL_CCW);
|
||||
GLInterface.SetCull(Cull_Back);
|
||||
|
||||
|
@ -2037,9 +2029,9 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
if ((tspr->cstat&2) || sext->alpha > 0.f || pc[3] < 1.0f)
|
||||
GLInterface.EnableBlend(true); //else GLInterface.EnableBlend(false);
|
||||
}
|
||||
glColor4f(pc[0],pc[1],pc[2],pc[3]);
|
||||
GLInterface.SetColor(pc[0],pc[1],pc[2],pc[3]);
|
||||
//if (MFLAGS_NOCONV(m))
|
||||
// glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
// GLInterface.SetColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
//------------
|
||||
|
||||
// PLAG: Cleaner model rotation code
|
||||
|
|
|
@ -62,7 +62,7 @@ void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
|
|||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLInterface.EnableBlend(true);
|
||||
glColor4ub(r, g, b, f);
|
||||
GLInterface.SetColorub(r, g, b, f);
|
||||
|
||||
polymost_useColorOnly(true);
|
||||
|
||||
|
@ -99,7 +99,7 @@ void fullscreen_tint_gl_blood(void)
|
|||
GLInterface.EnableBlend(true);
|
||||
|
||||
polymost_useColorOnly(true);
|
||||
glColor4ub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255);
|
||||
GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255);
|
||||
auto data = GLInterface.AllocVertices(3);
|
||||
auto vt = data.second;
|
||||
vt[0].Set(-2.5f, 1.f);
|
||||
|
@ -107,7 +107,7 @@ void fullscreen_tint_gl_blood(void)
|
|||
vt[2].Set(.0f, -2.5f);
|
||||
GLInterface.Draw(DT_TRIANGLES, data.first, 3);
|
||||
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
||||
glColor4ub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255);
|
||||
GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255);
|
||||
data = GLInterface.AllocVertices(3);
|
||||
vt = data.second;
|
||||
vt[0].Set(-2.5f, 1.f);
|
||||
|
@ -115,7 +115,7 @@ void fullscreen_tint_gl_blood(void)
|
|||
vt[2].Set(.0f, -2.5f);
|
||||
GLInterface.Draw(DT_TRIANGLES, data.first, 3);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glColor4ub(0,0,0,0);
|
||||
GLInterface.SetColorub(0,0,0,0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
polymost_useColorOnly(false);
|
||||
|
||||
|
|
|
@ -2204,7 +2204,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
if (skyzbufferhack_pass)
|
||||
pc[3] = 0.01f;
|
||||
|
||||
glColor4f(pc[0], pc[1], pc[2], pc[3]);
|
||||
GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]);
|
||||
|
||||
//POGOTODO: remove this, replace it with a shader implementation
|
||||
//Hack for walls&masked walls which use textures that are not a power of 2
|
||||
|
@ -7195,7 +7195,7 @@ void polymost_fillpolygon(int32_t npoints)
|
|||
if (maskprops > DAMETH_MASK)
|
||||
{
|
||||
GLInterface.EnableBlend(true);
|
||||
glColor4f(f, f, f, float_trans(maskprops, 0));
|
||||
GLInterface.SetColor(f, f, f, float_trans(maskprops, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7296,7 +7296,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
|
|||
GLInterface.EnableAlphaTest(false);
|
||||
glDepthMask(GL_FALSE); // disable writing to the z-buffer
|
||||
|
||||
// glPushAttrib(GL_POLYGON_BIT|GL_ENABLE_BIT);
|
||||
// XXX: Don't fogify the OSD text in Mapster32 with r_usenewshading >= 2.
|
||||
polymost_setFogEnabled(false);
|
||||
// We want to have readable text in wireframe mode, too:
|
||||
|
@ -7307,7 +7306,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
|
|||
{
|
||||
int const c = Bstrlen(name);
|
||||
|
||||
glColor4ub(b.r,b.g,b.b,255);
|
||||
GLInterface.SetColorub(b.r,b.g,b.b,255);
|
||||
|
||||
auto data = GLInterface.AllocVertices(4);
|
||||
auto vt = data.second;
|
||||
|
@ -7321,7 +7320,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
|
|||
}
|
||||
|
||||
GLInterface.EnableBlend(true);
|
||||
glColor4ub(p.r,p.g,p.b,255);
|
||||
GLInterface.SetColorub(p.r,p.g,p.b,255);
|
||||
|
||||
vec2f_t const tc = { fontsize ? (4.f / 256.f) : (8.f / 256.f),
|
||||
fontsize ? (6.f / 128.f) : (8.f / 128.f) };
|
||||
|
@ -7352,7 +7351,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
|
|||
|
||||
bricolor(&p, col);
|
||||
|
||||
glColor4ub(p.r, p.g, p.b, 255);
|
||||
GLInterface.SetColorub(p.r, p.g, p.b, 255);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -7387,8 +7386,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
|
|||
|
||||
glDepthMask(GL_TRUE); // re-enable writing to the z-buffer
|
||||
|
||||
// glPopAttrib();
|
||||
|
||||
if (!nofog) polymost_setFogEnabled(true);
|
||||
|
||||
polymost_usePaletteIndexing(true);
|
||||
|
|
|
@ -1082,10 +1082,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
|
||||
// glDepthRange(0.0, 0.9999);
|
||||
}
|
||||
|
||||
// glPushAttrib(GL_POLYGON_BIT);
|
||||
|
||||
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0))
|
||||
glFrontFace(GL_CW);
|
||||
|
@ -1164,7 +1162,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
qstart += qdone * 4;
|
||||
qdone = 0;
|
||||
}
|
||||
glColor4f(pc[0]*f, pc[1]*f, pc[2]*f, pc[3]*f);
|
||||
GLInterface.SetColor(pc[0]*f, pc[1]*f, pc[2]*f, pc[3]*f);
|
||||
}
|
||||
|
||||
const vert_t *const vptr = &m->quad[i].v[0];
|
||||
|
|
|
@ -196,3 +196,8 @@ void GLInstance::SetCull(int type)
|
|||
glCullFace(GL_BACK);
|
||||
}
|
||||
}
|
||||
|
||||
void GLInstance::SetColor(float r, float g, float b, float a)
|
||||
{
|
||||
glColor4f(r, g, b, a);
|
||||
}
|
|
@ -123,6 +123,11 @@ public:
|
|||
void EnableStencilWrite(int value);
|
||||
void EnableStencilTest(int value);
|
||||
void DisableStencil();
|
||||
void SetColor(float r, float g, float b, float a = 1.f);
|
||||
void SetColorub(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||
{
|
||||
SetColor(r * (1 / 255.f), g * (1 / 255.f), b * (1 / 255.f), a * (1 / 255.f));
|
||||
}
|
||||
};
|
||||
|
||||
extern GLInstance GLInterface;
|
||||
|
|
Loading…
Reference in a new issue