Mercurial > touhou
comparison pytouhou/ui/opengl/renderer.pyx @ 560:c759b97f4f81
Remove all reference to the old fixed pipeline option in the OpenGL backend, use the newer is_legacy one.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 30 May 2014 16:51:38 +0200 |
parents | 1be60813f7cb |
children | b8df946d394d |
comparison
equal
deleted
inserted
replaced
559:1be60813f7cb | 560:c759b97f4f81 |
---|---|
37 | 37 |
38 from pytouhou.lib.sdl import SDLError | 38 from pytouhou.lib.sdl import SDLError |
39 | 39 |
40 from pytouhou.game.element cimport Element | 40 from pytouhou.game.element cimport Element |
41 from .sprite cimport get_sprite_rendering_data | 41 from .sprite cimport get_sprite_rendering_data |
42 from .backend cimport use_vao | 42 from .backend cimport is_legacy, use_vao |
43 | 43 |
44 from pytouhou.utils.helpers import get_logger | 44 from pytouhou.utils.helpers import get_logger |
45 | 45 |
46 logger = get_logger(__name__) | 46 logger = get_logger(__name__) |
47 | 47 |
91 return i | 91 return i |
92 | 92 |
93 | 93 |
94 cdef class Renderer: | 94 cdef class Renderer: |
95 def __dealloc__(self): | 95 def __dealloc__(self): |
96 if not self.use_fixed_pipeline: | 96 if not is_legacy: |
97 glDeleteBuffers(1, &self.framebuffer_vbo) | 97 glDeleteBuffers(1, &self.framebuffer_vbo) |
98 glDeleteBuffers(1, &self.vbo) | 98 glDeleteBuffers(1, &self.vbo) |
99 | 99 |
100 if use_vao: | 100 if use_vao: |
101 glDeleteVertexArrays(1, &self.vao) | 101 glDeleteVertexArrays(1, &self.vao) |
112 self.font_manager = FontManager(font_name, 16, self, Texture) | 112 self.font_manager = FontManager(font_name, 16, self, Texture) |
113 except SDLError: | 113 except SDLError: |
114 self.font_manager = None | 114 self.font_manager = None |
115 logger.error('Font file ā%sā not found, disabling text rendering altogether.', font_name) | 115 logger.error('Font file ā%sā not found, disabling text rendering altogether.', font_name) |
116 | 116 |
117 if not self.use_fixed_pipeline: | 117 if not is_legacy: |
118 framebuffer_indices[:] = [0, 1, 2, 2, 3, 0] | 118 framebuffer_indices[:] = [0, 1, 2, 2, 3, 0] |
119 | 119 |
120 glGenBuffers(1, &self.vbo) | 120 glGenBuffers(1, &self.vbo) |
121 glGenBuffers(1, &self.framebuffer_vbo) | 121 glGenBuffers(1, &self.framebuffer_vbo) |
122 glGenBuffers(1, &self.framebuffer_ibo) | 122 glGenBuffers(1, &self.framebuffer_ibo) |
202 rec[next_indice+5] = nb_vertices | 202 rec[next_indice+5] = nb_vertices |
203 self.last_indices[key] += 6 | 203 self.last_indices[key] += 6 |
204 | 204 |
205 nb_vertices += 4 | 205 nb_vertices += 4 |
206 | 206 |
207 if self.use_fixed_pipeline: | 207 if is_legacy: |
208 glVertexPointer(3, GL_SHORT, sizeof(Vertex), &self.vertex_buffer[0].x) | 208 glVertexPointer(3, GL_SHORT, sizeof(Vertex), &self.vertex_buffer[0].x) |
209 glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].u) | 209 glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].u) |
210 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &self.vertex_buffer[0].r) | 210 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &self.vertex_buffer[0].r) |
211 else: | 211 else: |
212 glBindBuffer(GL_ARRAY_BUFFER, self.vbo) | 212 glBindBuffer(GL_ARRAY_BUFFER, self.vbo) |
239 previous_blendfunc = blendfunc | 239 previous_blendfunc = blendfunc |
240 previous_texture = texture | 240 previous_texture = texture |
241 | 241 |
242 glBindTexture(GL_TEXTURE_2D, 0) | 242 glBindTexture(GL_TEXTURE_2D, 0) |
243 | 243 |
244 if not self.use_fixed_pipeline and use_vao: | 244 if not is_legacy and use_vao: |
245 glBindVertexArray(0) | 245 glBindVertexArray(0) |
246 | 246 |
247 | 247 |
248 cdef void render_quads(self, rects, colors, GLuint texture): | 248 cdef void render_quads(self, rects, colors, GLuint texture): |
249 # There is nothing that batch more than two quads on the same texture, currently. | 249 # There is nothing that batch more than two quads on the same texture, currently. |
260 buf[4*i] = Vertex(r.x, r.y, 0, 0, 0, 0, c1.r, c1.g, c1.b, c1.a) | 260 buf[4*i] = Vertex(r.x, r.y, 0, 0, 0, 0, c1.r, c1.g, c1.b, c1.a) |
261 buf[4*i+1] = Vertex(r.x + r.w, r.y, 0, 0, 1, 0, c2.r, c2.g, c2.b, c2.a) | 261 buf[4*i+1] = Vertex(r.x + r.w, r.y, 0, 0, 1, 0, c2.r, c2.g, c2.b, c2.a) |
262 buf[4*i+2] = Vertex(r.x + r.w, r.y + r.h, 0, 0, 1, 1, c3.r, c3.g, c3.b, c3.a) | 262 buf[4*i+2] = Vertex(r.x + r.w, r.y + r.h, 0, 0, 1, 1, c3.r, c3.g, c3.b, c3.a) |
263 buf[4*i+3] = Vertex(r.x, r.y + r.h, 0, 0, 0, 1, c4.r, c4.g, c4.b, c4.a) | 263 buf[4*i+3] = Vertex(r.x, r.y + r.h, 0, 0, 0, 1, c4.r, c4.g, c4.b, c4.a) |
264 | 264 |
265 if self.use_fixed_pipeline: | 265 if is_legacy: |
266 glVertexPointer(3, GL_SHORT, sizeof(Vertex), &buf[0].x) | 266 glVertexPointer(3, GL_SHORT, sizeof(Vertex), &buf[0].x) |
267 glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &buf[0].u) | 267 glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &buf[0].u) |
268 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &buf[0].r) | 268 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &buf[0].r) |
269 else: | 269 else: |
270 glBindBuffer(GL_ARRAY_BUFFER, self.vbo) | 270 glBindBuffer(GL_ARRAY_BUFFER, self.vbo) |
282 | 282 |
283 | 283 |
284 cdef void render_framebuffer(self, Framebuffer fb): | 284 cdef void render_framebuffer(self, Framebuffer fb): |
285 cdef PassthroughVertex[4] buf | 285 cdef PassthroughVertex[4] buf |
286 | 286 |
287 assert not self.use_fixed_pipeline | 287 assert not is_legacy |
288 | 288 |
289 glBindFramebuffer(GL_FRAMEBUFFER, 0) | 289 glBindFramebuffer(GL_FRAMEBUFFER, 0) |
290 glViewport(self.x, self.y, self.width, self.height) | 290 glViewport(self.x, self.y, self.width, self.height) |
291 glBlendFunc(GL_ONE, GL_ZERO) | 291 glBlendFunc(GL_ONE, GL_ZERO) |
292 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) | 292 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) |