mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- simplify the interface.
This commit is contained in:
parent
1967165633
commit
9486180843
4 changed files with 20 additions and 18 deletions
|
@ -471,7 +471,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
|
|||
matrices.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
|
||||
matrices.mViewMatrix.loadIdentity();
|
||||
matrices.CalcDependencies();
|
||||
GLRenderer->mShaderManager->ApplyMatrices(&matrices.mProjectionMatrix, &matrices.mViewMatrix, &matrices.mNormalViewMatrix, NORMAL_PASS);
|
||||
GLRenderer->mShaderManager->ApplyMatrices(&matrices, NORMAL_PASS);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ EXTERN_CVAR (Bool, r_drawvoxels)
|
|||
void FDrawInfo::ApplyVPUniforms()
|
||||
{
|
||||
VPUniforms.CalcDependencies();
|
||||
GLRenderer->mShaderManager->ApplyMatrices(&VPUniforms.mProjectionMatrix, &VPUniforms.mViewMatrix, &VPUniforms.mNormalViewMatrix, NORMAL_PASS);
|
||||
GLRenderer->mShaderManager->ApplyMatrices(&VPUniforms, NORMAL_PASS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "cmdlib.h"
|
||||
#include "hwrenderer/utility/hw_shaderpatcher.h"
|
||||
#include "hwrenderer/data/shaderuniforms.h"
|
||||
#include "hwrenderer/scene/hw_viewpointuniforms.h"
|
||||
|
||||
#include "gl_load/gl_interface.h"
|
||||
#include "gl/system/gl_debug.h"
|
||||
|
@ -434,12 +435,12 @@ FShader *FShaderCollection::Compile (const char *ShaderName, const char *ShaderP
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm)
|
||||
void FShader::ApplyMatrices(HWViewpointUniforms *u)
|
||||
{
|
||||
Bind();
|
||||
glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get());
|
||||
glUniformMatrix4fv(viewmatrix_index, 1, false, view->get());
|
||||
glUniformMatrix4fv(normalviewmatrix_index, 1, false, norm->get());
|
||||
glUniformMatrix4fv(projectionmatrix_index, 1, false, u->mProjectionMatrix.get());
|
||||
glUniformMatrix4fv(viewmatrix_index, 1, false, u->mViewMatrix.get());
|
||||
glUniformMatrix4fv(normalviewmatrix_index, 1, false, u->mNormalViewMatrix.get());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -539,10 +540,10 @@ FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passT
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm, EPassType passType)
|
||||
void FShaderManager::ApplyMatrices(HWViewpointUniforms *u, EPassType passType)
|
||||
{
|
||||
if (passType < mPassShaders.Size())
|
||||
mPassShaders[passType]->ApplyMatrices(proj, view, norm);
|
||||
mPassShaders[passType]->ApplyMatrices(u);
|
||||
|
||||
if (mActiveShader)
|
||||
mActiveShader->Bind();
|
||||
|
@ -687,25 +688,25 @@ FShader *FShaderCollection::BindEffect(int effect)
|
|||
//==========================================================================
|
||||
EXTERN_CVAR(Int, gl_fuzztype)
|
||||
|
||||
void FShaderCollection::ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm)
|
||||
void FShaderCollection::ApplyMatrices(HWViewpointUniforms *u)
|
||||
{
|
||||
for (int i = 0; i < SHADER_NoTexture; i++)
|
||||
{
|
||||
mMaterialShaders[i]->ApplyMatrices(proj, view, norm);
|
||||
mMaterialShadersNAT[i]->ApplyMatrices(proj, view, norm);
|
||||
mMaterialShaders[i]->ApplyMatrices(u);
|
||||
mMaterialShadersNAT[i]->ApplyMatrices(u);
|
||||
}
|
||||
mMaterialShaders[SHADER_NoTexture]->ApplyMatrices(proj, view, norm);
|
||||
mMaterialShaders[SHADER_NoTexture]->ApplyMatrices(u);
|
||||
if (gl_fuzztype != 0)
|
||||
{
|
||||
mMaterialShaders[SHADER_NoTexture + gl_fuzztype]->ApplyMatrices(proj, view, norm);
|
||||
mMaterialShaders[SHADER_NoTexture + gl_fuzztype]->ApplyMatrices(u);
|
||||
}
|
||||
for (unsigned i = FIRST_USER_SHADER; i < mMaterialShaders.Size(); i++)
|
||||
{
|
||||
mMaterialShaders[i]->ApplyMatrices(proj, view, norm);
|
||||
mMaterialShaders[i]->ApplyMatrices(u);
|
||||
}
|
||||
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||
{
|
||||
mEffectShaders[i]->ApplyMatrices(proj, view, norm);
|
||||
mEffectShaders[i]->ApplyMatrices(u);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ enum
|
|||
};
|
||||
|
||||
class FShaderCollection;
|
||||
struct HWViewpointUniforms;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -306,7 +307,7 @@ public:
|
|||
bool Bind();
|
||||
unsigned int GetHandle() const { return hShader; }
|
||||
|
||||
void ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm);
|
||||
void ApplyMatrices(HWViewpointUniforms *u);
|
||||
|
||||
};
|
||||
|
||||
|
@ -326,7 +327,7 @@ public:
|
|||
|
||||
FShader *BindEffect(int effect, EPassType passType);
|
||||
FShader *Get(unsigned int eff, bool alphateston, EPassType passType);
|
||||
void ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm, EPassType passType);
|
||||
void ApplyMatrices(HWViewpointUniforms *u, EPassType passType);
|
||||
|
||||
private:
|
||||
FShader *mActiveShader = nullptr;
|
||||
|
@ -348,7 +349,7 @@ public:
|
|||
FShader *Compile(const char *ShaderName, const char *ShaderPath, const char *LightModePath, const char *shaderdefines, bool usediscard, EPassType passType);
|
||||
int Find(const char *mame);
|
||||
FShader *BindEffect(int effect);
|
||||
void ApplyMatrices(VSMatrix *proj, VSMatrix *view, VSMatrix *norm);
|
||||
void ApplyMatrices(HWViewpointUniforms *u);
|
||||
|
||||
FShader *Get(unsigned int eff, bool alphateston)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue