mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
- converted the simple state settings into renderstate flags.
This commit is contained in:
parent
6156e7382a
commit
3608a646e6
2 changed files with 131 additions and 84 deletions
|
@ -307,24 +307,6 @@ void GLInstance::UnbindAllTextures()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLInstance::EnableBlend(bool on)
|
|
||||||
{
|
|
||||||
if (on) glEnable (GL_BLEND);
|
|
||||||
else glDisable (GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::EnableDepthTest(bool on)
|
|
||||||
{
|
|
||||||
if (on) glEnable (GL_DEPTH_TEST);
|
|
||||||
else glDisable (GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::EnableMultisampling(bool on)
|
|
||||||
{
|
|
||||||
if (on) glEnable(GL_MULTISAMPLE);
|
|
||||||
else glDisable(GL_MULTISAMPLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
void GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
||||||
{
|
{
|
||||||
matrices[num] = *mat;
|
matrices[num] = *mat;
|
||||||
|
@ -355,46 +337,6 @@ void GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLInstance::EnableStencilWrite(int value)
|
|
||||||
{
|
|
||||||
glEnable(GL_STENCIL_TEST);
|
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
|
||||||
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
|
||||||
glStencilFunc(GL_ALWAYS, value, 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::EnableStencilTest(int value)
|
|
||||||
{
|
|
||||||
glEnable(GL_STENCIL_TEST);
|
|
||||||
glStencilFunc(GL_EQUAL, value, 0xFF);
|
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::DisableStencil()
|
|
||||||
{
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::SetCull(int type, int winding)
|
|
||||||
{
|
|
||||||
if (type == Cull_None)
|
|
||||||
{
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
}
|
|
||||||
else if (type == Cull_Front)
|
|
||||||
{
|
|
||||||
glFrontFace(winding == Winding_CW ? GL_CW : GL_CCW);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
glCullFace(GL_FRONT);
|
|
||||||
}
|
|
||||||
else if (type == Cull_Back)
|
|
||||||
{
|
|
||||||
glFrontFace(winding == Winding_CW ? GL_CW : GL_CCW);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
glCullFace(GL_BACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::SetScissor(int x1, int y1, int x2, int y2)
|
void GLInstance::SetScissor(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
glScissor(x1, y1, x2, y2);
|
glScissor(x1, y1, x2, y2);
|
||||||
|
@ -419,16 +361,6 @@ void GLInstance::SetDepthFunc(int func)
|
||||||
glDepthFunc(f[func]);
|
glDepthFunc(f[func]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLInstance::SetColorMask(bool on)
|
|
||||||
{
|
|
||||||
glColorMask(on, on, on, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::SetDepthMask(bool on)
|
|
||||||
{
|
|
||||||
glDepthMask(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA };
|
static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA };
|
||||||
|
|
||||||
void GLInstance::SetBlendFunc(int src, int dst)
|
void GLInstance::SetBlendFunc(int src, int dst)
|
||||||
|
@ -459,11 +391,6 @@ void GLInstance::SetViewport(int x, int y, int w, int h)
|
||||||
glViewport(x, y, w, h);
|
glViewport(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLInstance::SetWireframe(bool on)
|
|
||||||
{
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK,on? GL_LINE : GL_FILL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
|
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
@ -535,6 +462,73 @@ void GLInstance::ClearScreen(PalEntry color)
|
||||||
|
|
||||||
void PolymostRenderState::Apply(PolymostShader* shader, int &oldstate)
|
void PolymostRenderState::Apply(PolymostShader* shader, int &oldstate)
|
||||||
{
|
{
|
||||||
|
if (StateFlags != oldstate)
|
||||||
|
{
|
||||||
|
if ((StateFlags ^ oldstate) & STF_DEPTHTEST)
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_DEPTHTEST) glEnable(GL_DEPTH_TEST);
|
||||||
|
else glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & STF_BLEND)
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_BLEND) glEnable(GL_BLEND);
|
||||||
|
else glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & STF_MULTISAMPLE)
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_MULTISAMPLE) glEnable(GL_MULTISAMPLE);
|
||||||
|
else glDisable(GL_MULTISAMPLE);
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & (STF_STENCILTEST|STF_STENCILWRITE))
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_STENCILWRITE)
|
||||||
|
{
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
||||||
|
glStencilFunc(GL_ALWAYS, 1/*value*/, 0xFF);
|
||||||
|
}
|
||||||
|
else if (StateFlags & STF_STENCILTEST)
|
||||||
|
{
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
glStencilFunc(GL_EQUAL, 1/*value*/, 0xFF);
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & (STF_CULLCW | STF_CULLCCW))
|
||||||
|
{
|
||||||
|
if (StateFlags & (STF_CULLCW | STF_CULLCCW))
|
||||||
|
{
|
||||||
|
glFrontFace(StateFlags & STF_CULLCW ? GL_CW : GL_CCW);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK); // Cull_Front is not being used.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & STF_COLORMASK)
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_COLORMASK) glColorMask(1, 1, 1, 1);
|
||||||
|
else glColorMask(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & STF_DEPTHMASK)
|
||||||
|
{
|
||||||
|
if (StateFlags & STF_DEPTHMASK) glDepthMask(1);
|
||||||
|
else glDepthMask(0);
|
||||||
|
}
|
||||||
|
if ((StateFlags ^ oldstate) & STF_WIREFRAME)
|
||||||
|
{
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, (StateFlags & STF_WIREFRAME) ? GL_LINE : GL_FILL);
|
||||||
|
}
|
||||||
|
oldstate = StateFlags;
|
||||||
|
}
|
||||||
// Disable brightmaps if non-black fog is used.
|
// Disable brightmaps if non-black fog is used.
|
||||||
if (!(Flags & RF_FogDisabled) && !FogColor.isBlack()) Flags &= ~RF_Brightmapping;
|
if (!(Flags & RF_FogDisabled) && !FogColor.isBlack()) Flags &= ~RF_Brightmapping;
|
||||||
shader->Flags.Set(Flags);
|
shader->Flags.Set(Flags);
|
||||||
|
|
|
@ -239,9 +239,6 @@ public:
|
||||||
void BindTexture(int texunit, FHardwareTexture *texid, int sampler = NoSampler);
|
void BindTexture(int texunit, FHardwareTexture *texid, int sampler = NoSampler);
|
||||||
void UnbindTexture(int texunit);
|
void UnbindTexture(int texunit);
|
||||||
void UnbindAllTextures();
|
void UnbindAllTextures();
|
||||||
void EnableBlend(bool on);
|
|
||||||
void EnableDepthTest(bool on);
|
|
||||||
void EnableMultisampling(bool on);
|
|
||||||
void EnableNonTransparent255(bool on)
|
void EnableNonTransparent255(bool on)
|
||||||
{
|
{
|
||||||
g_nontransparent255 = on;
|
g_nontransparent255 = on;
|
||||||
|
@ -275,11 +272,6 @@ public:
|
||||||
{
|
{
|
||||||
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
|
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
|
||||||
}
|
}
|
||||||
void SetCull(int type, int winding = Winding_CCW);
|
|
||||||
|
|
||||||
void EnableStencilWrite(int value);
|
|
||||||
void EnableStencilTest(int value);
|
|
||||||
void DisableStencil();
|
|
||||||
void SetColor(float r, float g, float b, float a = 1.f);
|
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)
|
void SetColorub(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||||
{
|
{
|
||||||
|
@ -289,14 +281,11 @@ public:
|
||||||
void SetScissor(int x1, int y1, int x2, int y2);
|
void SetScissor(int x1, int y1, int x2, int y2);
|
||||||
void DisableScissor();
|
void DisableScissor();
|
||||||
void SetDepthFunc(int func);
|
void SetDepthFunc(int func);
|
||||||
void SetColorMask(bool on);
|
|
||||||
void SetDepthMask(bool on);
|
|
||||||
void SetBlendFunc(int src, int dst);
|
void SetBlendFunc(int src, int dst);
|
||||||
void SetBlendOp(int op);
|
void SetBlendOp(int op);
|
||||||
void ClearScreen(float r, float g, float b, bool depth);
|
void ClearScreen(float r, float g, float b, bool depth);
|
||||||
void ClearDepth();
|
void ClearDepth();
|
||||||
void SetViewport(int x, int y, int w, int h);
|
void SetViewport(int x, int y, int w, int h);
|
||||||
void SetWireframe(bool on);
|
|
||||||
void SetPolymostShader();
|
void SetPolymostShader();
|
||||||
void SetSurfaceShader();
|
void SetSurfaceShader();
|
||||||
void SetVPXShader();
|
void SetVPXShader();
|
||||||
|
@ -342,6 +331,70 @@ public:
|
||||||
renderState.VisFactor = visibility* fviewingrange* (1.f / (64.f * 65536.f));
|
renderState.VisFactor = visibility* fviewingrange* (1.f / (64.f * 65536.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnableBlend(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_BLEND;
|
||||||
|
else renderState.StateFlags &= ~STF_BLEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableDepthTest(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_DEPTHTEST;
|
||||||
|
else renderState.StateFlags &= ~STF_DEPTHTEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableMultisampling(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_MULTISAMPLE;
|
||||||
|
else renderState.StateFlags &= ~STF_MULTISAMPLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableStencilWrite(int value)
|
||||||
|
{
|
||||||
|
renderState.StateFlags |= STF_STENCILWRITE;
|
||||||
|
renderState.StateFlags &= ~STF_STENCILTEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableStencilTest(int value)
|
||||||
|
{
|
||||||
|
renderState.StateFlags &= ~STF_STENCILWRITE;
|
||||||
|
renderState.StateFlags |= STF_STENCILTEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisableStencil()
|
||||||
|
{
|
||||||
|
renderState.StateFlags &= ~(STF_STENCILWRITE | STF_STENCILTEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCull(int type, int winding = Winding_CW)
|
||||||
|
{
|
||||||
|
renderState.StateFlags &= ~(STF_CULLCCW | STF_CULLCW);
|
||||||
|
if (type != Cull_None)
|
||||||
|
{
|
||||||
|
if (winding == Winding_CW) renderState.StateFlags |= STF_CULLCW;
|
||||||
|
else renderState.StateFlags |= STF_CULLCCW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetColorMask(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_COLORMASK;
|
||||||
|
else renderState.StateFlags &= ~STF_COLORMASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetDepthMask(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_DEPTHMASK;
|
||||||
|
else renderState.StateFlags &= ~STF_DEPTHMASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWireframe(bool on)
|
||||||
|
{
|
||||||
|
if (on) renderState.StateFlags |= STF_WIREFRAME;
|
||||||
|
else renderState.StateFlags &= ~STF_WIREFRAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UseColorOnly(bool yes)
|
void UseColorOnly(bool yes)
|
||||||
{
|
{
|
||||||
if (yes) renderState.Flags |= RF_ColorOnly;
|
if (yes) renderState.Flags |= RF_ColorOnly;
|
||||||
|
|
Loading…
Reference in a new issue