Performance with 2D graphics and no OpenGL

Hello,

I am writing a really simple little demo that is entirely 2D, but has a
bunch of sprites that need to be scaled and rotated fairly often. I am
writing it in vanilla SDL without any OpenGL, but now that I am about half
way through I am beginning to worry whether this will affect the performance
of my application too much. Would using OpenGL be a better option in this
case? I am not really looking forward to learning how to figure out all this
stuff in OpenGL and re-write a whole lot of code, so if it is the best
option to use OpenGL if anyone could point me in the right direction to find
some good resources that deal with OpenGL and SDL for 2D applications I
apprecaite it. If, on the other hand, using regular SDL should be okay for
this application, then please let me know. Thank you!

Hey Tom

No point using OpenGL for 2D applications, IMHO. SDL is more than capable, and also there is the SDL_gfx library which can rotate and scale (rotozoom) your surfaces.
Not great for real-time application but just cache the data.

Ed> ----- Original Message -----

From: tdavies@gmail.com (Tom Davies)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Friday, 18 May, 2007 11:29:47 AM
Subject: [SDL] Performance with 2D graphics and no OpenGL

Hello,

I am writing a really simple little demo that is entirely 2D, but has a bunch of sprites that need to be scaled and rotated fairly often. I am writing it in vanilla SDL without any OpenGL, but now that I am about half way through I am beginning to worry whether this will affect the performance of my application too much. Would using OpenGL be a better option in this case? I am not really looking forward to learning how to figure out all this stuff in OpenGL and re-write a whole lot of code, so if it is the best option to use OpenGL if anyone could point me in the right direction to find some good resources that deal with OpenGL and SDL for 2D applications I apprecaite it. If, on the other hand, using regular SDL should be okay for this application, then please let me know. Thank you!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

Thanks for the reply.

What are my options if I want to rotate largish images in real time ? (I
can’t really cache them without taking up a lot of RAM).On 5/18/07, Edward Byard <e_byard at yahoo.co.uk> wrote:

Hey Tom

No point using OpenGL for 2D applications, IMHO. SDL is more than capable,
and also there is the SDL_gfx library which can rotate and scale (rotozoom)
your surfaces.
Not great for real-time application but just cache the data.

Ed

----- Original Message ----
From: Tom Davies <@Tom_Davies>
To: A list for developers using the SDL library. (includes SDL-announce) <
sdl at lists.libsdl.org>
Sent: Friday, 18 May, 2007 11:29:47 AM
Subject: [SDL] Performance with 2D graphics and no OpenGL

Hello,

I am writing a really simple little demo that is entirely 2D, but has a
bunch of sprites that need to be scaled and rotated fairly often. I am
writing it in vanilla SDL without any OpenGL, but now that I am about half
way through I am beginning to worry whether this will affect the performance
of my application too much. Would using OpenGL be a better option in this
case? I am not really looking forward to learning how to figure out all this
stuff in OpenGL and re-write a whole lot of code, so if it is the best
option to use OpenGL if anyone could point me in the right direction to find
some good resources that deal with OpenGL and SDL for 2D applications I
apprecaite it. If, on the other hand, using regular SDL should be okay for
this application, then please let me know. Thank you!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Yahoo! Mail is the world’s favourite email. Don’t settle for less, sign up
for your free account todayhttp://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Opengl would really be better suited to that. Opengl isn’t really all
that difficult, especially when you are using SDL for everything else.
Even just using immediate mode can give decent performance, that has
been my experience anyway.On 5/18/07, Tom Davies wrote:

Thanks for the reply.

What are my options if I want to rotate largish images in real time ? (I
can’t really cache them without taking up a lot of RAM).

Brian <brian.ripoff gmail.com> writes:

Opengl would really be better suited to that. Opengl isn’t really all
that difficult, especially when you are using SDL for everything else.
Even just using immediate mode can give decent performance, that has
been my experience anyway.

Not only is OpenGL better suited to scaling and rotating, there is an OpenGL
function wrapper called hxRender that will correct the non-power-of-two blits
into something that older implementations of OpenGL can handle. The website is
at http://joel.slylabs.com/?q=node/4 .

Perhaps this will be my best option then. I am reading up on tutorials for
OpenGL and SDL, but most seem geared towards 3D applications. If anyone can
point me towards some good resources I would really appreciate it. Thanks!On 5/18/07, Brian <brian.ripoff at gmail.com> wrote:

Opengl would really be better suited to that. Opengl isn’t really all
that difficult, especially when you are using SDL for everything else.
Even just using immediate mode can give decent performance, that has
been my experience anyway.

On 5/18/07, Tom Davies <@Tom_Davies> wrote:

Thanks for the reply.

What are my options if I want to rotate largish images in real time ? (I
can’t really cache them without taking up a lot of RAM).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

El Mi?rcoles 23 Mayo 2007, Tom Davies escribi?:

Perhaps this will be my best option then. I am reading up on tutorials for
OpenGL and SDL, but most seem geared towards 3D applications. If anyone can
point me towards some good resources I would really appreciate it. Thanks!

Basically doing 2D with OpenGL is to pass all the coordinates with the third
value set to zero (z=0) and do the most rotations about the Z axis (however
you can get some nice effects rotating about the X and Y, too). To get rid of
perspective issues, you can set an orthogonal perspective the one you expect
to work with using gluOrtho2D:

http://www.opengl.org/sdk/docs/man/xhtml/gluOrtho2D.xml

So the coordinates you pass match exactly the window coordinates.

Okay, that makes sense. This will also make it a lot easier to handle
scrolling and zooming I assume :)On 5/23/07, Alberto Luaces wrote:

El Mi?rcoles 23 Mayo 2007, Tom Davies escribi?:

Perhaps this will be my best option then. I am reading up on tutorials
for
OpenGL and SDL, but most seem geared towards 3D applications. If anyone
can
point me towards some good resources I would really appreciate it.
Thanks!

Basically doing 2D with OpenGL is to pass all the coordinates with the
third
value set to zero (z=0) and do the most rotations about the Z axis
(however
you can get some nice effects rotating about the X and Y, too). To get rid
of
perspective issues, you can set an orthogonal perspective the one you
expect
to work with using gluOrtho2D:

http://www.opengl.org/sdk/docs/man/xhtml/gluOrtho2D.xml

So the coordinates you pass match exactly the window coordinates.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Tom Davies <tdavies gmail.com> writes:

Okay, that makes sense. This will also make it a lot easier to handle
scrolling and zooming I assume :slight_smile:

For a hint on how to convert it to use screen coordinates instead of cartesian
coordinates and how to turn off the Z-buffering so that blitting polygons won’t
cause fighting on the Z axis, see the source code of hxRender at
http://joel.slylabs.com/?q=node/4 . It’s under the ZLib license so there’s very
little restrictions on its use.