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

Allegro vs Direct3D vs OpenGL in 2D

Started by VanillaSnake21 Sep 22, 2008 at 4:40 PM 6 replies 7.4k views
Original Post
VanillaSnake21
VanillaSnake21
Hi, I was wonder how the libraries listed compare speed-wise when working with fully 2D scenes? Thanks.
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
Daaark
Daaark
Allegro on Windows is just a wrapper over the old DirectDraw interfaces (unless they have updated it in recent builds). So D3D and GL will give you more speed as you can use all the video card's capabilities such as stretching and blending. But it's not really something to worry about, and it might not even be noticeable, especially at low resolutions.

XNA has a nice 2D sprite setup over Direct3D9 and is easy to use like Allegro. Might be a good starting point for you. You get the benefits of using 3D drawing to simulate 2D with all the added benefits, but without having to set it all up yourself.
VanillaSnake21
VanillaSnake21
Quote:
Original post by Daaark
Allegro on Windows is just a wrapper over the old DirectDraw interfaces (unless they have updated it in recent builds). So D3D and GL will give you more speed as you can use all the video card's capabilities such as stretching and blending. But it's not really something to worry about, and it might not even be noticeable, especially at low resolutions.

XNA has a nice 2D sprite setup over Direct3D9 and is easy to use like Allegro. Might be a good starting point for you. You get the benefits of using 3D drawing to simulate 2D with all the added benefits, but without having to set it all up yourself.


Thanks, I was particularly interested in Allegro since, it has "low level" in it's name, so I though it might be have an advantage over D3D (which I know is already low enough in itself), but apparently not, thanks for the clarification.
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
zedz
zedz
theres also SDL for 2d stuff http://www.libsdl.org/

allegro + SDL will be faster than ogl/d3d for plain 2d stuff done on the CPU.
but if u use ogl/d3d u get hardware acceleration for nice effects eg blending/rotation etc
I believe also SDL uses/ or will ogl for acceleration for its 2d stuff in future
Daaark
Daaark
Quote:
Original post by VanillaSnake21
Thanks, I was particularly interested in Allegro since, it has "low level" in it's name, so I though it might be have an advantage over D3D (which I know is already low enough in itself), but apparently not, thanks for the clarification.
Allegro is an old DOS gaming library written by Shawn Hargreaves in the early ninties. A small community rose around it, and have since shoe-horned it onto every other OS possible.

It creates a window for you with a macro hack and manages it on its own, and it can create a few different video drivers, like directdraw and GDI. But the library has pretty much stalled since 2000, when they started planning for version 5 and it still hasn't gotten off the ground.

It's a lot like DevC++. It technically still works, but it's not really relevant anymore. You should use something more modern.

XNA > Allegro. You can do a lot with just one function call SpriteBatch.Draw().
>It looks pretty good for 2d. ;)
JMNightmare
JMNightmare
Well SFML is better than Allegro if this is a library argument thread (oh wait it is). As for the reality: Direct3D and OpenGL aren't comparable to Allegro. Allegro is a fast 2D sprite based library, the closest to that was DirectDraw which is no longer common place. And textured quads or points are generally much faster, can be rotated/blended/colorized easier, and of course Direct-X and OpenGL have shaders now days. So DirectDraw & SDL & Allegro will have about equal speeds, where as OpenGL and Direct3D will blow the others out of the water (especially in effects) but are about equal speed. As for numbers, I have none, except for my terribly tossed together SDL test versus OpenGL (both using SDL for opening the window et cetera).

[I have a crappy computer and a worse graphics card, if you want to call it that]
SDL - 2,000 Sprites [64x64 32-bit RGB]: 37 frames per 5 seconds (Latest stable release, with the SVN release its actually a bit fast IIRC, about 45)
OpenGL - 2,000 Quads [128x128 32-bit RGB]: 348 frames per 5 seconds (faster if you use display lists, DXT compression, or are a better coder than me =| )
Fiddler
Fiddler
Quote:
Allegro is an old DOS gaming library written by Shawn Hargreaves in the early ninties. A small community rose around it, and have since shoe-horned it onto every other OS possible.

It creates a window for you with a macro hack and manages it on its own, and it can create a few different video drivers, like directdraw and GDI. But the library has pretty much stalled since 2000, when they started planning for version 5 and it still hasn't gotten off the ground.

It's a lot like DevC++. It technically still works, but it's not really relevant anymore. You should use something more modern.

The latest version (4.4) provides both opengl and software drivers and Allegro 5 is on track for a 2009 release and takes care of every single issue you mentioned :) It's a very active project with a large and supportive community (allegro.cc and 200-300 downloads per day).

An interesting fact is that it's author, Shawn Hargreaves, is now employed at Microsoft and is working on XNA.

That said, I'll also join the voices advising to use a managed solution like XNA, OpenTK or SDL.Net. Unless you have a solid reason to stay with unmanaged code, you'll be much more productive with those.
[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]
VanillaSnake21
VanillaSnake21
Thanks for the replies, well basically there is no real evidence that SDL or Allegro are at a speed advantage compared to their 3D counterparts, quiet on the contrary. I didn't want this thread to turn into a X vs Y thread, but apparently it was unavoidable. I'll just stick to D3D. BTW the XNA game video posted by Daaark looks impressive.
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Topic Locked

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

Sign in to reply to this topic.