vwait = set to FALSE to disable frame syncing, defaults to TRUE which waits for vertical blank to finish |
dxFlip will switch the dxFrontBuffer() and dxBackBuffer(). This command should be used when you are using Double Buffering. Double Buffering is a technique used to ensure that screen updates are not visible to the user. If you draw directly to the dxFrontBuffer, the display may appear flickery as the updates are drawn directly to the screen. If you draw to the dxBackBuffer, the updates are drawn in memory. dxFlip is then used to make the dxBackBuffer the dxFrontBuffer, and hence show the updates on screen in one go. At the same time, the dxFrontBuffer becomes the dxBackBuffer, allowing you to draw the next screen update on the dxBackBuffer before Flipping again. The vwait parameter defines whether or not the graphics card will wait for the vertical blank before flipping the screen. The vertical blank is an event that occurs at the frequency of the monitors refresh rate, and corresponds to the point in time when the last dxLine on the screen has been drawn, and the top dxLine is about to be drawn by the monitor. By waiting until the vertical blank, you ensure smooth updates to the screen as the image being drawn by the monitor will change only once the entire screen has been drawn by the monitor, and the screen is just about to start being refreshed. However, it is worth noting that this setting applies to the graphics card only, and some graphics cards allow the user to disable the vertical blank event. Therefore, if you rely on dxFlip alone, the display may be corrupted on certain setups. The VWait command may be useful to you in this respect, as it forces the CPU to wait for the vertical blank (as opposed to the graphics card), and this cannot be disabled. Hence true silky smooth updates are best achieved using "VWait : dxFlip False". See also: dxFrontBuffer, dxBackBuffer, VWait, ScanLine. |
; dxFlip/dxBackBuffer()/dxRect Example ; Set Graphics Mode Graphics 640,480 ; Go double buffering dxSetBuffer dxBackBuffer() ; Setup initial locations for the box box_x = -20 ; negative so it will start OFF screen box_y = 100 While Not dxKeyHit(1) dxCls ; Always clear screen first dxRect box_x,box_y,20,20,1 ; Draw the box in the current x,y location dxFlip ; dxFlip it into view box_x = box_x + 1 ; Move the box over one pixel If box_x = 640 Then box_x=-20 ; If it leaves the Right edge, reset its x location Wend |