I made a small program that displays a 3d cube that you can scale on any axis using the arrow keys. Only problem is that im using cleardevice();
for refreshing the cube ( so that there is no "smearing" when scaling the cube ). that works fine its just that every time the cube refreshes using this method the screen goes black for a split second resulting in annoying flickering. Is there a better way of refreshing the screen every time the user changes the cube?
I did actually research this but i wasnt able to find anything suitable (Maybe im just bad at researching but i couldn't find anything for the live of me)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
there are 2 ways to handle this:
Double buffering
I do not use BGI so I stick to their docs. for WinBGIm you can use
- int swapbuffers (void);
On oldstyle BGI use this:
int oldv = getvisualpage( ); int olda = getactivepage( ); setvisualpage(olda); setactivepage(oldv);
use vertical synchronization with monitor
You need to wait for VSync before calling
cleardevice();
. On DOS you can use VGA BIOS or direct VGA/VESA access to obtain the signal. On higher OS you need to use some kind of gfx API or Driver API to get VSync.In both cases consult the documentation for target platform.