u8* gfxTopRightFramebuffers[2];
u8* gfxBottomFramebuffers[2];
-u8 currentBuffer;
-bool enable3d;
+static u8 currentBuffer;
+static bool enable3d;
+static int doubleBuf = 1;
Handle gspEvent, gspSharedMemHandle;
-GSP_FramebufferFormats topFormat = GSP_BGR8_OES;
-GSP_FramebufferFormats botFormat = GSP_BGR8_OES;
+static GSP_FramebufferFormats topFormat = GSP_BGR8_OES;
+static GSP_FramebufferFormats botFormat = GSP_BGR8_OES;
void gfxSet3D(bool enable)
{
botFormat = format;
}
+void gfxSetDoubleBuffering(bool doubleBuffering) {
+ doubleBuf = doubleBuffering ? 1 : 0; // make sure they're the integer values '1' and '0'
+}
+
static u32 __get_bytes_per_pixel(GSP_FramebufferFormats format) {
switch(format) {
case GSP_RGBA8_OES:
u8* framebufferInfoHeader=gfxSharedMemory+0x200+gfxThreadID*0x80;
if(screen==GFX_BOTTOM)framebufferInfoHeader+=0x40;
GSP_FramebufferInfo* framebufferInfo=(GSP_FramebufferInfo*)&framebufferInfoHeader[0x4];
- framebufferInfoHeader[0x0]^=1;
+ framebufferInfoHeader[0x0]^=doubleBuf;
framebufferInfo[framebufferInfoHeader[0x0]]=(screen==GFX_TOP)?(topFramebufferInfo):(bottomFramebufferInfo);
framebufferInfoHeader[0x1]=1;
}
// Exit event handler
gspExitEventHandler();
- // Free framebuffers (let's pretend linearFree is actually implemented...)
+ // Free framebuffers
linearFree(gfxTopRightFramebuffers[1]);
linearFree(gfxTopRightFramebuffers[0]);
linearFree(gfxBottomFramebuffers[1]);
if(screen==GFX_TOP)
{
if(height)*height=400;
- return (side==GFX_LEFT || !enable3d)?(gfxTopLeftFramebuffers[currentBuffer^1]):(gfxTopRightFramebuffers[currentBuffer^1]);
+ return (side==GFX_LEFT || !enable3d)?(gfxTopLeftFramebuffers[currentBuffer^doubleBuf]):(gfxTopRightFramebuffers[currentBuffer^doubleBuf]);
}else{
if(height)*height=320;
- return gfxBottomFramebuffers[currentBuffer^1];
+ return gfxBottomFramebuffers[currentBuffer^doubleBuf];
}
}
void gfxSwapBuffers()
{
- currentBuffer^=1;
+ currentBuffer^=doubleBuf;
gfxSetFramebufferInfo(GFX_TOP, currentBuffer);
gfxSetFramebufferInfo(GFX_BOTTOM, currentBuffer);
GSPGPU_SetBufferSwap(NULL, GFX_TOP, &topFramebufferInfo);
void gfxSwapBuffersGpu()
{
- currentBuffer^=1;
+ currentBuffer^=doubleBuf;
gfxSetFramebufferInfo(GFX_TOP, currentBuffer);
gfxSetFramebufferInfo(GFX_BOTTOM, currentBuffer);
gfxWriteFramebufferInfo(GFX_TOP);