lib/gamnit flat: extract `App::frame_core_draw`
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 15 Jan 2016 04:59:27 +0000 (23:59 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 17 Jan 2016 22:50:24 +0000 (17:50 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/flat.nit

index 4c0b103..24a72c8 100644 (file)
@@ -179,24 +179,30 @@ redef class App
                update dt
 
                # Draw and flip screen
+               frame_core_draw display
+               display.flip
+
+               # Check errors
+               gl_error = glGetError
+               assert gl_error == gl_NO_ERROR else print gl_error
+       end
+
+       # Draw sprites in `sprites` and `ui_sprites`
+       protected fun frame_core_draw(display: GamnitDisplay)
+       do
                # TODO optimize this draw to store constant values on the GPU
 
-               ## World sprites
+               # World sprites
                simple_2d_program.use
                simple_2d_program.mvp.uniform world_camera.mvp_matrix
                for sprite in sprites do sprite.draw
 
-               ## Reset only the depth buffer
+               # Reset only the depth buffer
                glClear gl_DEPTH_BUFFER_BIT
 
-               ## UI sprites
+               # UI sprites
                simple_2d_program.mvp.uniform ui_camera.mvp_matrix
                for sprite in ui_sprites do sprite.draw
-               display.flip
-
-               # Check errors
-               gl_error = glGetError
-               assert gl_error == gl_NO_ERROR else print gl_error
        end
 
        # Main method to refine in clients to update game logic and `sprites`