mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- remove all uses of builtin matrices.
This commit is contained in:
parent
2214c0ac06
commit
ce3653f6e1
6 changed files with 59 additions and 10 deletions
|
@ -80,7 +80,7 @@ public:
|
||||||
#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway.
|
#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway.
|
||||||
void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count)
|
void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count)
|
||||||
{
|
{
|
||||||
drawcalls.Clock();
|
//drawcalls.Clock();
|
||||||
if (gl.flags & RFL_BUFFER_STORAGE)
|
if (gl.flags & RFL_BUFFER_STORAGE)
|
||||||
{
|
{
|
||||||
glDrawArrays(primtype, offset, count);
|
glDrawArrays(primtype, offset, count);
|
||||||
|
@ -89,7 +89,7 @@ public:
|
||||||
{
|
{
|
||||||
ImmRenderBuffer(primtype, offset, count);
|
ImmRenderBuffer(primtype, offset, count);
|
||||||
}
|
}
|
||||||
drawcalls.Unclock();
|
//drawcalls.Unclock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL)
|
void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL)
|
||||||
|
|
|
@ -301,8 +301,10 @@ void FRenderState::Apply()
|
||||||
|
|
||||||
void FRenderState::ApplyMatrices()
|
void FRenderState::ApplyMatrices()
|
||||||
{
|
{
|
||||||
glMatrixMode(GL_MODELVIEW);
|
drawcalls.Clock();
|
||||||
glLoadMatrixf(mViewMatrix.get());
|
if (GLRenderer->mShaderManager != NULL)
|
||||||
glMatrixMode(GL_PROJECTION);
|
{
|
||||||
glLoadMatrixf(mProjectionMatrix.get());
|
GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix);
|
||||||
|
}
|
||||||
|
drawcalls.Unclock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,9 +298,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans)
|
||||||
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
|
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
|
||||||
{
|
{
|
||||||
if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub);
|
if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub);
|
||||||
drawcalls.Clock();
|
//drawcalls.Clock();
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
|
glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
|
||||||
drawcalls.Unclock();
|
//drawcalls.Unclock();
|
||||||
flatvertices += sub->numlines;
|
flatvertices += sub->numlines;
|
||||||
flatprimitives++;
|
flatprimitives++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
#include "gl/system/gl_interface.h"
|
#include "gl/system/gl_interface.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
|
#include "gl/data/gl_matrix.h"
|
||||||
#include "gl/renderer/gl_renderer.h"
|
#include "gl/renderer/gl_renderer.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/system/gl_cvars.h"
|
#include "gl/system/gl_cvars.h"
|
||||||
|
@ -206,6 +207,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
timer_index = glGetUniformLocation(hShader, "timer");
|
timer_index = glGetUniformLocation(hShader, "timer");
|
||||||
lights_index = glGetUniformLocation(hShader, "lights");
|
lights_index = glGetUniformLocation(hShader, "lights");
|
||||||
fakevb_index = glGetUniformLocation(hShader, "fakeVB");
|
fakevb_index = glGetUniformLocation(hShader, "fakeVB");
|
||||||
|
projectionmatrix_index = glGetUniformLocation(hShader, "ProjectionMatrix");
|
||||||
|
viewmatrix_index = glGetUniformLocation(hShader, "ViewMatrix");
|
||||||
modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix");
|
modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix");
|
||||||
texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix");
|
texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix");
|
||||||
|
|
||||||
|
@ -277,6 +280,19 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
|
||||||
|
{
|
||||||
|
glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get());
|
||||||
|
glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -486,6 +502,33 @@ FShader *FShaderManager::BindEffect(int effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
EXTERN_CVAR(Int, gl_fuzztype)
|
||||||
|
|
||||||
|
void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= 4; i++)
|
||||||
|
{
|
||||||
|
mTextureEffects[i]->ApplyMatrices(proj, view);
|
||||||
|
}
|
||||||
|
if (gl_fuzztype != 0)
|
||||||
|
{
|
||||||
|
mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view);
|
||||||
|
}
|
||||||
|
for (unsigned i = 12; i < mTextureEffects.Size(); i++)
|
||||||
|
{
|
||||||
|
mTextureEffects[i]->ApplyMatrices(proj, view);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||||
|
{
|
||||||
|
mEffectShaders[i]->ApplyMatrices(proj, view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
|
@ -198,6 +198,8 @@ class FShader
|
||||||
|
|
||||||
int timer_index;
|
int timer_index;
|
||||||
int lights_index;
|
int lights_index;
|
||||||
|
int projectionmatrix_index;
|
||||||
|
int viewmatrix_index;
|
||||||
int modelmatrix_index;
|
int modelmatrix_index;
|
||||||
int texturematrix_index;
|
int texturematrix_index;
|
||||||
public:
|
public:
|
||||||
|
@ -230,6 +232,7 @@ public:
|
||||||
bool Bind();
|
bool Bind();
|
||||||
unsigned int GetHandle() const { return hShader; }
|
unsigned int GetHandle() const { return hShader; }
|
||||||
|
|
||||||
|
void ApplyMatrices(VSMatrix *proj, VSMatrix *view);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -256,6 +259,7 @@ public:
|
||||||
FShader *BindEffect(int effect);
|
FShader *BindEffect(int effect);
|
||||||
void SetActiveShader(FShader *sh);
|
void SetActiveShader(FShader *sh);
|
||||||
void SetWarpSpeed(unsigned int eff, float speed);
|
void SetWarpSpeed(unsigned int eff, float speed);
|
||||||
|
void ApplyMatrices(VSMatrix *proj, VSMatrix *view);
|
||||||
FShader *GetActiveShader() const
|
FShader *GetActiveShader() const
|
||||||
{
|
{
|
||||||
return mActiveShader;
|
return mActiveShader;
|
||||||
|
|
|
@ -36,8 +36,8 @@ uniform ivec4 uLightRange;
|
||||||
|
|
||||||
|
|
||||||
// redefine the matrix names to what they actually represent.
|
// redefine the matrix names to what they actually represent.
|
||||||
#define ProjectionMatrix gl_ProjectionMatrix
|
uniform mat4 ProjectionMatrix;
|
||||||
#define ViewMatrix gl_ModelViewMatrix
|
uniform mat4 ViewMatrix;
|
||||||
uniform mat4 ModelMatrix;
|
uniform mat4 ModelMatrix;
|
||||||
uniform mat4 TextureMatrix;
|
uniform mat4 TextureMatrix;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue