changeset 609:23b9418e4b2f

Remove generic usage of GL_DRAW_FRAMEBUFFER which was introduced in GL 3.0 with framebuffer_blit.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 21 Dec 2014 18:10:23 +0100
parents 725bd24235a2
children 1b31169dc344
files pytouhou/lib/opengl.pxd pytouhou/ui/opengl/backend.pyx pytouhou/ui/opengl/framebuffer.pyx
diffstat 3 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/lib/opengl.pxd
+++ b/pytouhou/lib/opengl.pxd
@@ -104,7 +104,7 @@ cdef extern from 'epoxy/gl.h' nogil:
 
     ctypedef enum GLenum_framebuffer 'GLenum':
         GL_FRAMEBUFFER
-        GL_DRAW_FRAMEBUFFER
+        GL_READ_FRAMEBUFFER
 
     ctypedef enum GLenum_renderbuffer 'GLenum':
         GL_RENDERBUFFER
--- a/pytouhou/ui/opengl/backend.pyx
+++ b/pytouhou/ui/opengl/backend.pyx
@@ -91,7 +91,7 @@ def create_window(title, x, y, width, he
     sdl.gl_set_attribute(sdl.GL_CONTEXT_PROFILE_MASK, profile)
     sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, major)
     sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, minor)
-    sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24)
+    sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24 if is_legacy else 0)
     if double_buffer >= 0:
         sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, double_buffer)
 
--- a/pytouhou/ui/opengl/framebuffer.pyx
+++ b/pytouhou/ui/opengl/framebuffer.pyx
@@ -27,7 +27,7 @@ from pytouhou.lib.opengl cimport \
           GL_STATIC_DRAW, glGenVertexArrays, glDeleteVertexArrays,
           glBindVertexArray, glVertexAttribPointer, GL_SHORT, GL_FLOAT,
           glEnableVertexAttribArray, glDrawArrays, GL_TRIANGLE_STRIP,
-          glBlitFramebuffer, GL_DRAW_FRAMEBUFFER, glClear, GL_COLOR_BUFFER_BIT,
+          glBlitFramebuffer, GL_READ_FRAMEBUFFER, glClear, GL_COLOR_BUFFER_BIT,
           GL_DEPTH_BUFFER_BIT, glViewport, glBlendFunc, GL_ONE, GL_ZERO)
 
 from .backend cimport use_debug_group, use_vao, use_framebuffer_blit
@@ -118,10 +118,11 @@ cdef class Framebuffer:
         if use_debug_group:
             glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Framebuffer drawing")
 
-        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)
-        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
+        glBindFramebuffer(GL_FRAMEBUFFER, 0)
+        glClear(GL_COLOR_BUFFER_BIT)
 
         if use_framebuffer_blit:
+            glBindFramebuffer(GL_READ_FRAMEBUFFER, self.fbo)
             glBlitFramebuffer(self.x, self.y, self.width, self.height,
                               x, y, x + width, y + height,
                               GL_COLOR_BUFFER_BIT, GL_LINEAR)