mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- color and depth func moved to render state.
This commit is contained in:
parent
27ed6cdae5
commit
ce75832945
4 changed files with 29 additions and 21 deletions
|
@ -1805,7 +1805,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
|||
|
||||
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255));
|
||||
GLInterface.SetClamp(prevClamp);
|
||||
GLInterface.SetPolymostShader();
|
||||
|
||||
globalnoeffect=0;
|
||||
return 1;
|
||||
|
|
|
@ -55,9 +55,11 @@ struct PolymostRenderState
|
|||
float Brightness = 1.f;
|
||||
float AlphaThreshold = 0.5f;
|
||||
bool AlphaTest = true;
|
||||
float Color[4] = { 1,1,1,1 };
|
||||
|
||||
int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
|
||||
FRenderStyle Style{};
|
||||
int DepthFunc = 1;
|
||||
PalEntry ClearColor = 0;
|
||||
short vp_x, vp_y, vp_w, vp_h;
|
||||
short sc_x, sc_y, sc_w, sc_h;
|
||||
|
|
|
@ -53,6 +53,7 @@ float shadediv[MAXPALOOKUPS];
|
|||
|
||||
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 renderops[] = { GL_FUNC_ADD, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT };
|
||||
int depthf[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL };
|
||||
|
||||
|
||||
FileReader GetResource(const char* fn)
|
||||
|
@ -235,7 +236,8 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
|
|||
|
||||
if (activeShader == polymostShader)
|
||||
{
|
||||
if (istrans) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
|
||||
glVertexAttrib4fv(2, renderState.Color);
|
||||
if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
|
||||
renderState.Apply(polymostShader, lastState);
|
||||
if (renderState.VertexBuffer != LastVertexBuffer || LastVB_Offset[0] != renderState.VB_Offset[0] || LastVB_Offset[1] != renderState.VB_Offset[1])
|
||||
{
|
||||
|
@ -340,18 +342,6 @@ void GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
|||
}
|
||||
}
|
||||
|
||||
void GLInstance::SetColor(float r, float g, float b, float a)
|
||||
{
|
||||
glVertexAttrib4f(2, r, g, b, a);
|
||||
istrans = (a != 1);
|
||||
}
|
||||
|
||||
void GLInstance::SetDepthFunc(int func)
|
||||
{
|
||||
int f[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL };
|
||||
glDepthFunc(f[func]);
|
||||
}
|
||||
|
||||
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
|
||||
{
|
||||
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
|
@ -503,6 +493,11 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
|
|||
oldState.Style = Style;
|
||||
// Flags are not being checked yet, the current shader has no implementation for them.
|
||||
}
|
||||
if (DepthFunc != oldState.DepthFunc)
|
||||
{
|
||||
glDepthFunc(depthf[DepthFunc]);
|
||||
oldState.DepthFunc = DepthFunc;
|
||||
}
|
||||
// Disable brightmaps if non-black fog is used.
|
||||
if (!(Flags & RF_FogDisabled) && !FogColor.isBlack()) Flags &= ~RF_Brightmapping;
|
||||
shader->Flags.Set(Flags);
|
||||
|
|
|
@ -181,6 +181,7 @@ struct GLState
|
|||
{
|
||||
int Flags = STF_COLORMASK | STF_DEPTHMASK;
|
||||
FRenderStyle Style{};
|
||||
int DepthFunc = -1;
|
||||
};
|
||||
|
||||
class GLInstance
|
||||
|
@ -201,7 +202,6 @@ class GLInstance
|
|||
FTexture* currentTexture = nullptr;
|
||||
int TextureType;
|
||||
int MatrixChange = 0;
|
||||
bool istrans = false;
|
||||
bool g_nontransparent255 = false; // Ugh... This is for movie playback and needs to be maintained as global state.
|
||||
|
||||
// Cached GL state.
|
||||
|
@ -281,13 +281,7 @@ public:
|
|||
{
|
||||
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
void SetDepthFunc(int func);
|
||||
void SetPolymostShader();
|
||||
void SetSurfaceShader();
|
||||
void SetVPXShader();
|
||||
|
@ -426,6 +420,11 @@ public:
|
|||
renderState.StateFlags |= STF_SCISSORSET;
|
||||
}
|
||||
|
||||
void SetDepthFunc(int func)
|
||||
{
|
||||
renderState.DepthFunc = func;
|
||||
}
|
||||
|
||||
|
||||
void ClearScreen(PalEntry pe)
|
||||
{
|
||||
|
@ -444,6 +443,19 @@ public:
|
|||
renderState.Style = style;
|
||||
}
|
||||
|
||||
void SetColor(float r, float g, float b, float a = 1.f)
|
||||
{
|
||||
renderState.Color[0] = r;
|
||||
renderState.Color[1] = g;
|
||||
renderState.Color[2] = b;
|
||||
renderState.Color[3] = a;
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
void UseColorOnly(bool yes)
|
||||
{
|
||||
if (yes) renderState.Flags |= RF_ColorOnly;
|
||||
|
|
Loading…
Reference in a new issue