Jump to content
  • Advertisement
Sign in to follow this  
nicequeenbee

How to rotate text or image using SDL??

This topic is 4613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Look at the sample programs that come with SDL_gfx

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!