changeset 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 bafe6361c0af
files pytouhou/ui/opengl/background.pxd pytouhou/ui/opengl/background.pyx pytouhou/ui/opengl/gamerenderer.pyx pytouhou/ui/opengl/renderer.pxd pytouhou/ui/opengl/renderer.pyx
diffstat 5 files changed, 23 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/ui/opengl/background.pxd	Fri May 30 16:40:36 2014 +0200
+++ b/pytouhou/ui/opengl/background.pxd	Fri May 30 16:51:38 2014 +0200
@@ -10,7 +10,6 @@
 cdef class BackgroundRenderer:
     cdef GLuint texture
     cdef GLsizei nb_indices
-    cdef unsigned int use_fixed_pipeline
 
     # For modern GL.
     cdef GLuint vbo, ibo
--- a/pytouhou/ui/opengl/background.pyx	Fri May 30 16:40:36 2014 +0200
+++ b/pytouhou/ui/opengl/background.pyx	Fri May 30 16:51:38 2014 +0200
@@ -25,12 +25,12 @@
           glGenVertexArrays, glDeleteVertexArrays, glBindVertexArray)
 
 from .sprite cimport get_sprite_rendering_data
-from .backend cimport use_vao
+from .backend cimport is_legacy, use_vao
 
 
 cdef class BackgroundRenderer:
     def __dealloc__(self):
-        if self.use_fixed_pipeline:
+        if is_legacy:
             if self.vertex_buffer != NULL:
                 free(self.vertex_buffer)
             if self.indices != NULL:
@@ -43,10 +43,8 @@
                 glDeleteVertexArrays(1, &self.vao)
 
 
-    def __init__(self, use_fixed_pipeline):
-        self.use_fixed_pipeline = use_fixed_pipeline
-
-        if not use_fixed_pipeline:
+    def __init__(self):
+        if not is_legacy:
             glGenBuffers(1, &self.vbo)
             glGenBuffers(1, &self.ibo)
 
@@ -72,7 +70,7 @@
 
 
     cdef void render_background(self):
-        if self.use_fixed_pipeline:
+        if is_legacy:
             indices = self.indices
             glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].x)
             glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].u)
@@ -90,7 +88,7 @@
         glDrawElements(GL_TRIANGLES, self.nb_indices, GL_UNSIGNED_SHORT, indices)
         glDisable(GL_DEPTH_TEST)
 
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             if use_vao:
                 glBindVertexArray(0)
             else:
@@ -138,7 +136,7 @@
         self.texture = renderer.textures[key >> 1]
         self.nb_indices = nb_indices
 
-        if self.use_fixed_pipeline:
+        if is_legacy:
             self.vertex_buffer = <Vertex*> realloc(vertex_buffer, nb_vertices * sizeof(Vertex))
             self.indices = <GLushort*> realloc(indices, nb_indices * sizeof(GLushort))
         else:
--- a/pytouhou/ui/opengl/gamerenderer.pyx	Fri May 30 16:40:36 2014 +0200
+++ b/pytouhou/ui/opengl/gamerenderer.pyx	Fri May 30 16:51:38 2014 +0200
@@ -36,11 +36,9 @@
 
 cdef class GameRenderer(Renderer):
     def __init__(self, resource_loader, _):
-        self.use_fixed_pipeline = is_legacy #XXX
-
         Renderer.__init__(self, resource_loader)
 
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             self.game_shader = GameShader()
             self.background_shader = BackgroundShader()
             self.interface_shader = self.game_shader
@@ -71,7 +69,7 @@
     def load_background(self, background):
         self.background = background
         if background is not None:
-            self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline)
+            self.background_renderer = BackgroundRenderer()
             self.background_renderer.load(background, self)
         else:
             self.background_renderer = None
@@ -87,14 +85,14 @@
 
 
     def render(self, Game game):
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             self.framebuffer.bind()
 
         self.render_game(game)
         self.render_text(game.texts)
         self.render_interface(game.interface, game.boss)
 
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             self.passthrough_shader.bind()
             self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp)
             self.render_framebuffer(self.framebuffer)
@@ -114,12 +112,12 @@
         glScissor(game_x, game_y, game.width, game.height)
         glEnable(GL_SCISSOR_TEST)
 
-        if self.use_fixed_pipeline:
+        if is_legacy:
             glMatrixMode(GL_PROJECTION)
             glLoadIdentity()
 
         if game is not None and game.spellcard_effect is not None:
