This commit is contained in:
Ryan Houdek 2011-12-02 18:31:06 -06:00
parent 49b6e4beed
commit 6882e00d5e
2 changed files with 60 additions and 2 deletions

View File

@ -296,8 +296,37 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
// GLSL Specific
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;
}
(void)GL_REPORT_ERROR();
ps.glprogid = result;
return true;
}
void PixelShaderCache::SetPSSampler(const char * name, unsigned int Tex)
{
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();

View File

@ -180,8 +180,37 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
// GLSL Specific
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;
}
(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)
{
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();