void ctrAddRectEx(u32 color, s16 x, s16 y, s16 w, s16 h, s16 u, s16 v, s16 uw, s16 vh, float rotate) { if (x >= 400 && w >= 0) { return; } if (y >= 240 && h >= 0) { return; } if (ctrNumVerts + ctrVertStart == MAX_NUM_QUADS) { ctrFlushBatch(); C3D_Flush(); ctrNumVerts = 0; ctrVertStart = 0; } struct ctrUIVertex* vtx = &ctrVertexBuffer[ctrVertStart + ctrNumVerts]; vtx->x = x; vtx->y = y; vtx->w = w; vtx->h = h; vtx->u = u; vtx->v = v; vtx->uw = uw; vtx->vh = vh; vtx->abgr = color; vtx->rotate[0] = cosf(rotate); vtx->rotate[1] = sinf(rotate); ++ctrNumVerts; }
int main() { // Initialize graphics gfxInitDefault(); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); // Initialize the renderbuffer static C3D_RenderBuf rb; C3D_RenderBufInit(&rb, 240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); rb.clearColor = CLEAR_COLOR; C3D_RenderBufClear(&rb); C3D_RenderBufBind(&rb); // Initialize the scene sceneInit(); // Main loop while (aptMainLoop()) { C3D_VideoSync(); hidScanInput(); // Respond to user input u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu // Render the scene sceneRender(); C3D_Flush(); C3D_RenderBufTransfer(&rb, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), DISPLAY_TRANSFER_FLAGS); C3D_RenderBufClear(&rb); } // Deinitialize the scene sceneExit(); // Deinitialize graphics C3D_Fini(); gfxExit(); return 0; }
void ctrFinalize(void) { ctrFlushBatch(); C3D_Flush(); ctrNumVerts = 0; ctrVertStart = 0; }