gamnit: intro dynamic resolution support
[nit.git] / lib / gamnit / flat.nit
index 7c2db7e..f6e0fd2 100644 (file)
@@ -41,6 +41,7 @@ import performance_analysis
 
 import gamnit
 import gamnit::cameras
+import gamnit::dynamic_resolution
 import gamnit::limit_fps
 
 import android_two_fingers_motion is conditional(android)
@@ -355,13 +356,16 @@ redef class App
        # Draw the whole screen, all `glDraw...` calls should be executed here
        protected fun frame_core_draw(display: GamnitDisplay)
        do
-               perf_clock_main.lapse
+               frame_core_dynamic_resolution_before display
 
+               perf_clock_main.lapse
                frame_core_world_sprites display
                perfs["gamnit flat world_sprites"].add perf_clock_main.lapse
 
                frame_core_ui_sprites display
                perfs["gamnit flat ui_sprites"].add perf_clock_main.lapse
+
+               frame_core_dynamic_resolution_after display
        end
 
        private fun frame_core_sprites(display: GamnitDisplay, sprite_set: SpriteSet, camera: Camera)
@@ -654,6 +658,7 @@ private class SpriteSet
 
        redef fun add(e)
        do
+               if contexts_items.has(e.context) then return
                map_sprite e
                super
        end
@@ -664,6 +669,12 @@ private class SpriteSet
                if e isa Sprite then unmap_sprite e
        end
 
+       redef fun remove_all(e)
+       do
+               if not has(e) then return
+               remove e
+       end
+
        redef fun clear
        do
                super