WIP: sketching gfx engine design
authorslack <slack@codemaniacs.com>
Thu, 2 Oct 2008 20:20:01 +0000 (22:20 +0200)
committerslack <slack@codemaniacs.com>
Thu, 2 Oct 2008 20:20:01 +0000 (22:20 +0200)
Makefile
game.cc
gfx.cc
gfx.h

index c2b34f7ceed76602423edac1e1d035ef80b9a4f9..83c83f26065070308b59d40ce877a910667caf7c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 TARGET = laz0r
-OBJS = main.o game.o
+OBJS = main.o game.o gfx.o
 
 PSP_FW_VERSION=401
 BUILD_PRX=1
diff --git a/game.cc b/game.cc
index d726e6b53aa99fc3eecfd76ce563d229e3a5a105..a6319468e1fdc95120e597055c655cec4e20006b 100644 (file)
--- a/game.cc
+++ b/game.cc
@@ -2,6 +2,7 @@
 
 int game_main(int argc, char **argv)
 {
+
        while(1)
        {
        }
diff --git a/gfx.cc b/gfx.cc
index e5905cbd7fbc536a972e58f29712cba98543ca02..6d7cf1c28ba0eeaf636edbc9b42df9ae5b620ea1 100644 (file)
--- a/gfx.cc
+++ b/gfx.cc
@@ -6,7 +6,7 @@
 
 void GFX::init()
 {
-       dList = memalign(16, 640);
+       dList = memalign(16, 2048);
        fbp0  = 0;
 
        // Init GU
@@ -32,6 +32,11 @@ void GFX::init()
        sceGuFrontFace( GU_CW );
        sceGuEnable( GU_CULL_FACE );
        sceGuEnable( GU_CLIP_PLANES );
+       
+       // set clear color/depth
+       sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) ); 
+       sceGuClearDepth(0);     
+
     sceGuFinish();
        sceGuSync(0,0);
  
@@ -67,3 +72,20 @@ void update_fps( void )
        pspDebugScreenPrintf( fps_display );
 
 }
+       
+void GFX::perspective(float fov, float aspect, float znear, float zfar)
+{
+       // setup projection matrix
+       sceGumMatrixMode(GU_PROJECTION);
+       sceGumLoadIdentity();
+       sceGumPerspective(fov, aspect, znear, zfar);
+}
+
+void GFX::look_at(ScePspFVector3 *eye, ScePspFVector3 *center, ScePspFVector3 *up)
+{
+       sceGumMatrixMode(GU_VIEW);
+       sceGumLoadIdentity();
+       sceGumLookAt(eye, center, up);
+}
+
+
diff --git a/gfx.h b/gfx.h
index 35ceb15f6e57e6078a893db4e69920a6f1819a5a..97081fca86b2e31a23cb953b4ab1e426cb533a36 100644 (file)
--- a/gfx.h
+++ b/gfx.h
@@ -21,6 +21,9 @@ class GFX: public Singleton<GFX>
        void init();
        void cleanup();
        void update_fps();
+
+       void setup_perspective(float fov, float aspect, float znear, float zfar);
+       void look_at(ScePspFVector3 *eye, ScePspFVector3 *center, ScePspFVector3 *up);
 };
 
 #endif