From cfef1ca1d2ac46ed4c155c58ddbd8e1489d04a7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Thu, 14 Jan 2016 23:59:27 -0500 Subject: [PATCH] lib/gamnit flat: extract `App::frame_core_draw` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/gamnit/flat.nit | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/gamnit/flat.nit b/lib/gamnit/flat.nit index 4c0b103..24a72c8 100644 --- a/lib/gamnit/flat.nit +++ b/lib/gamnit/flat.nit @@ -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` -- 1.7.9.5