mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
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
This commit is contained in:
parent
fae3eaffcd
commit
721134b008
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user