Mercurial > touhou
diff pytouhou/ui/opengl/background.pyx @ 582:6e79756b7f42
Don’t call gl*DebugGroup if it isn’t exposed by the driver.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 05 Oct 2014 17:46:51 +0200 |
parents | b8df946d394d |
children | e0166cda75d5 |
line wrap: on
line diff
--- a/pytouhou/ui/opengl/background.pyx +++ b/pytouhou/ui/opengl/background.pyx @@ -26,7 +26,7 @@ from pytouhou.lib.opengl cimport \ glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup) from .sprite cimport get_sprite_rendering_data -from .backend cimport is_legacy, use_vao +from .backend cimport is_legacy, use_debug_group, use_vao cdef class BackgroundRenderer: @@ -46,7 +46,9 @@ cdef class BackgroundRenderer: def __init__(self): if not is_legacy: - glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background creation") + if use_debug_group: + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background creation") + glGenBuffers(1, &self.vbo) glGenBuffers(1, &self.ibo) @@ -55,7 +57,9 @@ cdef class BackgroundRenderer: glBindVertexArray(self.vao) self.set_state() glBindVertexArray(0) - glPopDebugGroup() + + if use_debug_group: + glPopDebugGroup() cdef void set_state(self) nogil: @@ -72,7 +76,9 @@ cdef class BackgroundRenderer: cdef void render_background(self): - glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background drawing") + if use_debug_group: + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background drawing") + if is_legacy: indices = self.indices glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].x) @@ -97,7 +103,9 @@ cdef class BackgroundRenderer: else: glBindBuffer(GL_ARRAY_BUFFER, 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) - glPopDebugGroup() + + if use_debug_group: + glPopDebugGroup() cdef void load(self, background, Renderer renderer): @@ -144,7 +152,9 @@ cdef class BackgroundRenderer: self.vertex_buffer = <Vertex*> realloc(vertex_buffer, nb_vertices * sizeof(Vertex)) self.indices = <GLushort*> realloc(indices, nb_indices * sizeof(GLushort)) else: - glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background uploading") + if use_debug_group: + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Background uploading") + glBindBuffer(GL_ARRAY_BUFFER, self.vbo) glBufferData(GL_ARRAY_BUFFER, nb_vertices * sizeof(Vertex), vertex_buffer, GL_STATIC_DRAW) glBindBuffer(GL_ARRAY_BUFFER, 0) @@ -152,4 +162,6 @@ cdef class BackgroundRenderer: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.ibo) glBufferData(GL_ELEMENT_ARRAY_BUFFER, nb_indices * sizeof(GLushort), indices, GL_STATIC_DRAW) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) - glPopDebugGroup() + + if use_debug_group: + glPopDebugGroup()