mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Added shader sharing mechanism; added "cook all dirty packages" button; other various tweaks and fixes
This commit is contained in:
@@ -13,12 +13,14 @@ u64 gFailedCompileCount = 0;
|
||||
u64 gSuccessfulCompileCount = 0;
|
||||
|
||||
CShader* CShader::spCurrentShader = nullptr;
|
||||
int CShader::smNumShaders = 0;
|
||||
|
||||
CShader::CShader()
|
||||
{
|
||||
mVertexShaderExists = false;
|
||||
mPixelShaderExists = false;
|
||||
mProgramExists = false;
|
||||
smNumShaders++;
|
||||
}
|
||||
|
||||
CShader::CShader(const char *pkVertexSource, const char *pkPixelSource)
|
||||
@@ -26,6 +28,7 @@ CShader::CShader(const char *pkVertexSource, const char *pkPixelSource)
|
||||
mVertexShaderExists = false;
|
||||
mPixelShaderExists = false;
|
||||
mProgramExists = false;
|
||||
smNumShaders++;
|
||||
|
||||
CompileVertexSource(pkVertexSource);
|
||||
CompilePixelSource(pkPixelSource);
|
||||
@@ -39,6 +42,7 @@ CShader::~CShader()
|
||||
if (mProgramExists) glDeleteProgram(mProgram);
|
||||
|
||||
if (spCurrentShader == this) spCurrentShader = 0;
|
||||
smNumShaders--;
|
||||
}
|
||||
|
||||
bool CShader::CompileVertexSource(const char* pkSource)
|
||||
|
||||
@@ -23,6 +23,7 @@ class CShader
|
||||
GLint mTextureUniforms[8];
|
||||
GLint mNumLightsUniform;
|
||||
|
||||
static int smNumShaders;
|
||||
static CShader* spCurrentShader;
|
||||
|
||||
public:
|
||||
@@ -45,6 +46,8 @@ public:
|
||||
static CShader* CurrentShader();
|
||||
static void KillCachedShader();
|
||||
|
||||
inline static int NumShaders() { return smNumShaders; }
|
||||
|
||||
private:
|
||||
void CacheCommonUniforms();
|
||||
void DumpShaderSource(GLuint Shader, const TString& rkOut);
|
||||
|
||||
Reference in New Issue
Block a user