comparison pytouhou/ui/opengl/background.pyx @ 593:974decb8df4f

Only selects between GL_TRIANGLE_STRIP and GL_TRIANGLES once, in the backend.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 16 Oct 2014 21:40:54 +0200
parents 4b0593da29d5
children 3c2f96f1d715
comparison
equal deleted inserted replaced
592:19d930f9e3f0 593:974decb8df4f
18 (glVertexPointer, glTexCoordPointer, glColorPointer, 18 (glVertexPointer, glTexCoordPointer, glColorPointer,
19 glVertexAttribPointer, glEnableVertexAttribArray, glBlendFunc, 19 glVertexAttribPointer, glEnableVertexAttribArray, glBlendFunc,
20 glBindTexture, glBindBuffer, glBufferData, GL_ARRAY_BUFFER, 20 glBindTexture, glBindBuffer, glBufferData, GL_ARRAY_BUFFER,
21 GL_STATIC_DRAW, GL_UNSIGNED_BYTE, GL_FLOAT, GL_SRC_ALPHA, 21 GL_STATIC_DRAW, GL_UNSIGNED_BYTE, GL_FLOAT, GL_SRC_ALPHA,
22 GL_ONE_MINUS_SRC_ALPHA, GL_TEXTURE_2D, glGenBuffers, glEnable, 22 GL_ONE_MINUS_SRC_ALPHA, GL_TEXTURE_2D, glGenBuffers, glEnable,
23 glDisable, GL_DEPTH_TEST, glDrawElements, GL_TRIANGLES, 23 glDisable, GL_DEPTH_TEST, glDrawElements, GL_UNSIGNED_SHORT,
24 GL_UNSIGNED_SHORT, GL_ELEMENT_ARRAY_BUFFER, glDeleteBuffers, 24 GL_ELEMENT_ARRAY_BUFFER, glDeleteBuffers, glGenVertexArrays,
25 glGenVertexArrays, glDeleteVertexArrays, glBindVertexArray, 25 glDeleteVertexArrays, glBindVertexArray, glPushDebugGroup,
26 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup, 26 GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup)
27 GL_TRIANGLE_STRIP)
28 27
29 from .sprite cimport get_sprite_rendering_data 28 from .sprite cimport get_sprite_rendering_data
30 from .backend cimport is_legacy, use_debug_group, use_vao, use_primitive_restart 29 from .backend cimport primitive_mode, is_legacy, use_debug_group, use_vao, use_primitive_restart
31 30
32 31
33 cdef class BackgroundRenderer: 32 cdef class BackgroundRenderer:
34 def __dealloc__(self): 33 def __dealloc__(self):
35 if is_legacy: 34 if is_legacy:
93 self.set_state() 92 self.set_state()
94 93
95 glEnable(GL_DEPTH_TEST) 94 glEnable(GL_DEPTH_TEST)
96 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 95 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
97 glBindTexture(GL_TEXTURE_2D, self.texture) 96 glBindTexture(GL_TEXTURE_2D, self.texture)
98 glDrawElements(GL_TRIANGLE_STRIP if use_primitive_restart else GL_TRIANGLES, self.nb_indices, GL_UNSIGNED_SHORT, indices) 97 glDrawElements(primitive_mode, self.nb_indices, GL_UNSIGNED_SHORT, indices)
99 glDisable(GL_DEPTH_TEST) 98 glDisable(GL_DEPTH_TEST)
100 99
101 if not is_legacy: 100 if not is_legacy:
102 if use_vao: 101 if use_vao:
103 glBindVertexArray(0) 102 glBindVertexArray(0)