Code: Select all
fbp0 = 0;
// Init GU
sceGuInit();
sceGuStart(GU_DIRECT, display_list);
// Set Buffers
sceGuDrawBuffer(GU_PSM_8888, fbp0, BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
sceGuDepthBuffer((void*)0x110000, BUF_WIDTH);
sceGuOffset(2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
sceGuDepthRange(65535, 0);
// 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);
// 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
sceGuTexScale(1.0f, 1.0f); // No scaling
sceGuTexOffset(0.0f, 0.0f);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
// finish
// setup projection matrix
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(fov, aspect, znear, zfar);
// look at
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumLookAt(eye, center, up);
// io
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
Model* model = loadModel();
while(1) {
// begin
sceGuStart(GU_DIRECT, display_list);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// peek
sceCtrlPeekBufferPositive(&pad, 1);
// update x and y
model->position->x = (float) (pad.Lx - 128);
model->position->y = (float) (pad.Ly - 128);
// texture bind
sceGuColor(GU_COLOR(1.0f,1.0f,1.0f,0.0f));
sceGuTexMode(model->texture->mode, 0, 0, 1);
sceGuTexImage(0,
model->texture->width,
model->texture->height,
model->texture->width,
model->texture->pixels);
sceGumMatrixMode(GU_MODEL);
// i should see the model to go left and right, top down, right? why doesn't it work?
sceGumTranslate(model->position));
sceGumLoadMatrix(model->initialTransform));
// draw mesh
sceGumDrawArray(
GU_TRIANGLES,
model->mesh->vtype | GU_TRANSFORM_3D,
model->mesh->nFaces * 3,
model->mesh->indices,
model->mesh->vertices);
// end
sceGuFinish();
sceGuSync(0, 0);
// swap buffers
fbp0 = sceGuSwapBuffers();
}
The model is rendered and the texture also but the translation doesn't seem to work, I'm doing something wrong for sure, can anyone show me what?
Thanks!