mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 19:20:38 +00:00
- make sure that the first matrix is always the identity matrix. It was just random luck that it was always put there before.
- let the matrix setters return the previous value for easy restoring without creating yet another matrix.
This commit is contained in:
parent
57a455d6cb
commit
b209b1f960
3 changed files with 19 additions and 16 deletions
|
@ -73,7 +73,8 @@ GLInstance GLInterface;
|
||||||
GLInstance::GLInstance()
|
GLInstance::GLInstance()
|
||||||
:palmanager(this)
|
:palmanager(this)
|
||||||
{
|
{
|
||||||
|
VSMatrix mat(0);
|
||||||
|
matrixArray.Push(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_Init_Backend();
|
void ImGui_Init_Backend();
|
||||||
|
@ -239,9 +240,6 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
|
||||||
|
|
||||||
void GLInstance::DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState &renderState)
|
void GLInstance::DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState &renderState)
|
||||||
{
|
{
|
||||||
// Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation.
|
|
||||||
bool applied = false;
|
|
||||||
|
|
||||||
if (activeShader == polymostShader)
|
if (activeShader == polymostShader)
|
||||||
{
|
{
|
||||||
glVertexAttrib4fv(2, renderState.Color);
|
glVertexAttrib4fv(2, renderState.Color);
|
||||||
|
@ -262,24 +260,23 @@ void GLInstance::DoDraw()
|
||||||
{
|
{
|
||||||
for (auto& rs : rendercommands)
|
for (auto& rs : rendercommands)
|
||||||
{
|
{
|
||||||
// Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation.
|
|
||||||
bool applied = false;
|
|
||||||
|
|
||||||
glVertexAttrib4fv(2, rs.Color);
|
glVertexAttrib4fv(2, rs.Color);
|
||||||
if (rs.Color[3] != 1.f) rs.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
|
if (rs.Color[3] != 1.f) rs.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
|
||||||
rs.Apply(polymostShader, lastState);
|
rs.Apply(polymostShader, lastState);
|
||||||
glDrawArrays(primtypes[rs.primtype], rs.vindex, rs.vcount);
|
glDrawArrays(primtypes[rs.primtype], rs.vindex, rs.vcount);
|
||||||
}
|
}
|
||||||
rendercommands.Clear();
|
rendercommands.Clear();
|
||||||
matrixArray.Clear();
|
matrixArray.Resize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
int GLInstance::SetMatrix(int num, const VSMatrix *mat)
|
||||||
{
|
{
|
||||||
|
int r = renderState.matrixIndex[num];
|
||||||
if (num == Matrix_Projection) mProjectionM5 = mat->get()[5];
|
if (num == Matrix_Projection) mProjectionM5 = mat->get()[5];
|
||||||
renderState.matrixIndex[num] = matrixArray.Size();
|
renderState.matrixIndex[num] = matrixArray.Size();
|
||||||
matrixArray.Push(*mat);
|
matrixArray.Push(*mat);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
|
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
|
||||||
|
|
|
@ -208,14 +208,20 @@ public:
|
||||||
void ClearBufferState();
|
void ClearBufferState();
|
||||||
|
|
||||||
float GetProjectionM5() { return mProjectionM5; }
|
float GetProjectionM5() { return mProjectionM5; }
|
||||||
void SetMatrix(int num, const VSMatrix *mat );
|
int SetMatrix(int num, const VSMatrix *mat );
|
||||||
void SetMatrix(int num, const float *mat)
|
int SetMatrix(int num, const float *mat)
|
||||||
{
|
{
|
||||||
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
|
return SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
|
||||||
}
|
}
|
||||||
void SetIdentityMatrix(int num)
|
int SetIdentityMatrix(int num)
|
||||||
{
|
{
|
||||||
|
auto r = renderState.matrixIndex[num];
|
||||||
renderState.matrixIndex[num] = 0;
|
renderState.matrixIndex[num] = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
void RestoreMatrix(int num, int index)
|
||||||
|
{
|
||||||
|
renderState.matrixIndex[num] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPolymostShader();
|
void SetPolymostShader();
|
||||||
|
|
|
@ -97,9 +97,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
||||||
void GLInstance::Draw2D(F2DDrawer *drawer)
|
void GLInstance::Draw2D(F2DDrawer *drawer)
|
||||||
{
|
{
|
||||||
VSMatrix mat(0);
|
VSMatrix mat(0);
|
||||||
SetMatrix(Matrix_View, mat.get());
|
SetIdentityMatrix(Matrix_View);
|
||||||
SetMatrix(Matrix_ModelView, mat.get());
|
SetIdentityMatrix(Matrix_ModelView);
|
||||||
SetMatrix(Matrix_Detail, mat.get());
|
SetIdentityMatrix(Matrix_Detail);
|
||||||
mat.ortho(0, xdim, ydim, 0, -1, 1);
|
mat.ortho(0, xdim, ydim, 0, -1, 1);
|
||||||
SetMatrix(Matrix_Projection, mat.get());
|
SetMatrix(Matrix_Projection, mat.get());
|
||||||
SetViewport(0, 0, xdim, ydim);
|
SetViewport(0, 0, xdim, ydim);
|
||||||
|
|
Loading…
Reference in a new issue