-            if self.use_fixed_pipeline:
+            if is_legacy:
                 glMatrixMode(GL_MODELVIEW)
                 glLoadMatrixf(<GLfloat*>self.game_mvp)
                 glDisable(GL_FOG)
@@ -153,7 +151,7 @@
             free(view)
             mul(mvp, self.proj)
 
-            if self.use_fixed_pipeline:
+            if is_legacy:
                 glMatrixMode(GL_MODELVIEW)
                 glLoadMatrixf(mvp_data)
 
@@ -181,7 +179,7 @@
             glClear(GL_COLOR_BUFFER_BIT)
 
         if game is not None:
-            if self.use_fixed_pipeline:
+            if is_legacy:
                 glMatrixMode(GL_MODELVIEW)
                 glLoadMatrixf(<GLfloat*>self.game_mvp)
                 glDisable(GL_FOG)
@@ -236,7 +234,7 @@
 
         elements = []
 
-        if self.use_fixed_pipeline:
+        if is_legacy:
             glMatrixMode(GL_MODELVIEW)
             glLoadMatrixf(<GLfloat*>self.interface_mvp)
             glDisable(GL_FOG)
--- a/pytouhou/ui/opengl/renderer.pxd	Fri May 30 16:40:36 2014 +0200
+++ b/pytouhou/ui/opengl/renderer.pxd	Fri May 30 16:51:38 2014 +0200
@@ -33,8 +33,6 @@
     cdef GLuint vbo, framebuffer_vbo, framebuffer_ibo
     cdef GLuint vao, framebuffer_vao
 
-    cdef bint use_fixed_pipeline #XXX
-
     cdef GLuint textures[MAX_TEXTURES]
     cdef unsigned short *indices[MAX_TEXTURES][2]
     cdef unsigned short last_indices[2 * MAX_TEXTURES]
--- a/pytouhou/ui/opengl/renderer.pyx	Fri May 30 16:40:36 2014 +0200
+++ b/pytouhou/ui/opengl/renderer.pyx	Fri May 30 16:51:38 2014 +0200
@@ -39,7 +39,7 @@
 
 from pytouhou.game.element cimport Element
 from .sprite cimport get_sprite_rendering_data
-from .backend cimport use_vao
+from .backend cimport is_legacy, use_vao
 
 from pytouhou.utils.helpers import get_logger
 
@@ -93,7 +93,7 @@
 
 cdef class Renderer:
     def __dealloc__(self):
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             glDeleteBuffers(1, &self.framebuffer_vbo)
             glDeleteBuffers(1, &self.vbo)
 
@@ -114,7 +114,7 @@
             self.font_manager = None
             logger.error('Font file ā€œ%sā€ not found, disabling text rendering altogether.', font_name)
 
-        if not self.use_fixed_pipeline:
+        if not is_legacy:
             framebuffer_indices[:] = [0, 1, 2, 2, 3, 0]
 
             glGenBuffers(1, &self.vbo)
@@ -204,7 +204,7 @@
 
             nb_vertices += 4
 
-        if self.use_fixed_pipeline:
+        if is_legacy:
             glVertexPointer(3, GL_SHORT, sizeof(Vertex), &self.vertex_buffer[0].x)
             glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &self.vertex_buffer[0].u)
             glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &self.vertex_buffer[0].r)
@@ -241,7 +241,7 @@
 
         glBindTexture(GL_TEXTURE_2D, 0)
 
-        if not self.use_fixed_pipeline and use_vao:
+        if not is_legacy and use_vao:
             glBindVertexArray(0)
 
 
@@ -262,7 +262,7 @@
             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)
             buf[4*i+3] = Vertex(r.x, r.y + r.h, 0, 0, 0, 1, c4.r, c4.g, c4.b, c4.a)
 
-        if self.use_fixed_pipeline:
+        if is_legacy:
             glVertexPointer(3, GL_SHORT, sizeof(Vertex), &buf[0].x)
             glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &buf[0].u)
             glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &buf[0].r)
@@ -284,7 +284,7 @@
     cdef void render_framebuffer(self, Framebuffer fb):
         cdef PassthroughVertex[4] buf
 
-        assert not self.use_fixed_pipeline
+        assert not is_legacy
 
         glBindFramebuffer(GL_FRAMEBUFFER, 0)
         glViewport(self.x, self.y, self.width, self.height)