From 638f8d33d116be7d100cb9ee17432215bbc99963 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 1 Feb 2016 11:45:01 -0500 Subject: [PATCH] lib/gamnit: divide frame_core_flat in 2 parts to draw particles in between MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/gamnit/depth/depth.nit | 4 +++- lib/gamnit/flat.nit | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) 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 -- 1.7.9.5