Clean up error handling a bit.

This commit is contained in:
Themaister 2011-06-07 15:58:30 +02:00
parent 3717f7442c
commit 11b58d8c69
2 changed files with 35 additions and 15 deletions

View File

@ -1173,8 +1173,15 @@ static bool gl_focus(void *data)
static bool gl_xml_shader(void *data, const char *path)
{
gl_t *gl = data;
//if (!gl_check_error())
// SSNES_WARN("Error happened before deinit!\n");
gl_shader_deinit();
//if (!gl_check_error())
// SSNES_WARN("Error happened in deinit!\n");
#ifdef HAVE_FBO
if (gl->fbo_inited)
{
@ -1186,13 +1193,13 @@ static bool gl_xml_shader(void *data, const char *path)
gl->render_to_tex = false;
gl->fbo_pass = 0;
if (!gl_check_error())
SSNES_WARN("Failed to deinit FBO properly!\n");
glBindTexture(GL_TEXTURE_2D, gl->texture);
}
#endif
//if (!gl_check_error())
// SSNES_WARN("Failed to deinit rendering path properly!\n");
if (!gl_glsl_init(path))
return false;

View File

@ -741,13 +741,30 @@ static bool compile_shader(GLuint shader, const char *program)
return status == GL_TRUE;
}
static bool link_program(GLuint prog)
{
pglLinkProgram(prog);
GLint status;
pglGetProgramiv(prog, GL_LINK_STATUS, &status);
print_linker_log(prog);
if (status == GL_TRUE)
{
pglUseProgram(prog);
return true;
}
else
return false;
}
static bool compile_programs(GLuint *gl_prog, struct shader_program *progs, size_t num)
{
for (unsigned i = 0; i < num; i++)
{
gl_prog[i] = pglCreateProgram();
if (!gl_check_error() || gl_prog[i] == 0)
if (gl_prog[i] == 0)
{
SSNES_ERR("Failed to create GL program #%u.\n", i);
return false;
@ -784,20 +801,16 @@ static bool compile_programs(GLuint *gl_prog, struct shader_program *progs, size
if (progs[i].vertex || progs[i].fragment)
{
SSNES_LOG("Linking GLSL program.\n");
pglLinkProgram(gl_prog[i]);
pglUseProgram(gl_prog[i]);
print_linker_log(gl_prog[i]);
if (!link_program(gl_prog[i]))
{
SSNES_ERR("Failed to link program #%u\n", i);
return false;
}
GLint location = pglGetUniformLocation(gl_prog[i], "rubyTexture");
pglUniform1i(location, 0);
pglUseProgram(0);
}
if (!gl_check_error())
{
SSNES_ERR("Failed to link program #%u\n", i);
return false;
}
}
return true;
@ -893,8 +906,8 @@ bool gl_glsl_init(const char *path)
}
}
if (!gl_check_error())
return false;
//if (!gl_check_error())
// SSNES_WARN("Detected GL error!\n");
if (gl_tracker_info_cnt > 0)
{