Linux framebuffer graphics and VSync

前端 未结 2 566
我寻月下人不归
我寻月下人不归 2021-01-13 22:40

I\'m making a game in C that works on the linux framebuffer. So far I have a red 100x100 square that moves in tandem with the mouse, just like a pointer. I have implemented

2条回答
  •  情深已故
    2021-01-13 23:02

    This isn't the correct way to do double-buffering. You're right to do all the painting on a back-buffer, but then you do a memcpy to transfer the data to the front. A screen refresh could easily happen during the copy.

    To do this properly, you should only have to switch a pointer to the data; not copy the data itself. With the Linux framebuffer device, this is done by having a "virtual" screen that is twice as large as the physical screen, and using an offset variable to set whether you're showing the top or bottom half. You can query the size and set offset using the FBIOGET_VSCREENINFO, FBIOPUT_VSCREENINFO, and FBIOPAN_DISPLAY ioctl calls.

    This page briefly gives some details about this: http://www.ummon.eu/Linux/API/Devices/framebuffer.html

    All the relevant data structures are in the linux/fb.h header file.

提交回复
热议问题