- if(pixels) {
- /* just memcpy to the front buffer */
- if(opt.vsync) {
- wait_vsync();
- }
- drawFps(pixels);
- memcpy(vmem_front, pixels, fbsize);
-
- } else {
- /* attempt page flipping */
- void *next;
-
- drawFps(vmem_back);
- if((next = page_flip(opt.vsync ? FLIP_VBLANK_WAIT : FLIP_NOW))) {
- assert(next == vmem_back);
- vmem_back = vmem_front;
- vmem_front = next;
- } else {
- /* failed to page flip, assume we drew in the front buffer then
- * and just wait for vsync if necessary
- */
- if(opt.vsync) {
- wait_vsync();
- }
- }
- }