Surfaces and stuff...

Started by
2 comments, last by IronMan 22 years, 9 months ago
hey,i was wondering how you would go about making a game with multiple graphics. What i mean is,how would you store them on surfaces,would you load all the images on to a backbuffer,and then flip the ones you need?Thanks for any help .............................
.............................
Advertisement
The backbuffer is only a pre-copy of the primary surface (the screen), so whatever you blit to the backbuffer, it will appear on the screen by calling ->flip(). All your graphics should be stored in seperate surfaces which can be in system memory or video memory, then whatever you would like on the screen, you blit them to the backbuffer. See below:

Initialization
* Create the DDraw interface.
* Create the primary surface and its connected backbuffer.
* Load your BMPs to individual surfaces.


Every frame:
* Blit the graphics to the backbuffer
* Flip the backbuffer to the screen.

Destruction:
* Remove the graphics surfaces.
* Remove the backbuffer and primary surface
* Destroy the DDraw interface.

The best way to animate graphics is to create a single bitmap/surface of all your frames for a particular sprite, then specify the source rect in ->BltFast() according to its current frame.

Hope this helps



  Downloads:  ZeroOne Realm

  Downloads:  ZeroOne Realm

yeah,that helped a lot,thanks.But one other thing,wouldnt making a surface for all the images take up a lot of memory?

.............................
.............................
Yes but it doesnt really matter, it also depends on the type of game you are creating.
If you are creating a graphically intensive game such as a Real-Time stragety game you will need around 8-16MB to store the surfaces, though this isnt a problem these days since PCI video cards can use system memory for storing surfaces. So if you have an 8MB video card and 64MB of sys mem, the game will use the 8MB of memory in the video card, and any extra surfaces will be put in system memory.

Also, make sure you limit the size of your surfaces to the screen size, some video cards can handle surfaces larger then the primary buffer, though its better to be safe than sorry.

  Downloads:  ZeroOne Realm

  Downloads:  ZeroOne Realm

This topic is closed to new replies.

Advertisement