lib/gamnit: divide frame_core_flat in 2 parts to draw particles in between
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 1 Feb 2016 16:45:01 +0000 (11:45 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 2 Feb 2016 14:41:07 +0000 (09:41 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/depth/depth.nit
lib/gamnit/flat.nit

index 9eed0e6..12d0f15 100644 (file)
@@ -56,11 +56,13 @@ redef class App
                        end
                end
 
+               frame_core_world_sprites display
+
                # Toggle writing to the depth buffer for particles effects
                glDepthMask false
                for system in particle_systems do system.draw
                glDepthMask true
 
-               frame_core_flat display
+               frame_core_ui_sprites display
        end
 end
index b598f01..ab433bf 100644 (file)
@@ -184,10 +184,14 @@ redef class App
        end
 
        # Draw the whole screen, all `glDraw...` calls should be executed here
-       protected fun frame_core_draw(display: GamnitDisplay) do frame_core_flat display
+       protected fun frame_core_draw(display: GamnitDisplay)
+       do
+               frame_core_world_sprites display
+               frame_core_ui_sprites display
+       end
 
-       # Draw sprites in `sprites` and `ui_sprites`
-       protected fun frame_core_flat(display: GamnitDisplay)
+       # Draw world sprites from `sprites`
+       protected fun frame_core_world_sprites(display: GamnitDisplay)
        do
                simple_2d_program.use
 
@@ -200,6 +204,17 @@ redef class App
                # World sprites
                simple_2d_program.mvp.uniform world_camera.mvp_matrix
                for sprite in sprites do sprite.draw
+       end
+
+       # Draw UI sprites from `ui_sprites`
+       protected fun frame_core_ui_sprites(display: GamnitDisplay)
+       do
+               simple_2d_program.use
+
+               # Set constant configs
+               simple_2d_program.coord.array_enabled = true
+               simple_2d_program.tex_coord.array_enabled = true
+               simple_2d_program.color.array_enabled = false
 
                # Reset only the depth buffer
                glClear gl_DEPTH_BUFFER_BIT
@@ -227,7 +242,7 @@ redef class App
                var display = display
                assert display != null
                glClear gl_COLOR_BUFFER_BIT
-               frame_core_flat display
+               frame_core_ui_sprites display
                display.flip
 
                ui_sprites.remove splash