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
+++ b/pytouhou/ui/opengl/background.pxd
@@ -10,7 +10,6 @@ cdef struct Vertex:
 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
+++ b/pytouhou/ui/opengl/background.pyx
@@ -25,12 +25,12 @@ from pytouhou.lib.opengl cimport \
           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 @@ cdef class BackgroundRenderer:
                 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 class BackgroundRenderer:
 
 
     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 @@ cdef class BackgroundRenderer:
         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 @@ cdef class BackgroundRenderer:
         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
+++ b/pytouhou/ui/opengl/gamerenderer.pyx
@@ -36,11 +36,9 @@ Color = namedtuple('Color', 'r g b a')
 
 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 @@ cdef class GameRenderer(Renderer):
     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 @@ cdef class GameRenderer(Renderer):
 
 
     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 @@ cdef class GameRenderer(Renderer):
         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 @@ cdef class GameRenderer(Renderer):
             free(view)
             mul(mvp, self.proj)
 
-            if self.use_fixed_pipeline:
+            if is_legacy:
                 glMatrixMode(GL_MODELVIEW)
                 glLoadMatrixf(mvp_data)
 
@@ -181,7 +179,7 @@ cdef class GameRenderer(Renderer):
             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 @@ cdef class GameRenderer(Renderer):
 
         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
+++ b/pytouhou/ui/opengl/renderer.pxd
@@ -33,8 +33,6 @@ cdef class Renderer:
     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
+++ b/pytouhou/ui/opengl/renderer.pyx
@@ -39,7 +39,7 @@ from pytouhou.lib.sdl import SDLError
 
 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 long find_objects(Renderer self, ob
 
 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 @@ cdef class Renderer:
             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 @@ cdef class Renderer:
 
             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 @@ cdef class Renderer:
 
         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 @@ cdef class Renderer:
             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 class Renderer:
     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)