Moved some sceGu* calls from game.cc to GFX
authorslack <slack@codemaniacs.com>
Thu, 16 Oct 2008 01:17:25 +0000 (03:17 +0200)
committerslack <slack@codemaniacs.com>
Thu, 16 Oct 2008 01:17:25 +0000 (03:17 +0200)
game.cc
gfx.cc
gfx.h

diff --git a/game.cc b/game.cc
index 07365fa76df90ae53d58725cbf8237e9bf5e305c..2ee5c432e6b651fdb16a3baafacc5124c4a90e56 100644 (file)
--- a/game.cc
+++ b/game.cc
@@ -32,10 +32,8 @@ int game_main(int argc, char **argv)
        int i=0;
        while(1)
        {
+               GFX.begin_frame();
                i++;
-               sceGuStart(GU_DIRECT, GFX.display_list);
-               sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
-
                sceGumLoadIdentity();
                sceGumRotateX(0.001f*i);
                sceGumRotateY(0.001f*i);
@@ -46,12 +44,7 @@ int game_main(int argc, char **argv)
                                cube.num_faces*3, cube.indices, cube.vertices);
        
                
-               
-               sceGuFinish();
-               sceGuSync(0,0);
-
-               GFX.update_fps();
-               GFX.swap_buffers();
+               GFX.end_frame();        
        }
 
        GFX.cleanup();
diff --git a/gfx.cc b/gfx.cc
index b562585da5737cd79d4153dcee93865dc0819f45..5bcf1bdac6de4b6e1c8600721fdee5cffa9db8ef 100644 (file)
--- a/gfx.cc
+++ b/gfx.cc
@@ -94,6 +94,21 @@ void Gfx::swap_buffers()
        fbp0=sceGuSwapBuffers();
 }
 
+void Gfx::begin_frame()
+{
+       sceGuStart(GU_DIRECT, GFX.display_list);
+       sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
+}
+
+void Gfx::end_frame()
+{
+       sceGuFinish();
+       sceGuSync(0,0);
+
+       update_fps();
+       swap_buffers();
+}
+
 void Gfx::perspective(float fov, float aspect, float znear, float zfar)
 {
        // setup projection matrix
diff --git a/gfx.h b/gfx.h
index 00d584883b9f67b507405f4881b1b9d68a1f4071..e13ace865944f936857cb2fd3f9da0faaf2dce15 100644 (file)
--- a/gfx.h
+++ b/gfx.h
@@ -25,6 +25,9 @@ class Gfx: public Singleton<Gfx>
        
        void update_fps();
        void swap_buffers();
+       
+       void begin_frame();
+       void end_frame();
 
        // Camera controls;
        void perspective(float fov, float aspect, float znear, float zfar);