Skip to content

Commit

Permalink
ogc: implement double-buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
mardy committed Jan 14, 2024
1 parent 17c4c41 commit eaf7109
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/video/ogc/SDL_ogcvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int OGC_VideoInit(_THIS)

/* Allocate the XFB */
videodata->xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
videodata->xfb[1] = NULL; /* We'll allocate this when double-buffering */
videodata->xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

VIDEO_ClearFrameBuffer(vmode, videodata->xfb[0], COLOR_BLACK);
VIDEO_SetNextFramebuffer(videodata->xfb[0]);
Expand Down Expand Up @@ -172,20 +172,24 @@ void OGC_VideoQuit(_THIS)
void *OGC_video_get_xfb(_THIS)
{
SDL_VideoData *videodata = _this->driverdata;
return videodata->xfb[0];
return videodata->xfb[videodata->fb_index];
}

void OGC_video_flip(_THIS, bool vsync)
{
SDL_VideoData *videodata = _this->driverdata;
void *xfb = OGC_video_get_xfb(_this);
GX_CopyDisp(xfb, GX_TRUE);
GX_DrawDone();
GX_Flush();

VIDEO_SetNextFramebuffer(xfb);
VIDEO_Flush();
if (vsync) {
VIDEO_WaitVSync();
}

videodata->fb_index ^= 1;
}

#endif /* SDL_VIDEO_DRIVER_OGC */
Expand Down
1 change: 1 addition & 0 deletions src/video/ogc/SDL_ogcvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct SDL_VideoData
GXRModeObj *vmode;
u8 *gp_fifo;
void *xfb[2];
u8 fb_index;
} SDL_VideoData;

typedef struct SDL_WindowData
Expand Down

0 comments on commit eaf7109

Please sign in to comment.