2D sprites

Is libsdl suitable for making a simple sprite based game engine? What about
a more elaborate “Command and Conquer” type game engine? I know it can be
done in DirectX but I don’t want to be platform specific. What about OpenGL
for 2D game engines? Thanks.

  • Joel Dudley

Is libsdl suitable for making a simple sprite based game engine? What about
a more elaborate “Command and Conquer” type game engine? I know it can be
done in DirectX but I don’t want to be platform specific. What about OpenGL
for 2D game engines? Thanks.

SDL is used for the Linux version of Kohan: Immortal Sovereigns, which is
a Real Time Strategy game like Command and Conquer.

You can use OpenGL, if you want, but it changes the way you’d go about
writing your engine.

–ryan.

“Ryan C. Gordon” writes:

Is libsdl suitable for making a simple sprite based game engine? What about
a more elaborate “Command and Conquer” type game engine? I know it can be
done in DirectX but I don’t want to be platform specific. What about OpenGL
for 2D game engines? Thanks.
There is a Command & Conquer engine in development using SDL, find it
on the http://libsdl.org/games.php3 page.–
Best Regards / Venlig Hilsen
Rasmus Toftdahl Olesen
halfdan at halfdan.dyndns.org
http://halfdan.dyndns.org

Is libsdl suitable for making a simple sprite based game engine?

Yes, it is indeed.

What
about a more elaborate “Command and Conquer” type game engine?

No problem - SDL should be fast enough for full screen scrolling games on
most targets, even without using OpenGL. (The rest of the game doesn’t
have much to do with SDL anyway - SDL is for graphics, audio, input, and
other system level stuff.)

I know
it can be done in DirectX but I don’t want to be platform specific.

Could be a good idea for portability and testing/debugging reasons, but
I’d guess most people who have used both APIs would agree that the SDL
API is a good motivation in itself. (Not to mention that you can debug
using XFree86/DGA on Linux instead of DirectX fullscreen on Win98…)

What about OpenGL for 2D game engines?

IMHO, you should definitely consider this if you’re interested in
making use of machines with 3D acceleration - the speed-up is tremendous,
especially for higher resolutions on fast accelerators. (Modern PCs
aren’t built for software rendering…) The added blending and
transformation capabilities that come virtually for free (WRT coding as
well as performance), can be seen as an extra bonus.

Of course, you can still use SDL for everything but the actual OpenGL
rendering.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Tuesday 07 August 2001 02:18, Joel Dudley wrote:

David Olofson <david.olofson at reologica.se> writes:

API is a good motivation in itself. (Not to mention that you can debug
using XFree86/DGA on Linux instead of DirectX fullscreen on Win98…)
I apologize if this is offtopic - but could you give more info (howtos, links)
on that XFree86/DGA debugging. Thanks.–
Ed

Uhm, well, not really. The point is just that this configuration is
usually more stable for debugging.

If your program crashes in full screen mode while the screen surface is
locked, you end up with a frozen computer under Win95/98. (WinNT seems to
handle it a little better, although you still have to wait for a good
while before the global lock times out. Not sure about Win2k.)

With a stable XFree86 server on a well supported video card, it would be
very bad luck (or a driver bug) if you ended up with anything worse than
a desktop left in some low resolution mode. Just press ctrl-alt-[±] a
few times to fix that. DGA 2.0 could be somewhat risky I guess, but
OpenGL (GLX/DRI) and all normal X stuff should be totally safe as long as
the drivers are OK.

Even development versions of OpenGL drivers for XFree86 can take more
abuse than DirectX without crashing the system in my experience, but I
might just have had very bad luck with DirectX and/or been very lucky
with XFree86. :slight_smile:

Oh, some @?!?$ program grabbed all X input focus and then froze? (If you
haven’t seen it, it kills both keyboard and mouse input totally. Only
Linux “Magic SysRq” works. For example, RealPlayer 8 can do this if it
blocks on the audio device.) Just do a remote login and kill the nasty
application, and everything’s back to normal! :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Tuesday 07 August 2001 13:14, Ed Sinjiashvili wrote:

David Olofson <david.olofson at reologica.se> writes:

API is a good motivation in itself. (Not to mention that you can
debug using XFree86/DGA on Linux instead of DirectX fullscreen on
Win98…)

I apologize if this is offtopic - but could you give more info (howtos,
links) on that XFree86/DGA debugging. Thanks.

“David Olofson” <david.olofson at reologica.se> wrote

If your program crashes in full screen mode while the
screen surface is locked, you end up with a frozen computer
under Win95/98. (WinNT seems to handle it a little better,
although you still have to wait for a good while before the
global lock times out. Not sure about Win2k.)

