Skip to main content
GameDev.net gamedev.net
🔒 Locked

DIRECTDRAW LOOP?

Started by Sagat Sep 25, 2000 at 12:52 AM 1 replies 500+ views
Original Post
Sagat
Sagat
In C++/Win32/DX, full screen exclusive, how should an animation loop appear (no input or logic)? All I have is this: 1. Draw ("blt") images to back buffer 2. Show back buffer 3. Pause What other steps are involved? Ex: Clear, restore, wait for retrace? How/when is this done in DX?
-Sagat
Dark
Dark
Hi,

Animation should be done using a frame timer... this is a timer which runs at the same speed as the frame rate of the animation... Each time this frametimer is called the next image is blitted... You can do this by setting a genral index variable for the current image that you are blitting... just blit that image always with a simple function call and increase its value in the frame timer... this way your animation will run smooth on every computer (refresh rate independant)

NOTE!!: You should not Blit the image in the frame timer function... this will fail because the refresh rate probably is much higher and therefor most of the frames will not be displayed. Just increase the index for the frame and blit the current frame every refresh cycle)

I sure hope this helps, Dark
(Mail me at: mitolah@hotmail.com)

ICQ: 130925152Email: e.j.folkertsma@student.utwente.nl
wise_Guy
wise_Guy
Looks pretty good to me.

You would clear the screen before doing all of that (ie. step 0) BUT if you are filling the screen completely (ie. no gaps, no holes in your backgrounds) then you shouldn't need to!

This is done by blitting the screen using a COLORSRC blit, which basically blits the whole surface a single colour.

        
// set the dwfillcolor field to the desired color

ddbltfx.dwFillColor = color;

//blit

lpdds->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
[/source]
where ddbltfx is a DDBLTFX which is cleared to 0 and with the size value set, and lpdds is your surface to clear

To wait for retrace you can use
[source]
lpdd->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN,0);

where lpdd is you LPDIRECTDRAW pointer.

Not sure what restore is...


wise_guy

Edited by - wise_guy on September 25, 2000 7:30:21 AM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.