GFX.perspective(75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
- GFX.look_at(0,0,-15, 0,0,0, 0,1,0);
+ ScePspFVector3 camera_pos = {10,0,-50};
+ ScePspFVector3 camera_center = {-40, 0, 40};
+ ScePspFVector3 camera_up = {0, 1, 0};
+ GFX.look_at(&camera_pos, &camera_center, &camera_up);
sceGumMatrixMode(GU_MODEL);
int i=0;
GFX.begin_frame();
i++;
sceGumLoadIdentity();
- sceGumRotateX(0.001f*i);
- sceGumRotateY(0.001f*i);
- sceGumRotateZ(0.001f*i);
+ //sceGumRotateX(-3.14159f/2.0f);
+ //sceGumRotateY(-3.14159f/2.0f);
+ sceGumRotateZ(-3.14159f/2.0f);
sceGuColor(GU_COLOR(1.0f,1.0f,1.0f,0.0f));
GFX.bind_texture(texture);
sceGumDrawArray(GU_TRIANGLES, cube.vtype | GU_TRANSFORM_3D,
// Set Render States
// Enable scissor test, depth test, smooth shading and culling
- sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
- sceGuEnable( GU_SCISSOR_TEST );
- sceGuDepthFunc( GU_GEQUAL );
- sceGuEnable( GU_DEPTH_TEST );
- sceGuShadeModel( GU_SMOOTH );
- sceGuFrontFace( GU_CCW );
- sceGuEnable( GU_CULL_FACE );
- sceGuEnable( GU_CLIP_PLANES );
+ sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
+ sceGuEnable(GU_SCISSOR_TEST);
+ sceGuDepthFunc(GU_GEQUAL);
+ sceGuEnable(GU_DEPTH_TEST);
+ sceGuShadeModel(GU_SMOOTH);
+ sceGuFrontFace(GU_CCW);
+ 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);
// setup texture
- sceGuEnable(GU_TEXTURE_2D); //Enable Texture2D
- sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGB );
- sceGuTexFilter( GU_LINEAR, GU_LINEAR ); // Linear filtering (Good Quality) (NEW)
- sceGuTexScale( 1.0f, 1.0f ); // No scaling
- sceGuTexOffset( 0.0f, 0.0f );
+ sceGuEnable(GU_TEXTURE_2D); //Enable Texture2D
+ sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGB);
+ sceGuTexFilter(GU_LINEAR, GU_LINEAR); // Linear filtering
+ sceGuTexScale(1.0f, 1.0f); // No scaling
+ sceGuTexOffset(0.0f, 0.0f);
sceGuFinish();
sceGuSync(0,0);
// finish
// init fps counter
- sceRtcGetCurrentTick( &fps_tick_last );
+ sceRtcGetCurrentTick(&fps_tick_last);
tick_resolution = sceRtcGetTickResolution();
}
void Gfx::update_fps( void )
{
frames_drawn++;
- sceRtcGetCurrentTick( &fps_tick_now );
+ sceRtcGetCurrentTick(&fps_tick_now);
if( ((fps_tick_now - fps_tick_last)/((float)tick_resolution)) >= 1.0f )
{
fps_tick_last = fps_tick_now;
//sprintf( fps_display, "ticks=%f, FPS: %d", ((double)fps_tick_now/(double)tick_resolution), frames_drawn );
- sprintf( fps_display, "FPS: %d", frames_drawn );
+ sprintf(fps_display, "FPS: %d", frames_drawn);
frames_drawn = 0;
}
- pspDebugScreenSetOffset( (int)fbp0 );
- pspDebugScreenSetXY( 0, 0 );
- pspDebugScreenPrintf( fps_display );
+ pspDebugScreenSetOffset((int)fbp0);
+ pspDebugScreenSetXY(0, 0);
+ pspDebugScreenPrintf(fps_display);
}
sceGumPerspective(fov, aspect, znear, zfar);
}
+void Gfx::look_at(ScePspFVector3 *eye, ScePspFVector3 *center, ScePspFVector3 *up)
+{
+ sceGumMatrixMode(GU_VIEW);
+ sceGumLoadIdentity();
+ sceGumLookAt(eye, center, up);
+}
+
void Gfx::look_at(float eye_x, float eye_y, float eye_z,
float center_x, float center_y, float center_z,
float up_x, float up_y, float up_z)
sceGuTexMode(t.mode, 0, 0, t.swizzled? 1: 0);
sceGuTexImage(0, t.width, t.height, t.width, t.pixels);
}
+
+
size_t Model::vertex_size()
{
size_t result=0;
- if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_8BIT) { printf("GU_TEXTURE_8BIT\n"); result += 2; }
- else if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_16BIT) { printf("GU_TEXTURE_16BIT\n"); result +=4; }
- else if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_32BITF) { printf("GU_TEXTURE_32BITF\n"); result += 8; }
+ if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_8BIT) { result += 2; }
+ else if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_16BIT) { result += 4; }
+ else if ((vtype & GU_TEXTURE_BITS) == GU_TEXTURE_32BITF) { result += 8; }
- if ((vtype & GU_COLOR_BITS) == GU_COLOR_5650) { printf("GU_COLOR_5650\n"); result += 2; }
- else if ((vtype & GU_COLOR_BITS) == GU_COLOR_5551) { printf("GU_COLOR_5551\n"); result += 2; }
- else if ((vtype & GU_COLOR_BITS) == GU_COLOR_4444) { printf("GU_COLOR_4444\n"); result += 2; }
- else if ((vtype & GU_COLOR_BITS) == GU_COLOR_8888) { printf("GU_COLOR_8888\n"); result += 4; }
+ if ((vtype & GU_COLOR_BITS) == GU_COLOR_5650) { result += 2; }
+ else if ((vtype & GU_COLOR_BITS) == GU_COLOR_5551) { result += 2; }
+ else if ((vtype & GU_COLOR_BITS) == GU_COLOR_4444) { result += 2; }
+ else if ((vtype & GU_COLOR_BITS) == GU_COLOR_8888) { result += 4; }
- if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_8BIT) { printf("GU_NORMAL_8BIT\n"); result += 3; }
- else if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_16BIT) { printf("GU_NORMAL_16BIT\n"); result += 6; }
- else if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_32BITF) { printf("GU_NORMAL_32BITF\n"); result += 12; }
+ if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_8BIT) { result += 3; }
+ else if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_16BIT) { result += 6; }
+ else if ((vtype & GU_NORMAL_BITS) == GU_NORMAL_32BITF) { result += 12; }
- if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_8BIT) { printf("GU_VERTEX_8BIT\n"); result += 3; }
- else if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_16BIT) { printf("GU_VERTEX_16BIT\n"); result += 6; }
- else if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_32BITF) { printf("GU_VERTEX_32BITF\n"); result += 12; }
+ if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_8BIT) { result += 3; }
+ else if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_16BIT) { result += 6; }
+ else if ((vtype & GU_VERTEX_BITS) == GU_VERTEX_32BITF) { result += 12; }
return result;
}