From: Alexis Laferrière Date: Fri, 15 Jan 2016 04:59:27 +0000 (-0500) Subject: lib/gamnit flat: extract `App::frame_core_draw` X-Git-Tag: v0.8~14^2~5 X-Git-Url: http://nitlanguage.org lib/gamnit flat: extract `App::frame_core_draw` Signed-off-by: Alexis Laferrière --- 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`