Commit 721134b0 authored by Emmanuele Bassi's avatar Emmanuele Bassi

demo/glarea: Check errors on GtkGLArea

We should not call OpenGL API if GtkGLArea is in an error state.

https://bugzilla.gnome.org/show_bug.cgi?id=746746
parent fae3eaff
......@@ -220,6 +220,9 @@ realize (GtkWidget *widget)
{
gtk_gl_area_make_current (GTK_GL_AREA (widget));
if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
return;
init_buffers (&position_buffer, NULL);
init_shaders (&program, &mvp_location);
}
......@@ -230,6 +233,9 @@ unrealize (GtkWidget *widget)
{
gtk_gl_area_make_current (GTK_GL_AREA (widget));
if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
return;
glDeleteBuffers (1, &position_buffer);
glDeleteProgram (program);
}
......@@ -271,6 +277,9 @@ static gboolean
render (GtkGLArea *area,
GdkGLContext *context)
{
if (gtk_gl_area_get_error (area) != NULL)
return FALSE;
/* Clear the viewport */
glClearColor (0.5, 0.5, 0.5, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment