Initialize compile status variable and check also program link status
parent
7a1c45bd1c
commit
d6122704e8
|
@ -126,7 +126,7 @@ static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
|
||||||
|
|
||||||
static SDL_bool CompileShader(GLhandleARB shader, const char *source)
|
static SDL_bool CompileShader(GLhandleARB shader, const char *source)
|
||||||
{
|
{
|
||||||
GLint status;
|
GLint status = 0;
|
||||||
|
|
||||||
glShaderSourceARB(shader, 1, &source, NULL);
|
glShaderSourceARB(shader, 1, &source, NULL);
|
||||||
glCompileShaderARB(shader);
|
glCompileShaderARB(shader);
|
||||||
|
@ -147,6 +147,31 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SDL_bool LinkProgram(ShaderData *data)
|
||||||
|
{
|
||||||
|
GLint status = 0;
|
||||||
|
|
||||||
|
glAttachObjectARB(data->program, data->vert_shader);
|
||||||
|
glAttachObjectARB(data->program, data->frag_shader);
|
||||||
|
glLinkProgramARB(data->program);
|
||||||
|
|
||||||
|
glGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status);
|
||||||
|
if (status == 0) {
|
||||||
|
GLint length;
|
||||||
|
char *info;
|
||||||
|
|
||||||
|
glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||||
|
info = SDL_stack_alloc(char, length+1);
|
||||||
|
glGetInfoLogARB(data->program, length, NULL, info);
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info);
|
||||||
|
SDL_stack_free(info);
|
||||||
|
|
||||||
|
return SDL_FALSE;
|
||||||
|
} else {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SDL_bool CompileShaderProgram(ShaderData *data)
|
static SDL_bool CompileShaderProgram(ShaderData *data)
|
||||||
{
|
{
|
||||||
const int num_tmus_bound = 4;
|
const int num_tmus_bound = 4;
|
||||||
|
@ -171,9 +196,9 @@ static SDL_bool CompileShaderProgram(ShaderData *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ... and in the darkness bind them */
|
/* ... and in the darkness bind them */
|
||||||
glAttachObjectARB(data->program, data->vert_shader);
|
if (!LinkProgram(data)) {
|
||||||
glAttachObjectARB(data->program, data->frag_shader);
|
return SDL_FALSE;
|
||||||
glLinkProgramARB(data->program);
|
}
|
||||||
|
|
||||||
/* Set up some uniform variables */
|
/* Set up some uniform variables */
|
||||||
glUseProgramObjectARB(data->program);
|
glUseProgramObjectARB(data->program);
|
||||||
|
|
Loading…
Reference in New Issue