- converted the clear screen commands.

This commit is contained in:
Christoph Oelckers 2020-01-02 23:56:35 +01:00
parent b549228d4d
commit 3380420de9
6 changed files with 38 additions and 42 deletions

View file

@ -375,7 +375,7 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
texuploaded = 0;
////////////////////
GLInterface.ClearScreen(0, 0, 0, true);
GLInterface.ClearScreen(0, true);
}
void animvpx_restore_glstate(void)

View file

@ -993,7 +993,7 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t,int32_
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
{
GLInterface.ClearScreen(0, 0, 0, true);
GLInterface.ClearScreen(0, true);
yax_polymostclearzbuffer = 0;
}
#endif
@ -10533,10 +10533,7 @@ void videoClearViewableArea(int32_t dacol)
{
palette_t const p = paletteGetColor(dacol);
GLInterface.ClearScreen((float)p.r * (1.f/255.f),
(float)p.g * (1.f/255.f),
(float)p.b * (1.f/255.f),
false);
GLInterface.ClearScreen(PalEntry(p.r, p.g, p.b), false);
return;
}
#endif
@ -10571,8 +10568,7 @@ void videoClearScreen(int32_t dacol)
glox1 = -1;
palette_t const p = paletteGetColor(dacol);
PalEntry clearcol = PalEntry(255, p.r, p.g, p.b);
GLInterface.ClearScreen(clearcol);
GLInterface.ClearScreen(PalEntry(255, p.r, p.g, p.b));
return;
}
#endif

View file

@ -310,7 +310,7 @@ static void resizeglcheck(void)
}
if (hw_polygonmode) //FUK
{
GLInterface.ClearScreen(1, 1, 1, true);
GLInterface.ClearScreen(0xffffff, true);
}
if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale) || (glohoriz2 != ghoriz2) || (glohorizcorrect != ghorizcorrect) || (glotang != gtang))

View file

@ -33,6 +33,8 @@ enum PRSFlags
STF_CULLCW = 128,
STF_CULLCCW = 256,
STF_WIREFRAME = 512,
STF_CLEARCOLOR = 1024,
STF_CLEARDEPTH = 2048,
};
@ -51,6 +53,7 @@ struct PolymostRenderState
bool AlphaTest = true;
int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
PalEntry ClearColor = 0;
PalEntry FogColor;

View file

@ -49,7 +49,6 @@
#include "v_video.h"
#include "gl_renderer.h"
extern int xdim, ydim;
float shadediv[MAXPALOOKUPS];
FileReader GetResource(const char* fn)
@ -375,17 +374,6 @@ void GLInstance::SetBlendOp(int op)
glBlendEquation(renderops[op]);
}
void GLInstance::ClearScreen(float r, float g, float b, bool depth)
{
glClearColor(r, g, b, 1.f);
glClear(depth ? GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT : GL_COLOR_BUFFER_BIT);
}
void GLInstance::ClearDepth()
{
glClear(GL_DEPTH_BUFFER_BIT);
}
void GLInstance::SetViewport(int x, int y, int w, int h)
{
glViewport(x, y, w, h);
@ -442,24 +430,6 @@ void GLInstance::DrawImGui(ImDrawData* data)
#endif
}
void GLInstance::ClearScreen(PalEntry color)
{
twod->Clear(); // Since we clear the entire screen, all previous draw operations become redundant, so delete them.
#if 1
SetViewport(0, 0, xdim, ydim);
ClearScreen((float)color.r * (1.f / 255.f),
(float)color.g * (1.f / 255.f),
(float)color.b * (1.f / 255.f),
false);
#else
// This must be synchronized with the rest of the 2D operations.
twod->AddColorOnlyQuad(0, 0, xdim, ydim, );
#endif
}
void PolymostRenderState::Apply(PolymostShader* shader, int &oldstate)
{
if (StateFlags != oldstate)
@ -527,6 +497,17 @@ void PolymostRenderState::Apply(PolymostShader* shader, int &oldstate)
{
glPolygonMode(GL_FRONT_AND_BACK, (StateFlags & STF_WIREFRAME) ? GL_LINE : GL_FILL);
}
if (StateFlags & (STF_CLEARCOLOR| STF_CLEARDEPTH))
{
glClearColor(ClearColor.r / 255.f, ClearColor.g / 255.f, ClearColor.b / 255.f, 1.f);
int bit = 0;
if (StateFlags & STF_CLEARCOLOR) bit |= GL_COLOR_BUFFER_BIT;
if (StateFlags & STF_CLEARDEPTH) bit |= GL_DEPTH_BUFFER_BIT;
glClear(bit);
StateFlags &= ~(STF_CLEARCOLOR|STF_CLEARDEPTH);
}
oldstate = StateFlags;
}
// Disable brightmaps if non-black fog is used.

View file

@ -18,6 +18,7 @@ class FTexture;
class GLInstance;
class F2DDrawer;
struct palette_t;
extern int xdim, ydim;
struct PaletteData
{
@ -283,8 +284,6 @@ public:
void SetDepthFunc(int func);
void SetBlendFunc(int src, int dst);
void SetBlendOp(int op);
void ClearScreen(float r, float g, float b, bool depth);
void ClearDepth();
void SetViewport(int x, int y, int w, int h);
void SetPolymostShader();
void SetSurfaceShader();
@ -292,7 +291,6 @@ public:
void SetPalette(int palette);
bool ApplyTextureProps(FTexture *tex, int pal);
void RestoreTextureProps();
void ClearScreen(PalEntry color);
void ReadPixels(int w, int h, uint8_t* buffer);
@ -394,6 +392,24 @@ public:
else renderState.StateFlags &= ~STF_WIREFRAME;
}
void ClearScreen(PalEntry pe, bool depth)
{
renderState.ClearColor = pe;
renderState.StateFlags |= STF_CLEARCOLOR;
if (depth) renderState.StateFlags |= STF_CLEARDEPTH;
}
void ClearScreen(PalEntry pe)
{
//twod->Clear();
SetViewport(0, 0, xdim, ydim);
ClearScreen(pe, false);
}
void ClearDepth()
{
renderState.StateFlags |= STF_CLEARDEPTH;
}
void UseColorOnly(bool yes)
{