wxWidgets vs SDL help

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

wxWidgets vs SDL help

Post by forrestcupp » Thu Jul 23, 2009 2:12 pm

First off, let me say that I know wxWidgets isn't made for game creation.

But I've created a flash card game using only wxWidgets. It's a full screen game with a background image, animations, and lots of sound effects and music. Basically, in each level when you get an answer right, a frog jumps one spot trying to get to his destination. I'm using a timer and preloaded images to animate things, so it should stay pretty accurate with the timing from computer to computer.

It worked great on my two main computers, which are somewhat modern. But I tried it on an older laptop with a 1.6 ghz Turion and something like 384 MB RAM, and it was as slow as molasses. Even though the animations are timer based, they were slooow, and everything based on the timer was slow.

So my question is this. If I ported the whole game to SDL, do you think it would run faster on a less capable machine like that, or would it still be slow? wxWidgets isn't meant for gaming, but is that because it would be easier to program a game in SDL, or because it would actually be more efficient and faster?

I really don't want to go to the trouble of learning SDL and reprogramming the whole thing only to find out it's not any better.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Thu Jul 23, 2009 5:17 pm

It would probably go a bit better, but of course SDL can't do miracles, so a slow computer will remain slow.

Using the graphics card (e.g. with OpenGL) is a major factor in getting a game faster (that is, if the computer it runs on has capable drivers and a decent graphics card)
"Keyboard not detected. Press F1 to continue"
-- Windows

User avatar
doublemax
Moderator
Moderator
Posts: 15069
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Thu Jul 23, 2009 5:59 pm

even if wxWidgets is not made for games, i think for simple 2D animated games it should be fast enough.

I suspect the lack of RAM in your machine to be the reason, check the memory usage of your application and the system while running.

A few performance tips though:
- if you use wxBufferedPaintDC, use a static buffer bitmap for it (so it doesn't have a allocate a new one on each redraw)

- keep all bitmaps you're blitting as wxBitmap, not as wxImage (otherwise they have to be converted each time)

- don't scale bitmaps at redraw time
Use the source, Luke!

forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp » Thu Jul 23, 2009 7:58 pm

For this project, I'm not using opengl. It's just a simple 2D educational game.

I'm already doing everything doublemax said. When the program begins, I initialize all of my images. I load all of the png's from my resources into a wxImage. Then I rescale them, and load each of them into their own wxBitmap that never gets changed. All of that takes place before I ever draw an image onto my wxBufferedPaintDC.

Like doublemax said, I suspect it must be the RAM. That proc should be able to handle something that simple. The game uses 32MB when it is loaded and running.

Basically, I was wondering if SDL will be resource light enough to boost performance on a cruddy old system, or would it be a waste of my time. Maybe I should just leave it how it is and up the system requirements. I hate to have to do that, though.


Edit:

I'm now checking into SFML. It's similar to SDL, but it has a few more features, and it uses opengl under the hood even on 2D stuff. It should speed things up tremendously. It looks easy to use. Does anyone have any experience with SFML?

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Mon Jul 27, 2009 3:01 pm

SFML is not as mature as SDL. And using OpenGL requires an appropriate video processor, so you shoud check if your laptop has one.

Are you invalidating the entire client area on each frame? If you invalidate only the areas that have changed since the last frame you should get better performance as the number of bytes moving around will be smaller.

I don't know much about game development with wxWidgets, but with SDL you can load an image and convert it to the display format (bpp, primary color ordering) which makes blitting it to the screen very fast. I imagine that wxWidgets doesn't do it and images stay with the same format they were read, so each blit has to do pixel conversion which is expensive.

I'd try SDL if I were you. Unless this game will be the last one you write :)

Cheers,

Andre

forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp » Fri Jul 31, 2009 1:06 pm

Thanks for the response.

I actually started working with SFML, and I like it a lot. SFML uses opengl under the hood, but it can limit itself to the computer's limitations. I found out the next major release of SDL will be like this, too.

For a project that is so relatively new, I can't believe how stable and robust SFML is. It's very easy to learn, too. I know SDL is great and popular, but SFML is a viable choice, too.

Right now I'm working on creating a small, barebones GUI toolkit based on SFML to integrate into my SFML games.

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Fri Jul 31, 2009 2:12 pm

I looked at SFML a long time ago when it was first released (in a post to the SDL mailing list :lol:) Maybe it has changed a lot since them, but by that time I think it had some limitations with audio callbacks if memory doesn't fail.

I liked the other aspects of SFML, and rendering with OpenGL is a plus. OpenGL with SDL 1.2 feels like a hack to me so I hope SDL 1.3 doesn't take long.

Good look!

Post Reply