static void psp_free(void *data) { psp1_video_t *psp = (psp1_video_t*)data; if(!(psp) || !(psp->main_dList)) return; sceDisplayWaitVblankStart(); sceGuDisplay(GU_FALSE); sceGuTerm(); if (psp->main_dList) free(psp->main_dList); if (psp->frame_dList) free(psp->frame_dList); if (psp->frame_coords) free(TO_CACHED_PTR(psp->frame_coords)); if (psp->menu.frame_coords) free(TO_CACHED_PTR(psp->menu.frame_coords)); if (psp->menu.dList) free(psp->menu.dList); if (psp->menu.frame) free(psp->menu.frame); free(data); sceKernelDisableSubIntr(PSP_VBLANK_INT, 0); sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT,0); }
extern "C" int main(int argc, char *argv[]) { init(); drawWithIndexOffsets(); sceGuTerm(); return 0; }
void psp_finish(void) { lprintf("psp_finish..\n"); sceGuTerm(); //sceKernelSleepThread(); sceKernelExitGame(); }
extern "C" int main(int argc, char *argv[]) { initDisplay(); draw(); emulatorEmitScreenshot(); sceGuTerm(); return 0; }
void App_Shutdown(void) { // Free Memory free( dList ); free( sceneList ); free( fbp0 ); sceGuTerm(); // Terminating the Graphics System sceKernelExitGame(); }
int dxpGraphicsEnd() { if(!dxpGraphicsData.init)return 0; GUSYNC; sceGuTerm(); vfree(dxpGraphicsData.displaybuffer[0].texvram); vfree(dxpGraphicsData.displaybuffer[1].texvram); vfree(dxpGraphicsData.depthbuffer.texvram); vfree(dxpGraphicsData.depthbuffer.texvram); InitGraph(); return 0; }
void os_fb_end() { if (os_byte_fb == NULL) return; // free(os_byte_fb); os_byte_fb = NULL; sceGuTerm(); sceKernelExitGame(); return 0; // x11_display_close(); }
int main(void) { init(); while (pad_read()) { update(); draw(); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); } sceGuTerm(); return 0; }
int main(int argc, char *argv[]) { int i; init(); for (i = 0; i < 120; ++i) { draw(); } emulatorEmitScreenshot(); sceGuTerm(); return 0; }
extern "C" int main(int argc, char *argv[]) { init(); checkpointNext("Nearest, clamp:"); sceGuStart(GU_DIRECT, list); sceGuTexFilter(GU_NEAREST, GU_NEAREST); sceGuTexWrap(GU_CLAMP, GU_CLAMP); sceGuFinish(); sceGuSync(0, 0); drawInterTransfer(); checkpointNext("Linear, clamp:"); sceGuStart(GU_DIRECT, list); sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuTexWrap(GU_CLAMP, GU_CLAMP); sceGuFinish(); sceGuSync(0, 0); drawInterTransfer(); checkpointNext("Nearest, wrap:"); sceGuStart(GU_DIRECT, list); sceGuTexFilter(GU_NEAREST, GU_NEAREST); sceGuTexWrap(GU_REPEAT, GU_REPEAT); sceGuFinish(); sceGuSync(0, 0); drawInterTransfer(); checkpointNext("Linear, wrap:"); sceGuStart(GU_DIRECT, list); sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuTexWrap(GU_REPEAT, GU_REPEAT); sceGuFinish(); sceGuSync(0, 0); drawInterTransfer(); drawIntraTransfer(); drawUploadTransfer(); sceGuTerm(); return 0; }
int main_thread(SceSize args, void *argp) { FILE *fp; int argc = 1; char *argv[] = {save_argv0}; #ifdef WITH_PSP2D sceGuInit(); #endif Py_Initialize(); PySys_SetPath("ms0:/python"); PySys_SetArgv(argc, argv); fp = fopen("script.py", "r"); if (fp) { PyRun_SimpleFile(fp, "script.py"); fclose(fp); } else { #ifndef DEBUG pspDebugScreenInit(); #endif pspDebugScreenPrintf("Error - could not open script.py\n"); } #ifdef DEBUG sceKernelDelayThreadCB(1e7); #endif Py_Finalize(); #ifdef WITH_PSP2D sceGuTerm(); #endif sceKernelExitGame(); return 0; }
void app() { setupCallbacks(); #ifdef DEBUG pspDebugScreenInit(); #endif sceGuInit(); 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); 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); sceGuClearDepth(65535); sceGuDepthFunc(GU_LEQUAL); sceGuAlphaFunc(GU_GREATER, 0, 255); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_DEPTH_TEST); sceGuEnable(GU_ALPHA_TEST); sceGuEnable(GU_SCISSOR_TEST); sceGuEnable(GU_BLEND); sceGuDisable(GU_CULL_FACE); sceGuDisable(GU_CLIP_PLANES); sceGuDisable(GU_DITHER); sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT); sceGuFinish(); sceGuSync(0, 0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); //g2dInit(); /*tileset_tex = g2dTexLoad((char *) "resources/tilemap.png", G2D_SWIZZLE); outline_tex = g2dTexLoad((char *) "resources/tilemap2.png", G2D_SWIZZLE); text_tex = g2dTexLoad((char *) "resources/ui-font.png", G2D_SWIZZLE); frame_tex = g2dTexLoad((char *) "resources/frame.png", G2D_SWIZZLE);*/ while (running()) { sceGuStart(GU_DIRECT,list); // Clear screen sceGuClearColor(0xff554433); // TODO change to black when everything works sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); // Process and draw a frame //menu.update(); //background.draw(); //menu.draw(); sceGuFinish(); sceGuSync(0,0); // Swap buffers and wait for VSYNC sceDisplayWaitVblankStart(); sceGuSwapBuffers(); } sceGuDisplay(GU_FALSE); sceGuTerm(); sceKernelExitGame(); }
int main(int argc, char* argv[]) { /* Setup Homebutton Callbacks */ setupCallbacks(); sceKernelDcacheWritebackAll(); // setup GU SceCtrlData pad; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_8888,(void*)0,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(0xc350,0x2710); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuFrontFace(GU_CCW); sceGuColor(0xffffffff); sceGuShadeModel(GU_SMOOTH); // sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_CLIP_PLANES); sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(GU_PSM_8888, 0, 0, 0); sceGuTexImage(0, 16, 16, 16, texture); sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); sceGuTexEnvColor(0xffffff); sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuTexWrap(GU_REPEAT, GU_REPEAT); sceGuTexScale(1.0f, 1.0f); sceGuTexOffset(0.0f, 0.0f); sceGuAmbientColor(0xffffffff); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); void* buffer = 0; pspDebugScreenInit(); unsigned int old = 0; unsigned int flags = PSP_CTRL_CIRCLE | PSP_CTRL_CROSS; int tex = 1; while(running()) { sceGuStart(GU_DIRECT,list); sceGuClearColor(0); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumPerspective(90.0f, 480.0/272.0f, 0.1f, 10.0f); sceGumMatrixMode(GU_VIEW); sceGumLoadIdentity(); ScePspFVector3 trans = { 0.0f, 0.0f, -1.8f }; sceGumTranslate(&trans); sceGumMatrixMode(GU_MODEL); sceGumLoadIdentity(); sceGumDrawArray(objects[o].prim, objects[o].flags, objects[o].count, 0, objects[o].data); sceCtrlReadBufferPositive(&pad, 1); if(old != pad.Buttons) { if(pad.Buttons & PSP_CTRL_CROSS) { o++; if(o >= sizeof(objects) / sizeof(Object)) { o = 0; } } if(pad.Buttons & PSP_CTRL_CIRCLE) { tex = !tex; if(tex) { sceGuEnable(GU_TEXTURE_2D); } else { sceGuDisable(GU_TEXTURE_2D); } } } old = pad.Buttons; sceGuFinish(); sceGuSync(0,0); pspDebugScreenSetOffset((int)buffer); pspDebugScreenSetXY(0, 0); pspDebugScreenPrintf("Mode: %s (X to change) Texture: %s (O to change)", objects[o].text, tex ? "on " : "off"); sceDisplayWaitVblankStart(); buffer = sceGuSwapBuffers(); } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char *argv[]) { SceCtrlData pad; int oldButtons = 0; #define SECOND 1000000 #define REPEAT_START (1 * SECOND) #define REPEAT_DELAY (SECOND / 5) struct timeval repeatStart; struct timeval repeatDelay; repeatStart.tv_sec = 0; repeatStart.tv_usec = 0; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; pspDebugScreenInit(); pspDebugScreenPrintf("Press Cross to start the IO Test\n"); while(!done) { sceCtrlReadBufferPositive(&pad, 1); int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons; if (pad.Buttons == oldButtons) { struct timeval now; gettimeofday(&now, NULL); if (repeatStart.tv_sec == 0) { repeatStart.tv_sec = now.tv_sec; repeatStart.tv_usec = now.tv_usec; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; } else { long usec = (now.tv_sec - repeatStart.tv_sec) * SECOND; usec += (now.tv_usec - repeatStart.tv_usec); if (usec >= REPEAT_START) { if (repeatDelay.tv_sec != 0) { usec = (now.tv_sec - repeatDelay.tv_sec) * SECOND; usec += (now.tv_usec - repeatDelay.tv_usec); if (usec >= REPEAT_DELAY) { repeatDelay.tv_sec = 0; } } if (repeatDelay.tv_sec == 0) { buttonDown = pad.Buttons; repeatDelay.tv_sec = now.tv_sec; repeatDelay.tv_usec = now.tv_usec; } } } } else { repeatStart.tv_sec = 0; } if (buttonDown & PSP_CTRL_CROSS) { sceKernelSetCompiledSdkVersion(0x307FFFF); runTest(); sceKernelSetCompiledSdkVersion(0x307FFFF + 1); runTest(); } if (buttonDown & PSP_CTRL_TRIANGLE) { done = 1; } oldButtons = pad.Buttons; } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char *argv[]) { SceCtrlData pad; int oldButtons = 0; #define SECOND 1000000 #define REPEAT_START (1 * SECOND) #define REPEAT_DELAY (SECOND / 5) struct timeval repeatStart; struct timeval repeatDelay; repeatStart.tv_sec = 0; repeatStart.tv_usec = 0; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; logFd = sceIoOpen("compilerPerf.log", PSP_O_WRONLY | PSP_O_CREAT, 0777); pspDebugScreenInit(); pspDebugScreenPrintf("Press Cross to start the Performance Test\n"); pspDebugScreenPrintf("Press Circle to change the CPU Clock\n"); while(!done) { sceCtrlReadBufferPositive(&pad, 1); int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons; if (pad.Buttons == oldButtons) { struct timeval now; gettimeofday(&now, NULL); if (repeatStart.tv_sec == 0) { repeatStart.tv_sec = now.tv_sec; repeatStart.tv_usec = now.tv_usec; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; } else { long usec = (now.tv_sec - repeatStart.tv_sec) * SECOND; usec += (now.tv_usec - repeatStart.tv_usec); if (usec >= REPEAT_START) { if (repeatDelay.tv_sec != 0) { usec = (now.tv_sec - repeatDelay.tv_sec) * SECOND; usec += (now.tv_usec - repeatDelay.tv_usec); if (usec >= REPEAT_DELAY) { repeatDelay.tv_sec = 0; } } if (repeatDelay.tv_sec == 0) { buttonDown = pad.Buttons; repeatDelay.tv_sec = now.tv_sec; repeatDelay.tv_usec = now.tv_usec; } } } } else { repeatStart.tv_sec = 0; } if (buttonDown & PSP_CTRL_CROSS) { runTest(); } if (buttonDown & PSP_CTRL_CIRCLE) { cpuFreq += 111; if (cpuFreq > 333) { cpuFreq = 111; } int result = scePowerSetCpuClockFrequency(cpuFreq); if (result == 0) { pspDebugScreenPrintf("CPU Clock set to %d MHz\n", cpuFreq); } else { pspDebugScreenPrintf("Could not set CPU Clock set to %d MHz\n", cpuFreq); } } if (buttonDown & PSP_CTRL_TRIANGLE) { done = 1; } oldButtons = pad.Buttons; } sceGuTerm(); sceIoClose(logFd); sceKernelExitGame(); return 0; }
int main(int argc, char* argv[]) { setupCallbacks(); // 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(0xc350,0x2710); 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_CLIP_PLANES); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); setupSH(); indicesSH(); // run sample int val = 0; while(running()) { sceGuStart(GU_DIRECT,list); // clear screen sceGuClearColor(0x000000); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // light settings sceGuEnable(GU_LIGHTING); sceGuEnable(GU_LIGHT0); sceGuEnable(GU_LIGHT1); sceGuEnable(GU_LIGHT2); sceGuLightMode(1); { unsigned int i; for (i = 0; i < 3; ++i) { sceGuLight(i,GU_DIRECTIONAL,GU_DIFFUSE_AND_SPECULAR,&lsettings[i].position); sceGuLightColor(i,GU_DIFFUSE,lsettings[i].diffuse); sceGuLightColor(i,GU_SPECULAR,lsettings[i].specular); sceGuLightAtt(i,0.0f,1.0f,0.0f); } sceGuSpecular(12.0f); sceGuAmbient(0x000000); } // setup matrices sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f); sceGumMatrixMode(GU_VIEW); { ScePspFVector3 pos = { 0, 0, -5.0f }; sceGumLoadIdentity(); sceGumTranslate(&pos); } sceGumMatrixMode(GU_MODEL); sceGumLoadIdentity(); { ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) }; sceGumRotateXYZ(&rot); } // setup texture sceGuAmbientColor(0xffffffff); // draw renderSH(parametersSH); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); val++; if ((val%600) == 0) { unsigned int i; for (i = 0; i < 8; ++i) parametersSH[i] = (int)((rand() / ((float)RAND_MAX)) * 6.0f); } } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char* argv[]) { unsigned int i,j; pspDebugScreenInit(); SetupCallbacks(); #ifdef ENABLE_PROFILER // Enable profiling pspDebugProfilerClear(); pspDebugProfilerEnable(); #endif // initialize global context g_context.iterationCount = NUM_VERTEX_BUFFERS * NUM_ITERATIONS; g_context.t = 0; g_context.sint = 0; // initialize torus for (i = 0; i < NUM_SLICES; ++i) { for (j = 0; j < NUM_ROWS; ++j) { float s = i + 0.5f, t = j; float x,y,z; x = (RING_SIZE + RING_RADIUS * cosf(s * ((GU_PI*2)/NUM_SLICES))) * cosf(t * ((GU_PI*2)/NUM_ROWS)); y = (RING_SIZE + RING_RADIUS * cosf(s * ((GU_PI*2)/NUM_SLICES))) * sinf(t * ((GU_PI*2)/NUM_ROWS)); z = RING_RADIUS * sinf(s * ((GU_PI*2)/NUM_SLICES)); torus_vertices[j + i * NUM_ROWS].x = x; torus_vertices[j + i * NUM_ROWS].y = y; torus_vertices[j + i * NUM_ROWS].z = z; } } // initialize torus modifiers for (j = 0; j < NUM_ROWS; ++j) { float t = j; torus_modifiers[j].x = 0; torus_modifiers[j].y = 0; torus_modifiers[j].z = 0.3*cosf( t * 8.0f *((GU_PI*2)/NUM_ROWS) ); } // init GU and set callbacks sceGuInit(); // 0x01 - user callback // 0x04 - 'rendering finished' callback sceGuSetCallback(1, &mySignalHandler); sceGuSetCallback(4, &myFinishHandler); // setup GU sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_8888,(void*)0,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(0xc350,0x2710); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); sceGuAlphaFunc(GU_GREATER,0,0xff); sceGuEnable(GU_ALPHA_TEST); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuFrontFace(GU_CW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_TEXTURE_2D); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // run sample #ifdef USING_SIGNALS sceGuCallMode(1); #endif // generate callable command-list with texture setup { sceGuStart(GU_CALL, smallList1); // setup texture sceGuTexMode(GU_PSM_5551,0,0,0); sceGuTexImage(0,32,32,32,ball_start); // width, height, buffer width, tbp sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA); // NOTE: this enables reads of the alpha-component from the texture, otherwise blend/test won't work sceGuTexFilter(GU_NEAREST,GU_NEAREST); sceGuTexWrap(GU_CLAMP,GU_CLAMP); sceGuTexScale(1,1); sceGuTexOffset(0,0); sceGuAmbientColor(0xffffffff); sceGuFinish(); sceGuSync(0,0); } // generate callable command-list for cube rendering { sceGuStart(GU_CALL, smallList2); // draw cube sceGuDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,cubeVertices); sceGuFinish(); sceGuSync(0,0); } for(;;) { sceGuStart(GU_DIRECT,list); unsigned int i = 0; for( ; i < NUM_VERTEX_BUFFERS; i++ ) g_context.vbuffer[i] = sceGuGetMemory((NUM_SLICES/g_context.iterationCount) * 2 * NUM_ROWS * sizeof(Vertex)); g_context.vertsRendered = 0; // clear screen sceGuClearColor(0x00334455); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup matrices sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f); sceGumMatrixMode(GU_VIEW); sceGumLoadIdentity(); sceGumMatrixMode(GU_MODEL); { ScePspFVector3 pos = {0.0f,0.0f,-3.5f}; ScePspFVector3 rot = {g_context.t * 0.3f * (GU_PI/180.0f), g_context.t * 0.7f * (GU_PI/180.0f), g_context.t * 1.3f * (GU_PI/180.0f)}; sceGumLoadIdentity(); sceGumTranslate(&pos); sceGumRotateXYZ(&rot); } sceGumStoreMatrix(&g_context.world); // call pregenerated command-list to setup texture sceGuCallList(smallList1); // start billboard rendering render_billboards(0); // call pregenerated command-list to render cube { ScePspFVector3 scale = {0.3f, 0.3f, 0.3f}; sceGumScale(&scale); } sceGumUpdateMatrix(); sceGuCallList(smallList2); #ifndef USING_SIGNALS // HACK: sceGuFinish() is called inside the signal interupt handler when all rendering job is done // this is done in order to stall GPU if it is ahead of CPU sceGuFinish(); #endif sceGuSync(0,0); #ifndef ENABLE_FRAMERATE // wait for next frame sceDisplayWaitVblankStart(); #endif sceGuSwapBuffers(); pspDebugScreenSetXY(0,0); #ifdef ENABLE_PROFILER // Print profile information to the screen pspDebugProfilerPrint(); #endif #ifdef ENABLE_FRAMERATE // simple frame rate counter static float curr_ms = 1.0f; static struct timeval time_slices[16]; static int t = 0; float curr_fps = 1.0f / curr_ms; t++; float vertsPerSec = g_context.vertsRendered*curr_fps; float kbPerSec = vertsPerSec * sizeof(Vertex) / 1024.0f; gettimeofday(&time_slices[t & 15],0); pspDebugScreenPrintf("fps: %d.%03d ms: %d vert/s: %dK MB/s: %d.%03d",(int)curr_fps, ((int)(curr_fps*1000.0f)%1000), (int)(curr_ms*1000.0f), (int)(vertsPerSec/1000.0f), (int)(kbPerSec/1024.0f), (int)((1000.0f/1024.0f)*((int)kbPerSec%1024)) ); if (!(t & 15)) { struct timeval last_time = time_slices[0]; unsigned int i; curr_ms = 0; for (i = 1; i < 16; ++i) { struct timeval curr_time = time_slices[i]; int curr_time_usec = curr_time.tv_usec + curr_time.tv_sec * 1000000; int last_time_usec = last_time.tv_usec + last_time.tv_sec * 1000000; if( last_time_usec < curr_time_usec ) curr_ms += (( curr_time_usec - last_time_usec ) * (1.0f/1000000.0f)); last_time = time_slices[i]; } curr_ms /= 15.0f; } #endif } sceGuTerm(); sceKernelExitGame(); return 0; }
extern "C" int main(int argc, char *argv[]) { init(); schedf("framebuf: %08x\n", sceDisplaySetFrameBuf(sceGeEdramGetAddr(), 512, GU_PSM_8888, PSP_DISPLAY_SETBUF_IMMEDIATE)); schedf("dispmode: %08x\n", sceDisplaySetMode(0, 480, 272)); checkpointNext("Common:"); testBlendFunc(" One + Zero", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0x00000000); testBlendFunc(" Zero + One", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_FIX, GU_FIX, 0x00000000, 0xFFFFFFFF); testBlendFunc(" Alpha + Inverse alpha", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0x80808080, 0x80808080); checkpointNext("Doubling:"); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x90808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x40808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x90404040, 0x80808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); checkpointNext("Factors:"); testBlendFunc(" Dest color + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse dest color + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Fix + Zero", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_FIX, 0x90808080, 0x00000000); testBlendFunc(" Zero + Src color", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_SRC_COLOR, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse dest color", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_COLOR, 0x00000000, 0x00000000); testBlendFunc(" Zero + Src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Double src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DOUBLE_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse double src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Double dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DOUBLE_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse double dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DOUBLE_DST_ALPHA, 0x00000000, 0x00000000); checkpointNext("Add:"); testBlendFunc(" F0 + 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" 0F + F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_ADD, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Subtract:"); testBlendFunc(" F0 - 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_SUBTRACT, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" 0F - F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_SUBTRACT, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Reverse subtract:"); testBlendFunc(" Reverse F0 - 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_REVERSE_SUBTRACT, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" Reverse 0F - F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_REVERSE_SUBTRACT, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Min:"); testBlendFunc(" Min 0F, F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_MIN, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Min F0, 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_MIN, GU_FIX, GU_FIX, 0x80808080, 0x80808080); checkpointNext("Max:"); testBlendFunc(" Max 0F, F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_MAX, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Max F0, 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_MAX, GU_FIX, GU_FIX, 0x80808080, 0x80808080); checkpointNext("Absolute difference:"); testBlendFunc(" Abs 0F - F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_ABS, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Abs F0 - 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_ABS, GU_FIX, GU_FIX, 0x80808080, 0x80808080); sceGuTerm(); return 0; }
int main(int argc, char* argv[]) { pspDebugScreenInit(); setupCallbacks(); // 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); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); int val = 0; gettimeofday(&base_time,0); while(running()) { struct Vertex* vertices; struct timeval tv; sceGuStart(GU_DIRECT,list); // clear screen sceGuClearColor(0); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // draw triangle 1 (normal) sceGuColor(0xffffffff); vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex)); vertices[0].x = (SCR_WIDTH/2) + cosf(val * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[0].y = (SCR_HEIGHT/2) + sinf(val * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[0].z = 0; vertices[1].x = (SCR_WIDTH/2) + cosf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[1].y = (SCR_HEIGHT/2) + sinf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[1].z = 0; vertices[2].x = (SCR_WIDTH/2) + cosf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[2].y = (SCR_HEIGHT/2) + sinf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[2].z = 0; sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices); // draw triangle 2 (affected by logic op) sceGuEnable(GU_COLOR_LOGIC_OP); sceGuLogicalOp(curr_state); sceGuColor(0xffff00ff); vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex)); vertices[0].x = (SCR_WIDTH/2) + cosf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[0].y = (SCR_HEIGHT/2) + sinf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[0].z = 0; vertices[1].x = (SCR_WIDTH/2) + cosf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[1].y = (SCR_HEIGHT/2) + sinf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[1].z = 0; vertices[2].x = (SCR_WIDTH/2) + cosf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[2].y = (SCR_HEIGHT/2) + sinf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2); vertices[2].z = 0; sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices); sceGuDisable(GU_COLOR_LOGIC_OP); sceGuFinish(); sceGuSync(0,0); gettimeofday(&tv,0); if ((tv.tv_sec-base_time.tv_sec) > TIME_SLICE) { curr_state = (curr_state + 1) & 15; base_time = tv; } sceDisplayWaitVblankStart(); sceGuSwapBuffers(); pspDebugScreenSetXY(0,0); pspDebugScreenPrintf("%s",names[curr_state]); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char* argv[]) { SetupCallbacks(); // generate geometry genTorus( TORUS_ROWS, TORUS_SLICES, TORUS_RADIUS, TORUS_THICKNESS, torus_vertices, torus_indices ); // flush cache so that no stray data remains sceKernelDcacheWritebackAll(); // setup Edram buffers void* frameBuffer = (void*)0; const void* doubleBuffer = (void*)0x44000; const void* renderTarget = (void*)0x88000; const void* depthBuffer = (void*)0x110000; // setup GU sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_4444,frameBuffer,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)doubleBuffer,BUF_WIDTH); sceGuDepthBuffer((void*)depthBuffer,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(0xc350,0x2710); 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); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // run sample int val = 0; Texture offscreenTexture = { GU_PSM_4444, 0, 128, 128, 128, sceGeEdramGetAddr() + (int)renderTarget }; for(;;) { sceGuStart(GU_DIRECT,list); { sceGuDrawBufferList(GU_PSM_4444,(void*)renderTarget,offscreenTexture.stride); // setup viewport sceGuOffset(2048 - (offscreenTexture.width/2),2048 - (offscreenTexture.height/2)); sceGuViewport(2048,2048,offscreenTexture.width,offscreenTexture.height); // clear screen sceGuClearColor(0xffffffff); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // draw torus to offscreen texture drawTorus( val ); } { // set frame buffer sceGuDrawBufferList(GU_PSM_4444,(void*)frameBuffer,BUF_WIDTH); // setup viewport sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // draw cube using offscreen texture drawCube( &offscreenTexture, val ); } sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); frameBuffer = sceGuSwapBuffers(); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char* argv[]) { SetupCallbacks(); // generate geometry genGrid( GRID_ROWS, GRID_COLUMNS, GRID_SIZE, grid_vertices, grid_indices ); genTorus( TORUS_ROWS, TORUS_SLICES, TORUS_RADIUS, TORUS_THICKNESS, torus_vertices, torus_indices ); // flush cache so that no stray data remains sceKernelDcacheWritebackAll(); // setup VRAM buffers void* frameBuffer = (void*)0; const void* doubleBuffer = (void*)0x44000; const void* renderTarget = (void*)0x88000; const void* depthBuffer = (void*)0x110000; // setup GU sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_4444,frameBuffer,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)doubleBuffer,BUF_WIDTH); sceGuDepthBuffer((void*)depthBuffer,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(0xc350,0x2710); 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_DITHER); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // setup matrices ScePspFMatrix4 identity; ScePspFMatrix4 projection; ScePspFMatrix4 view; gumLoadIdentity(&identity); gumLoadIdentity(&projection); gumPerspective(&projection,75.0f,16.0f/9.0f,0.5f,1000.0f); { ScePspFVector3 pos = {0,0,-5.0f}; gumLoadIdentity(&view); gumTranslate(&view,&pos); } ScePspFMatrix4 textureProjScaleTrans; gumLoadIdentity(&textureProjScaleTrans); textureProjScaleTrans.x.x = 0.5; textureProjScaleTrans.y.y = -0.5; textureProjScaleTrans.w.x = 0.5; textureProjScaleTrans.w.y = 0.5; ScePspFMatrix4 lightProjection; ScePspFMatrix4 lightProjectionInf; ScePspFMatrix4 lightView; ScePspFMatrix4 lightMatrix; gumLoadIdentity(&lightProjection); gumPerspective(&lightProjection,75.0f,1.0f,0.1f,1000.0f); gumLoadIdentity(&lightProjectionInf); gumPerspective(&lightProjectionInf,75.0f,1.0f,0.0f,1000.0f); gumLoadIdentity(&lightView); gumLoadIdentity(&lightMatrix); // define shadowmap Texture shadowmap = { GU_PSM_4444, 0, 128, 128, 128, sceGeEdramGetAddr() + (int)renderTarget }; // define geometry Geometry torus = { identity, sizeof(torus_indices)/sizeof(unsigned short), torus_indices, torus_vertices, 0xffffff }; Geometry grid = { identity, sizeof(grid_indices)/sizeof(unsigned short), grid_indices, grid_vertices, 0xff7777 }; // run sample int val = 0; for(;;) { // update matrices // grid { ScePspFVector3 pos = {0,-1.5f,0}; gumLoadIdentity(&grid.world); gumTranslate(&grid.world,&pos); } // torus { ScePspFVector3 pos = {0,0.5f,0.0f}; ScePspFVector3 rot = {val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f)}; gumLoadIdentity(&torus.world); gumTranslate(&torus.world,&pos); gumRotateXYZ(&torus.world,&rot); } // orbiting light { ScePspFVector3 lightLookAt = { torus.world.w.x, torus.world.w.y, torus.world.w.z }; ScePspFVector3 rot1 = {0,val * 0.79f * (GU_PI/180.0f),0}; ScePspFVector3 rot2 = {-(GU_PI/180.0f)*60.0f,0,0}; ScePspFVector3 pos = {0,0,LIGHT_DISTANCE}; gumLoadIdentity(&lightMatrix); gumTranslate(&lightMatrix,&lightLookAt); gumRotateXYZ(&lightMatrix,&rot1); gumRotateXYZ(&lightMatrix,&rot2); gumTranslate(&lightMatrix,&pos); } gumFastInverse(&lightView,&lightMatrix); // render to shadow map { sceGuStart(GU_DIRECT,list); // set offscreen texture as a render target sceGuDrawBufferList(GU_PSM_4444,(void*)renderTarget,shadowmap.stride); // setup viewport sceGuOffset(2048 - (shadowmap.width/2),2048 - (shadowmap.height/2)); sceGuViewport(2048,2048,shadowmap.width,shadowmap.height); // clear screen sceGuClearColor(0xffffffff); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup view/projection from light sceGuSetMatrix(GU_PROJECTION,&lightProjection); sceGuSetMatrix(GU_VIEW,&lightView); // shadow casters are drawn in black // disable lighting and texturing sceGuDisable(GU_LIGHTING); sceGuDisable(GU_TEXTURE_2D); // draw torus to shadow map drawShadowCaster( &torus ); sceGuFinish(); sceGuSync(0,0); } // render to frame buffer { sceGuStart(GU_DIRECT,list); // set frame buffer sceGuDrawBufferList(GU_PSM_4444,(void*)frameBuffer,BUF_WIDTH); // setup viewport sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup view/projection from camera sceGuSetMatrix(GU_PROJECTION,&projection); sceGuSetMatrix(GU_VIEW,&view); sceGuSetMatrix(GU_MODEL,&identity); // setup a light ScePspFVector3 lightPos = { lightMatrix.w.x, lightMatrix.w.y, lightMatrix.w.z }; ScePspFVector3 lightDir = { lightMatrix.z.x, lightMatrix.z.y, lightMatrix.z.z }; sceGuLight(0,GU_SPOTLIGHT,GU_DIFFUSE,&lightPos); sceGuLightSpot(0,&lightDir, 5.0, 0.6); sceGuLightColor(0,GU_DIFFUSE,0x00ff4040); sceGuLightAtt(0,1.0f,0.0f,0.0f); sceGuAmbient(0x00202020); sceGuEnable(GU_LIGHTING); sceGuEnable(GU_LIGHT0); // draw torus drawGeometry( &torus ); // setup texture projection sceGuTexMapMode( GU_TEXTURE_MATRIX, 0, 0 ); sceGuTexProjMapMode( GU_POSITION ); // set shadowmap as a texture sceGuTexMode(shadowmap.format,0,0,0); sceGuTexImage(shadowmap.mipmap,shadowmap.width,shadowmap.height,shadowmap.stride,shadowmap.data); sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGB); sceGuTexFilter(GU_LINEAR,GU_LINEAR); sceGuTexWrap(GU_CLAMP,GU_CLAMP); sceGuEnable(GU_TEXTURE_2D); // calculate texture projection matrix for shadowmap ScePspFMatrix4 shadowProj; gumMultMatrix(&shadowProj, &lightProjectionInf, &lightView); gumMultMatrix(&shadowProj, &textureProjScaleTrans, &shadowProj); // draw grid receiving shadow drawShadowReceiver( &grid, shadowProj ); sceGuFinish(); sceGuSync(0,0); } sceDisplayWaitVblankStart(); frameBuffer = sceGuSwapBuffers(); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }
void S9xSceGUDeinit () { sceGuDisplay (0); sceGuTerm (); /// ... }
void vidgu_exit() { sceGuTerm(); }
int main_thread(SceSize args, void *argp) { #ifdef DEBUG pspDebugScreenInit(); printf("Free Memory: %u KB\n",sceKernelTotalFreeMemSize()/1024); #else initGraphics(); loadTheme(); background = loadImageFromMemory(images[BACKGROUND].data, images[BACKGROUND].hdr.size); sceKernelFreePartitionMemory(images[BACKGROUND].blockid); images[BACKGROUND].blockid = -1; mask = loadImageFromMemory(images[MASK].data, images[MASK].hdr.size); sceKernelFreePartitionMemory(images[MASK].blockid); images[MASK].blockid = -1; #endif int firstUse = 0; int recovery = 0; int bytesRead = 0; Config cfg; char input[11]; if ((args == 9) && (strcmp(argp, "recovery") == 0)) { recovery = 1; } SceUID fp; fp = sceIoOpen("flash0:/buttons.ini", PSP_O_RDONLY, 0777); if (fp < 0) { #ifdef DEBUG printf("\nflash0:/buttons.ini could not be opned. Assuming first usage."); #endif firstUse = 1; } else { bytesRead = sceIoRead(fp, &cfg, sizeof(cfg)); sceIoClose(fp); if(bytesRead != sizeof(cfg)) { firstUse = 1; } } if (firstUse) { setPassword(); } else if (((args == 0) || (recovery != 0)) || !(cfg.onlyBoot)) { int len; main_password: #ifndef DEBUG footer_pressselect = loadImageFromMemory(images[FOOTER_PRESSSELECT].data, images[FOOTER_PRESSSELECT].hdr.size); title_password = loadImageFromMemory(images[TITLE_PASSWORD].data, images[TITLE_PASSWORD].hdr.size); #endif while(1) { selectEnabled = 1; #ifdef DEBUG printf("\nPress START to accept.\nPress SELECT to change password.\nEnter password: "******"\nPassword OK."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y); msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y); freeImage(msg_passwordok); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(1000*1000); break; } else { #ifdef DEBUG printf("\nIncorrect password."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y); msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y); freeImage(msg_passwordincorrect); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); } } #ifndef DEBUG freeImage(footer_pressselect); freeImage(title_password); #endif if(len == -1) { #ifndef DEBUG footer_changemode = loadImageFromMemory(images[FOOTER_CHANGEMODE].data, images[FOOTER_CHANGEMODE].hdr.size); title_oldpassword = loadImageFromMemory(images[TITLE_OLDPASSWORD].data, images[TITLE_OLDPASSWORD].hdr.size); #endif while(1) { #ifdef DEBUG printf("\nChange password mode.\nEnter old password: "******"\nPassword OK."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y); msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y); freeImage(msg_passwordok); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); break; } else { #ifdef DEBUG printf("\nIncorrect password."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y); msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y); freeImage(msg_passwordincorrect); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); } } #ifndef DEBUG freeImage(footer_changemode); freeImage(title_oldpassword); #endif if(len == -1) { goto main_password; } selectEnabled = 0; setPassword(); } } #ifndef DEBUG freeImage(background); freeImage(mask); sceGuTerm(); int i; for (i = 0; i < NUMFILES; i++) { if (images[i].blockid != -1) { sceKernelFreePartitionMemory(images[i].blockid); } } #endif __psp_free_heap(); #ifdef DEBUG printf("\n__psp_free_heap(): %u KB\n",sceKernelTotalFreeMemSize()/1024); sceKernelDelayThread(3000*1000); #endif #ifdef DEBUG printf("\nLoading loader.prx"); #endif SceUID mod = sceKernelLoadModule("flash0:/loader.prx", 0, NULL); if (mod & 0x80000000) { #ifdef DEBUG printf("\nLoadModule failed 0x%x", mod); #endif } else { SceUID startmod; startmod = sceKernelStartModule(mod, args, argp, NULL, NULL); if (mod != startmod) { #ifdef DEBUG printf("\nStartModule failed 0x%x", startmod); #endif } } return sceKernelExitDeleteThread(0); }
int main(int argc, char *argv[]) { SceCtrlData pad; int oldButtons = 0; #define SECOND 1000000 #define REPEAT_START (1 * SECOND) #define REPEAT_DELAY (SECOND / 5) struct timeval repeatStart; struct timeval repeatDelay; repeatStart.tv_sec = 0; repeatStart.tv_usec = 0; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; pspDebugScreenInit(); pspDebugScreenPrintf("Press Cross to start the Task Scheduler Test\n"); pspDebugScreenPrintf("Press Circle to start the CpuSuspendIntr/CpuResumeIntr Test\n"); pspDebugScreenPrintf("Press Square to start the Task with thread of same priority\n"); pspDebugScreenPrintf("Press Left to start the Task Dispatcher Test\n"); pspDebugScreenPrintf("Press Triangle to Exit\n"); while(!done) { sceCtrlReadBufferPositive(&pad, 1); int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons; if (pad.Buttons == oldButtons) { struct timeval now; gettimeofday(&now, NULL); if (repeatStart.tv_sec == 0) { repeatStart.tv_sec = now.tv_sec; repeatStart.tv_usec = now.tv_usec; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; } else { long usec = (now.tv_sec - repeatStart.tv_sec) * SECOND; usec += (now.tv_usec - repeatStart.tv_usec); if (usec >= REPEAT_START) { if (repeatDelay.tv_sec != 0) { usec = (now.tv_sec - repeatDelay.tv_sec) * SECOND; usec += (now.tv_usec - repeatDelay.tv_usec); if (usec >= REPEAT_DELAY) { repeatDelay.tv_sec = 0; } } if (repeatDelay.tv_sec == 0) { buttonDown = pad.Buttons; repeatDelay.tv_sec = now.tv_sec; repeatDelay.tv_usec = now.tv_usec; } } } } else { repeatStart.tv_sec = 0; } if (buttonDown & PSP_CTRL_CROSS) { SceUID lowThid = sceKernelCreateThread("Low Prio Thread", threadLowPrio, 0x70, 0x1000, 0, 0); SceUID mediumThid = sceKernelCreateThread("Medium Prio Thread", threadMediumPrio, 0x30, 0x1000, 0, 0); SceUID highThid = sceKernelCreateThread("High Prio Thread", threadHighPrio, 0x10, 0x1000, 0, 0); SceUID busyThid = sceKernelCreateThread("Busy Thread", threadBusy, 0x30, 0x1000, 0, 0); testDone = 0; highPrioCounter = 0; mediumPrioCounter = 0; lowPrioCounter = 0; sceKernelStartThread(lowThid, 0, 0); sceKernelStartThread(mediumThid, 0, 0); sceKernelStartThread(busyThid, 0, 0); sceKernelStartThread(highThid, 0, 0); int totalDelay = 5000000; sceKernelDelayThread(totalDelay); testDone = 1; sceKernelWaitThreadEnd(busyThid, NULL); sceKernelWaitThreadEnd(mediumThid, NULL); sceKernelWaitThreadEnd(highThid, NULL); sceKernelWaitThreadEnd(lowThid, NULL); pspDebugScreenPrintf("Counters: high=%d (%d us), medium=%d, low=%d\n", highPrioCounter, (totalDelay / highPrioCounter), mediumPrioCounter, lowPrioCounter); } if (buttonDown & PSP_CTRL_CIRCLE) { msg = buffer; strcpy(msg, ""); SceUID sleepingThid = sceKernelCreateThread("Sleeping Thread", sleepingThread, 0x10, 0x1000, 0, 0); sceKernelStartThread(sleepingThid, 0, 0); sceKernelDelayThread(100000); int intr = sceKernelCpuSuspendIntr(); sceKernelWakeupThread(sleepingThid); strcat(msg, "Main Thread with disabled interrupts\n"); sceKernelCpuResumeIntr(intr); strcat(msg, "Main Thread with enabled interrupts\n"); pspDebugScreenPrintf("%s", msg); } if (buttonDown & PSP_CTRL_SQUARE) { msg = buffer; strcpy(msg, ""); // Two threads having the same priority SceUID thread1 = sceKernelCreateThread("Thread 1", threadPrio_1, sceKernelGetThreadCurrentPriority(), 0x1000, 0, 0); SceUID thread2 = sceKernelCreateThread("Thread 2", threadPrio_2, sceKernelGetThreadCurrentPriority(), 0x1000, 0, 0); // Test that thread1 will be scheduled before thread2 sceKernelStartThread(thread1, 0, 0); sceKernelStartThread(thread2, 0, 0); strcat(msg, "1 "); sceKernelDelayThread(10000); strcat(msg, "4"); sceKernelWaitThreadEnd(thread1, NULL); sceKernelWaitThreadEnd(thread2, NULL); pspDebugScreenPrintf("Starting 2 threads at same priority: %s\n", msg); // Now with a different order for create & start strcpy(msg, ""); SceUID thread3 = sceKernelCreateThread("Thread 3", threadPrio_3, sceKernelGetThreadCurrentPriority(), 0x1000, 0, 0); SceUID thread4 = sceKernelCreateThread("Thread 4", threadPrio_4, sceKernelGetThreadCurrentPriority(), 0x1000, 0, 0); // Test that thread4 will be scheduled before thread3 sceKernelStartThread(thread4, 0, 0); sceKernelStartThread(thread3, 0, 0); strcat(msg, "1 "); sceKernelDelayThread(10000); strcat(msg, "4"); sceKernelWaitThreadEnd(thread3, NULL); sceKernelWaitThreadEnd(thread4, NULL); pspDebugScreenPrintf("Starting 2 threads with a different order create/start: %s\n", msg); } if (buttonDown & PSP_CTRL_LEFT) { msg = buffer; strcpy(msg, ""); int state = sceKernelSuspendDispatchThread(); // High priority thread SceUID thread = sceKernelCreateThread("Thread 1", threadHello, 0x10, 0x1000, 0, 0); strcat(msg, "1 "); // sceKernelStartThread resumes the thread dispatcher sceKernelStartThread(thread, 0, 0); strcat(msg, "2 "); sceKernelDelayThread(10000); strcat(msg, "3 "); sceKernelResumeDispatchThread(state); sceKernelWaitThreadEnd(thread, NULL); pspDebugScreenPrintf("Starting high prio thread with a disabled dispatcher (state=0x%X): %s\n", state, msg); msg = buffer; strcpy(msg, ""); state = sceKernelSuspendDispatchThread(); // Low priority thread thread = sceKernelCreateThread("Thread 1", threadHello, 0x70, 0x1000, 0, 0); strcat(msg, "1 "); // sceKernelStartThread resumes the thread dispatcher sceKernelStartThread(thread, 0, 0); strcat(msg, "2 "); sceKernelDelayThread(10000); strcat(msg, "3 "); sceKernelResumeDispatchThread(state); sceKernelWaitThreadEnd(thread, NULL); pspDebugScreenPrintf("Starting low prio thread with a disabled dispatcher (state=0x%X): %s\n", state, msg); } if (buttonDown & PSP_CTRL_TRIANGLE) { done = 1; } oldButtons = pad.Buttons; } sceGuTerm(); sceKernelExitGame(); return 0; }
void MasterGuRenderer::guShutDown() { sceGuTerm(); }
int main(int argc, char* argv[]) { setupCallbacks(); int i, j; // Load emd mesh from file EMD_MESH* mesh = EMD_LoadMeshFromFile("scene.emd"); int vert_count = EMD_GetVertexCount(mesh); int idx_count = 0; int elem_count = EMD_GetElementCount(mesh); for (i=0; i<elem_count; i++) { idx_count += EMD_GetIndexCount(mesh, i); } VERTEX* vert_buf = (VERTEX*)memalign(16, sizeof(VERTEX) * vert_count); GW_UINT16* idx_buf = (GW_UINT16*)memalign(16, sizeof(GW_UINT16) * idx_count); for (i=0; i<vert_count; i++) { EMD_GetVertexByIndex(mesh, i, &vert_buf[i].x, &vert_buf[i].y, &vert_buf[i].z); EMD_GetTexcoordByIndex(mesh, i, &vert_buf[i].u, &vert_buf[i].v); EMD_GetNormalByIndex(mesh, i, &vert_buf[i].nx, &vert_buf[i].ny, &vert_buf[i].nz); //vert_buf[i].color = 0xffffffff; } GW_UINT32 idx_head = 0; GW_UINT32* data; GW_UINT32 count; // Pack 32-bit index into 16-bit buffer for (i=0; i<elem_count; i++) { count = EMD_GetIndexCount(mesh, i); data = EMD_GetIndexArray(mesh, i); for (j=0; j<count; j++) { idx_buf[j + idx_head] = (GW_UINT16)data[j]; } idx_head += count; } EMD_FreeMesh(mesh); // flush cache so that no stray data remains sceKernelDcacheWritebackAll(); // 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); pspDebugScreenInit(); 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_CCW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); //sceGuDisable(GU_TEXTURE_2D); sceGuEnable(GU_CLIP_PLANES); sceGuEnable(GU_LIGHTING); sceGuEnable(GU_LIGHT0); sceGuEnable(GU_LIGHT1); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // run sample int val = 0; while(running()) { sceGuStart(GU_DIRECT,list); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup lights ScePspFVector3 light_dir = { 1.0f, 1.0f, 1.0f }; // GU_DIRECTIONAL // GU_POINTLIGHT sceGuLight(0, GU_POINTLIGHT, GU_DIFFUSE, &light_dir); sceGuLightColor(0, GU_DIFFUSE, 0xffffffff); sceGuAmbient(0x00202020); light_dir.x = -light_dir.x; light_dir.y = -light_dir.y; light_dir.z = -light_dir.z; sceGuLight(1, GU_DIRECTIONAL, GU_DIFFUSE_AND_SPECULAR, &light_dir); sceGuLightColor(1, GU_DIFFUSE, 0xff7f7f7f); // setup matrices for cube 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, -5.0f }; ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) }; sceGumTranslate(&pos); sceGumRotateXYZ(&rot); } // setup texture //sceGuTexMode(GU_PSM_4444,0,0,0); // sceGuTexImage(0,64,64,64,logo_start); //sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB); //sceGuTexEnvColor(0xffff00); //sceGuTexFilter(GU_LINEAR,GU_LINEAR); //sceGuTexScale(1.0f,1.0f); //sceGuTexOffset(0.0f,0.0f); //sceGuAmbientColor(0xff7f7f7f); // draw cube sceGuColor(0xffffff); sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D, idx_count, idx_buf, vert_buf); pspDebugScreenSetXY(0, 0); pspDebugScreenPrintf("v: %d", vert_count); pspDebugScreenSetXY(0, 1); pspDebugScreenPrintf("i: %d", idx_count); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); val++; } sceGuTerm(); // Release buffers free(vert_buf); free(idx_buf); sceKernelExitGame(); return 0; }
void MFRenderer_DestroyDisplay() { sceGuTerm(); }
int main(int argc, char *argv[]) { SceCtrlData pad; int oldButtons = 0; #define SECOND 1000000 #define REPEAT_START (1 * SECOND) #define REPEAT_DELAY (SECOND / 5) struct timeval repeatStart; struct timeval repeatDelay; int result; int msgCount = 0; repeatStart.tv_sec = 0; repeatStart.tv_usec = 0; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; printHeader(); int receiveThreadId = sceKernelCreateThread("ReceiveMbx", receiveMbxThread, 0x50, 0x1000, 0, 0); sceKernelStartThread(receiveThreadId, 0, 0); while (!done) { sceCtrlReadBufferPositive(&pad, 1); int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons; if (pad.Buttons == oldButtons) { struct timeval now; gettimeofday(&now, NULL); if (repeatStart.tv_sec == 0) { repeatStart.tv_sec = now.tv_sec; repeatStart.tv_usec = now.tv_usec; repeatDelay.tv_sec = 0; repeatDelay.tv_usec = 0; } else { long usec = (now.tv_sec - repeatStart.tv_sec) * SECOND; usec += (now.tv_usec - repeatStart.tv_usec); if (usec >= REPEAT_START) { if (repeatDelay.tv_sec != 0) { usec = (now.tv_sec - repeatDelay.tv_sec) * SECOND; usec += (now.tv_usec - repeatDelay.tv_usec); if (usec >= REPEAT_DELAY) { repeatDelay.tv_sec = 0; } } if (repeatDelay.tv_sec == 0) { buttonDown = pad.Buttons; repeatDelay.tv_sec = now.tv_sec; repeatDelay.tv_usec = now.tv_usec; } } } } else { repeatStart.tv_sec = 0; } if (buttonDown & PSP_CTRL_CROSS) { printHeader(); mbxId = sceKernelCreateMbx("Mbx", 0, NULL); pspDebugScreenPrintf("sceKernelCreateMbx = 0x%08X\n", mbxId); printMbxStatus(mbxId); } if (buttonDown & PSP_CTRL_CIRCLE) { printHeader(); msgCount++; MyMessage *msg = malloc(sizeof(MyMessage)); msg->header.next = (void *) 0x12345678; msg->header.msgPriority = 1; msg->header.dummy[0] = 2; msg->header.dummy[1] = 3; msg->header.dummy[2] = 4; sprintf(msg->text, "Hello %d", msgCount); result = sceKernelSendMbx(mbxId, msg); pspDebugScreenPrintf("sceKernelSendMbx msg=0x%08X, msgCount=%d: 0x%08X\n", (int) msg, msgCount, result); printMbxStatus(mbxId); } if (buttonDown & PSP_CTRL_SQUARE) { printHeader(); printMbxStatus(mbxId); } if (buttonDown & PSP_CTRL_LEFT) { sceKernelWakeupThread(receiveThreadId); printHeader(); } if (buttonDown & PSP_CTRL_TRIANGLE) { done = 1; } oldButtons = pad.Buttons; } sceGuTerm(); sceKernelExitGame(); return 0; }