i wouldn’t worry about this, i’ve been using SDL on windows
and haven’t had any sort of problems like this, the SDL
parachute always bails me out. if someone does want to
devel on windows and is having problems like this, i’d
recommend running with the “windib” driver while developing.

owell, just letting joel know that this is actually an
option :]

“David Olofson” <david.olofson at reologica.se> wrote

If your program crashes in full screen mode while the
screen surface is locked, you end up with a frozen computer
under Win95/98. (WinNT seems to handle it a little better,
although you still have to wait for a good while before the
global lock times out. Not sure about Win2k.)

i wouldn’t worry about this, i’ve been using SDL on windows
and haven’t had any sort of problems like this, the SDL
parachute always bails me out.

Ah, very nice! Didn’t think about that. :slight_smile:

I was thinking about using DirectX directly, and/or allowing the debugger
to step in when something goes wrong. Some debuggers don’t bother to
check locks and stuff before trying to take over…

if someone does want to
devel on windows and is having problems like this, i’d
recommend running with the “windib” driver while developing.

Which is another good reason to use SDL. (Tried to support fullscreen +
windowed mode with DirectX, not to mention GDI using the same code? heh)

owell, just letting joel know that this is actually an
option :]

With SDL, it’s even an option without the classical DirectX crashes… :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Tuesday 07 August 2001 17:42, Pete Shinners wrote:

> > > What about OpenGL for 2D game engines? > > IMHO, you should *definitely* consider this if you're interested in > making use of machines with 3D acceleration - the speed-up is tremendous, > especially for higher resolutions on fast accelerators. (Modern PCs > aren't built for software rendering...) The added blending and > transformation capabilities that come virtually for free (WRT coding as > well as performance), can be seen as an extra bonus.

Now… are there plans to support this internally (if available) in SDL?

In other words, say on a Linux box you’re running an SDL app. with a lot
of alpha blits. If the machine has an accellerated card, will SDL,
at some point, be able to take advantage of this?

In other words, I’m really comfortable with SDL, and really
uncomfortable with OpenGL. :wink: Both are about a sportable as the other,
but I’m lazy and busy, and don’t do too much true 3D stuff, so SDL is
incredibly more useful. It just can be slow sometimes. :wink:

-bill!On Tue, Aug 07, 2001 at 12:50:49PM +0200, David Olofson wrote:

What about OpenGL for 2D game engines?

IMHO, you should definitely consider this if you’re interested in
making use of machines with 3D acceleration - the speed-up is
tremendous, especially for higher resolutions on fast accelerators.
(Modern PCs aren’t built for software rendering…) The added
blending and transformation capabilities that come virtually for free
(WRT coding as well as performance), can be seen as an extra bonus.

Now… are there plans to support this internally (if available) in
SDL?

In other words, say on a Linux box you’re running an SDL app. with a
lot of alpha blits. If the machine has an accellerated card, will SDL,
at some point, be able to take advantage of this?

I don’t know if there are any plans, but I’m not counting on it. Apart
from anything based on OpenGL having various problems with being
compatible with the SDL 2D API without killing performance, it would lack
virtually all advantages of using OpenGL directly. It would basically be
a performance hack for targets with poor 2D acceleration, but with decent
3D acceleration. Not sure if anyone would consider it worth the effort.

In other words, I’m really comfortable with SDL, and really
uncomfortable with OpenGL. :wink: Both are about a sportable as the
other, but I’m lazy and busy, and don’t do too much true 3D stuff, so
SDL is incredibly more useful. It just can be slow sometimes. :wink:

My approach is to use a higher level API (with transformation support and
stuff, preferably using a coordinate system that’s not bound to the
screen resolution) and then implement that for

* SDL + some 2D software rendering library

as well as

* SDL + OpenGL.

and possibly

* other targets, if there's any point in that.

Unfortunately, my work in that area is progressing very slowly, but I can
send you some early prototype code if you like.

(It’ll be in some version of Project Spitfire, or something based on the
new engine for that game, but I’m planning to get an SDL 2D only version
"playable" before digging into the OpenGL stuff again. Status:

Rendering, SDL:		100%

Rendering, OpenGL:	30%	(Not in the same source tree.)

Control system:		90%	(Collision detection and
				spawning/shooting not implemented.)

Scripting engine:	60%	(OO style, "initializers" with
				inheritance, easy to use "plugin"
				system for application specific
				types, keywords and commands.)

Retro sound fx engine:	100%	(Runs on SDL audio and PC speaker
				under X and Linux console.)

New sound effects:	0%

Music:			0%

Graphics:		10%

Levels:			10%

Intro, highscore etc:	0%

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Tuesday 07 August 2001 19:54, William Kendrick wrote:

On Tue, Aug 07, 2001 at 12:50:49PM +0200, David Olofson wrote: