2D game in C++ with SDL; Options for advanced surface manipulation?

Started by
5 comments, last by J37IB 19 years, 12 months ago
What I need right now is a good way to do advanced manipulations of 2D surfaces in SDL... By advanced manipulations I mean (for the most part) performing rotating, stretching, flipping, tinting, etc on surfaces. Good alpha handling would be a plus, but isn''t a huge part of what I''m doing so it isn''t 100% vital. I have, at various times, tried writing my own functions and methods for handling these activities, mostly with very partial success. It seems silly to spend inordinate amounts of time or effort on this; clearly the proper algorithms are known and used already. I know there are various SDL libs available, but I''m somewhat wary of linking to too many things. It always irritates me to try compiling someone''s game, only to find that I need this or that minor library for some obscure feature. Either I want the code to be part of the binary (IE I need to directly integrate the code or statically link the lib..) or I want it to be something very standard (as standard as SDL itself at least...). My quest thus far seems to indicate that OpenGL would do what I want, but I think I''ll end up dumping alot of code if I switch, which would be mildly annoying. I''ll do it if OpenGL is hands down my best option, but that''s why I''m asking people who know... I really don''t need anything 3D in the broad sense of it, only advanced methods of manipulating 2D surfaces.
Advertisement
If you want to be able to do rotation/tinting in realtime, you can''t use SDL, even the SDL_gfx isn''t fast enough on most PCs. I was in your situation a while ago and I saw so many people looking for something like this I made ZEngine but I am no longer working on it, but instead a successor.

I still would refer you to ZEngine''s code (specifically that in the ZImage class) because it may be a good starting place for you if you plan on using SDL/OGL. It is licensed so that you may do what you wish with it, and consider this explicit permission to take whatever code you want from it.

(PS. if you are interested in what I am working on in place of ZEngine, feel free to email me)
Thanks, I''ll definitely look through it. Doing the stuff real-time would be nice, but most of what I''d like to do right now can be prepared during loading times and transitions, so the speed isn''t vital.
i am in a similar situation. I just converted my basic game codebase over from SDL to OpenGL. It''s taken a lot to learn the OpenGL basics, but it''s worth it just from the little bit that i''ve done.

I''m designing a generic 2D sidescrolling engine. I wanted more effects than i could cram into the game with SDL. OpenGL (with decent hardware) can handle lots of slick FX that SDL would never be able to do in real time. For instance, i programmed a 16-frame animated explosion @ 128x128px. In SDL it''s a pretty decent performance hit (on my Athlon 2500+) if you have a few of them going at once since they are alpha blended. In OpenGL, i''m using textured quads for the effect AND i''m enlarging the quad as the animation proceeds (to make it look like it expands outward). The explosion will cover a quarter of the screen and i can have dozens of them at once on a 1024x768 screen with only a laughable impact on the frame rate.

So if you want lots of blending and rotation/scaling in real time, You will realize real quick that SDL is very limiting on those things. If it''s just regular sprites on lower resolutions, i might be inclined to stick with SDL. Otherwise OpenGL it is! Most people who play games have some kind of sufficient graphics card anyway, so that''s not a big problem.
If you think you might not mind doing it during loading, SDL_gfxis your best choice, it''s not that slow I could use it in limited quantities realtime for rotation on my 2.4ghz P4, but I wouldn''t recommend it at all.
I make MMORPG 2D game and I use SDL as primary graphics library.
I think it's very good. Last time I wanted use fast Alpha Blending and I was wondering why this is so slow on Windows platform.
I looked in sources of sdl and I saw that SDL is using MMX commands to very fast alpha blitting but in Windows it doesn't work becouse SDL compiled in Windows haven't it.
I wrote my own function using MMX to alpha blending and it's very fast.
If anybody want I can give this code but it works only for 16 bit images at now.

Sire Zolthar
www.sigonyth.com
www.zoltharia.com

[edited by - Zolthar on April 21, 2004 9:43:49 AM]
Sire Zoltharwww.ndesert.com
Hmm... assuming hardware may or may not be an issue, what would be best? SDL_gfx or OpenGL? That is, supposing the game uses mostly alpha blending, as well as some scaling and rotation methods?

This topic is closed to new replies.

Advertisement