mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
- preparation for moving GL state into the renderstate struct.
This commit is contained in:
parent
85593e3e93
commit
6156e7382a
4 changed files with 26 additions and 18 deletions
|
@ -63,7 +63,7 @@ unsigned int FHardwareTexture::CreateTexture(int w, int h, int type, bool mipmap
|
|||
{
|
||||
static int gltypes[] = { GL_R8, GL_RGBA8, GL_RGB5_A1, GL_RGBA2 };
|
||||
static uint8_t bytes[] = { 1, 4, 2, 1 };
|
||||
glTexID = GLInterface.GetTextureID();
|
||||
glGenTextures(1, &glTexID);
|
||||
glActiveTexture(GL_TEXTURE15);
|
||||
glBindTexture(GL_TEXTURE_2D, glTexID);
|
||||
int size = std::max(w, h);
|
||||
|
|
|
@ -22,6 +22,19 @@ enum PRSFlags
|
|||
RF_HICTINT_BLEND_Overlay = 0x100000,
|
||||
RF_HICTINT_BLEND_Hardlight = 0x200000,
|
||||
RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight,
|
||||
|
||||
STF_BLEND = 1,
|
||||
STF_COLORMASK = 2,
|
||||
STF_DEPTHMASK = 4,
|
||||
STF_DEPTHTEST = 8,
|
||||
STF_MULTISAMPLE = 16,
|
||||
STF_STENCILWRITE = 32,
|
||||
STF_STENCILTEST = 64,
|
||||
STF_CULLCW = 128,
|
||||
STF_CULLCCW = 256,
|
||||
STF_WIREFRAME = 512,
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct PolymostRenderState
|
||||
|
@ -37,11 +50,13 @@ struct PolymostRenderState
|
|||
float AlphaThreshold = 0.5f;
|
||||
bool AlphaTest = true;
|
||||
|
||||
int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
|
||||
|
||||
PalEntry FogColor;
|
||||
|
||||
IVertexBuffer* VertexBuffer = nullptr;
|
||||
int VB_Offset[2] = {};
|
||||
IIndexBuffer* IndexBuffer = nullptr;
|
||||
|
||||
void Apply(PolymostShader *shader);
|
||||
void Apply(PolymostShader *shader, int &oldstate);
|
||||
};
|
||||
|
|
|
@ -193,6 +193,12 @@ void GLInstance::Deinit()
|
|||
palmanager.DeleteAllTextures();
|
||||
lastPalswapIndex = -1;
|
||||
}
|
||||
|
||||
FHardwareTexture* GLInstance::NewTexture()
|
||||
{
|
||||
return new FHardwareTexture;
|
||||
}
|
||||
|
||||
|
||||
std::pair<size_t, BaseVertex *> GLInstance::AllocVertices(size_t num)
|
||||
{
|
||||
|
@ -227,7 +233,7 @@ 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.
|
||||
renderState.Apply(polymostShader);
|
||||
renderState.Apply(polymostShader, lastState);
|
||||
if (renderState.VertexBuffer != LastVertexBuffer || LastVB_Offset[0] != renderState.VB_Offset[0] || LastVB_Offset[1] != renderState.VB_Offset[1])
|
||||
{
|
||||
if (renderState.VertexBuffer)
|
||||
|
@ -271,19 +277,6 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
|
|||
if (MatrixChange) RestoreTextureProps();
|
||||
}
|
||||
|
||||
int GLInstance::GetTextureID()
|
||||
{
|
||||
uint32_t id = 0;
|
||||
glGenTextures(1, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
FHardwareTexture* GLInstance::NewTexture()
|
||||
{
|
||||
return new FHardwareTexture;
|
||||
}
|
||||
|
||||
|
||||
void GLInstance::BindTexture(int texunit, FHardwareTexture *tex, int sampler)
|
||||
{
|
||||
if (!tex) return;
|
||||
|
@ -540,7 +533,7 @@ void GLInstance::ClearScreen(PalEntry color)
|
|||
}
|
||||
|
||||
|
||||
void PolymostRenderState::Apply(PolymostShader* shader)
|
||||
void PolymostRenderState::Apply(PolymostShader* shader, int &oldstate)
|
||||
{
|
||||
// Disable brightmaps if non-black fog is used.
|
||||
if (!(Flags & RF_FogDisabled) && !FogColor.isBlack()) Flags &= ~RF_Brightmapping;
|
||||
|
|
|
@ -196,6 +196,7 @@ class GLInstance
|
|||
int MatrixChange = 0;
|
||||
bool istrans = false;
|
||||
bool g_nontransparent255 = false; // Ugh... This is for movie playback and needs to be maintained as global state.
|
||||
int lastState = STF_COLORMASK | STF_DEPTHMASK;
|
||||
|
||||
IVertexBuffer* LastVertexBuffer = nullptr;
|
||||
int LastVB_Offset[2] = {};
|
||||
|
@ -234,7 +235,6 @@ public:
|
|||
std::pair<size_t, BaseVertex *> AllocVertices(size_t num);
|
||||
void Draw(EDrawType type, size_t start, size_t count);
|
||||
|
||||
int GetTextureID();
|
||||
FHardwareTexture* NewTexture();
|
||||
void BindTexture(int texunit, FHardwareTexture *texid, int sampler = NoSampler);
|
||||
void UnbindTexture(int texunit);
|
||||
|
|
Loading…
Reference in a new issue