How to rotate text or image using SDL??

Started by
10 comments, last by Spippo 18 years, 4 months ago
I have written a simple program to display text and image on the SDL Screen. Now I want to rotate them in many orientation. So, Is there any simple method to do it?? Thank a lot. If someone know anymethod, can you contact me via my email:thuyptt@dsp.com.vn I am looking forward to hearing from you!!
Advertisement
I believe there is a library called SDL_gfx which can do the trick. Don't expect to use it in real-time, however.
SDL_gfx has a nice little method called rotozoomSurface that rotates a surface as well as optionally enlarges it. Although software rotations are slow, they do work. Just make sure to cache all your rotated surfaces instead of rotating them in realtime.
Rob Loach [Website] [Projects] [Contact]
Hi all,

Thanks so much for your answers. I have downed load SDL_gfx, but I think it is so complex for me to understand. By the way, is rotating an image different to rotating a string on screen. I realized that SDL_gfx just support for rotating an image. Is there another way????


Thanks
How are you rendering the string onto the screen? Are you using something like SDL_ttf?
I like the DARK layout!
Look at the sample programs that come with SDL_gfx
Yes, I rendering text on the screen by using SDL_ttf, I thinks that's good.
You should be able to use SDL_ttf to give you a surface containing whatever text you want, then rotate that surface with SDL_gfx, then blit that surface to the screen.
I like the DARK layout!
Quote:Is there another way?


Other than using the means mentioned above, your only choice left would be to write your own little library to do this, and in the end you will end up with just the same thing as SDL_gfx, so you might as well use that. As was mentioned by Rob, pre-generate everything in the beginning and store that (cache) rather than try to do it in realtime, because your app will take some *major* performance hits. Sure it takes up more memory, but it's well worth the trade-off if possible.
Quote:Original post by nicequeenbee
Hi all,

Thanks so much for your answers. I have downed load SDL_gfx, but I think it is so complex for me to understand. By the way, is rotating an image different to rotating a string on screen. I realized that SDL_gfx just support for rotating an image. Is there another way????


Thanks


It might be far less complicated that it seems at first sight. I mean, even I could get it working.[grin] You just need the SDL_rotozoom part of SDL_gfx, which are three functions iirc, and you might even use only one of those. You could just add the SDL_Rotozoom.c and SDL_rotozoom.h to your project (remove all the references to DLLINTERFACE), no need to build a dll. (Your code becomes LGPL i think, but that might not be such a problem). As for the strings on the screen, those are actually images. SDL_ttf takes strings and converts them to surfaces, so you can use rotozoom for those if you use SDL_ttf.

This topic is closed to new replies.

Advertisement