gamnit: intro and use indirection to bind the screen framebuffer
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 12 Dec 2017 05:13:41 +0000 (00:13 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 14 Jan 2018 15:22:48 +0000 (10:22 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/depth/shadow.nit
lib/gamnit/dynamic_resolution.nit
lib/gamnit/gamnit.nit

index 75178f5..2bdc3ee 100644 (file)
@@ -112,7 +112,7 @@ redef class App
                end
 
                # Take down, bring back default values
-               glBindFramebuffer(gl_FRAMEBUFFER, shadow_context.screen_framebuffer)
+               bind_screen_framebuffer shadow_context.screen_framebuffer
                glColorMask(true, true, true, true)
        end
 
index c783e97..53a44e8 100644 (file)
@@ -93,7 +93,7 @@ redef class App
 
                if dynamic_resolution_ratio == 1.0 then
                        # Draw directly to the screen framebuffer
-                       glBindFramebuffer(gl_FRAMEBUFFER, screen_framebuffer)
+                       bind_screen_framebuffer screen_framebuffer
                        glViewport(0, 0, display.width, display.height)
                        glClear gl_COLOR_BUFFER_BIT | gl_DEPTH_BUFFER_BIT
 
@@ -125,7 +125,7 @@ redef class App
                var ratio = dynamic_resolution_ratio
                ratio = ratio.clamp(min_dynamic_resolution_ratio, max_dynamic_resolution_ratio)
 
-               glBindFramebuffer(gl_FRAMEBUFFER, screen_framebuffer)
+               bind_screen_framebuffer screen_framebuffer
                glBindBuffer(gl_ARRAY_BUFFER, dynamic_context.buffer_array)
                glViewport(0, 0, display.width, display.height)
                glClear gl_COLOR_BUFFER_BIT | gl_DEPTH_BUFFER_BIT
index 8f60056..05bd122 100644 (file)
@@ -102,3 +102,8 @@ redef class App
        # The framework handles resizing the viewport automatically.
        fun on_resize(display: GamnitDisplay) do end
 end
+
+# Portable indirection to `glBindFramebuffer(gl_FRAMEBUFFER, fbo)`
+#
+# This is implemented differently on iOS.
+fun bind_screen_framebuffer(fbo: Int) do glBindFramebuffer(gl_FRAMEBUFFER, fbo)