I’ve seen many people ask about using OpenGL with 2D games and I felt
compelled to say something. Hopefully this will help some of those people.
One thing I discovered when using OpenGL in 2D games is it isn’t necessary
and it severely limits what you can do in your 2D game. Once you load all of
those images onto the graphics card you cannot read and write pixels. If you
don’t have that capability you can’t have pulsing creatures and weapons
(like Baldurs Gate).
Recently I invented a method of drawing which lets you make use of almost
any effect in software mode without affecting your frame rate.
I call it the Special Surface Method. I’m sure the big companies used it in
the days of yore.
Special Surface Method:
I store all of my animations in ram (or system memory) and use a single
surface (from now I’ll call it S.S. short for special surface) to draw to
the screen.
Each time the animation increments I copy a frame of the animation to the
S.S. with the lighting effect switched on. As this is done once per
animation increment it does not affect the game’s frame rate. From then on I
draw S.S. to the screen using a standard blitter which is plenty fast.
Drawbacks of the Special Surface method:
-
The only effect that needs continual blitting is transparent creatures on
the map. If this is used sparingly you won’t get speed issues. -
You need a S.S. for each creature on the map/level. However with ram in
machines getting so large this is only an issue if you are making an Age of
Empires type game with hundreds of units. One thing to note is only a small
percentage of creatures are visible in these games. So you can share a
limited set of special surfaces among the visible creatures._________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com