This commit is contained in:
Ryan Houdek 2011-12-02 18:31:06 -06:00 committed by Sonicadvance1
parent 34c7b3fd73
commit 411357b54a
2 changed files with 60 additions and 2 deletions

View File

@ -296,7 +296,36 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
// GLSL Specific // GLSL Specific
bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram) bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
{ {
GLuint result = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(result, 1, &pstrprogram, NULL);
glCompileShader(result);
GLsizei length = 0;
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length);
if (length > 0)
{
GLsizei charsWritten;
GLchar* infoLog = new GLchar[length];
glGetShaderInfoLog(result, length, &charsWritten, infoLog);
WARN_LOG(VIDEO, "Shader info log:\n%s", infoLog);
delete[] infoLog;
}
GLint compileStatus;
glGetShaderiv(result, GL_COMPILE_STATUS, &compileStatus);
if (compileStatus != GL_TRUE)
{
// Compile failed
ERROR_LOG(VIDEO, "Shader compilation failed; see info log");
// Don't try to use this shader
glDeleteShader(result);
return false; return false;
}
(void)GL_REPORT_ERROR();
ps.glprogid = result;
return true;
} }
void PixelShaderCache::SetPSSampler(const char * name, unsigned int Tex) void PixelShaderCache::SetPSSampler(const char * name, unsigned int Tex)
{ {

View File

@ -180,7 +180,36 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
// GLSL Specific // GLSL Specific
bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram) bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
{ {
GLuint result = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(result, 1, &pstrprogram, NULL);
glCompileShader(result);
GLsizei length = 0;
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length);
if (length > 0)
{
GLsizei charsWritten;
GLchar* infoLog = new GLchar[length];
glGetShaderInfoLog(result, length, &charsWritten, infoLog);
WARN_LOG(VIDEO, "Shader info log:\n%s", infoLog);
delete[] infoLog;
}
GLint compileStatus;
glGetShaderiv(result, GL_COMPILE_STATUS, &compileStatus);
if (compileStatus != GL_TRUE)
{
// Compile failed
ERROR_LOG(VIDEO, "Shader compilation failed; see info log");
// Don't try to use this shader
glDeleteShader(result);
return false; return false;
}
(void)GL_REPORT_ERROR();
vs.glprogid = result;
return true;
} }
void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1) void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
{ {