int main(int argc, char* argv[]) { setupCallbacks(); TextureManager& texManager = TextureManager::instance(); int overlayId = texManager.loadTexture("overlay.png"); Texture *overlay = texManager.getTexture(overlayId); /* Recalc texture coords to make overlay cover whole screen. */ overlay_vertices[1].u = (float)overlay->width/overlay->textureWidth; overlay_vertices[1].v = (float)overlay->height/overlay->textureHeight; int heartVertices; Vertex *heart = ObjLoader::load("heart.obj", &heartVertices); // setup GU void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444); sceGuInit(); sceGuStart(GU_DIRECT, list); sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH); sceGuDepthBuffer(zbp,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(65535,0); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuFrontFace(GU_CW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_TEXTURE_2D); sceGuEnable(GU_CLIP_PLANES); sceGuEnable(GU_BLEND); /* Enable lighting! */ // sceGuEnable(GU_LIGHTING); sceGuEnable(GU_LIGHT0); /* Textures & blending*/ sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuTexScale(1.0f,1.0f); sceGuTexOffset(0.0f,0.0f); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); int val = 0; while (running()) { sceGuStart(GU_DIRECT,list); // clear screen sceGuClearColor(0xffffff); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); /* Lights! */ { ScePspFVector3 lpos = { cosf(val * (GU_PI/180)) * 3.0f, 0, sinf(val * (GU_PI/180)) * 3.0f }; sceGuLight(0, GU_POINTLIGHT, GU_DIFFUSE_AND_SPECULAR, &lpos); sceGuLightColor(0, GU_DIFFUSE, 0xffff00ff); sceGuLightColor(0, GU_SPECULAR, 0xffffffff); sceGuLightAtt(0, 0.0f, 1.0f, 0.0f); sceGuSpecular(12.0f); sceGuAmbient(0x00222222); } sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f); sceGumMatrixMode(GU_VIEW); sceGumLoadIdentity(); sceGumMatrixMode(GU_MODEL); sceGumLoadIdentity(); { ScePspFVector3 pos = { 0, -0.75f, -2.5f }; ScePspFVector3 rot = { 0, val * 0.98f * (GU_PI/180.0f), 0}; sceGumTranslate(&pos); sceGumRotateXYZ(&rot); } /* XXX: THIS HERE IS WHAT DOESN'T RENDER. */ sceGuDisable(GU_TEXTURE_2D); sceGuFrontFace(GU_CCW); sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, heartVertices, 0, heart); sceGuFrontFace(GU_CW); sceGuEnable(GU_TEXTURE_2D); /* XXX: END WHAT DOESN'T RENDER. */ /* The stuff below here renders fine, it's just an overlay image, most of it is transparency. */ sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumOrtho(0, 480, 272, 0, -1, 1); sceGumMatrixMode(GU_MODEL); sceGumLoadIdentity(); /* Setup & draw overlay texture. */ overlay->bind(); sceGumDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,2*3,0,overlay_vertices); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }