From: Alexis Laferrière Date: Mon, 1 Feb 2016 16:45:01 +0000 (-0500) Subject: lib/gamnit: divide frame_core_flat in 2 parts to draw particles in between X-Git-Url: http://nitlanguage.org lib/gamnit: divide frame_core_flat in 2 parts to draw particles in between Signed-off-by: Alexis Laferrière --- diff --git a/lib/gamnit/depth/depth.nit b/lib/gamnit/depth/depth.nit index 9eed0e6..12d0f15 100644 --- a/lib/gamnit/depth/depth.nit +++ b/lib/gamnit/depth/depth.nit @@ -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 diff --git a/lib/gamnit/flat.nit b/lib/gamnit/flat.nit index b598f01..ab433bf 100644 --- a/lib/gamnit/flat.nit +++ b/lib/gamnit/flat.nit @@ -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