Sign in to follow this  
nicequeenbee

How to rotate text or image using SDL??

Recommended Posts

nicequeenbee    122
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
Rob Loach    1504
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
nicequeenbee    122
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
BradDaBug    913
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
Drew_Benton    1861
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
DeadXorAlive    535
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
Guest Anonymous Poster   
Guest Anonymous Poster
Hi all,
I have added SDL_rotozoom.h and SDL_rotozoom.cpp into my project, but I met mistake when trying to use the function SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth), I can't correct it because it just give a message box and give the mistake of memory.
If I give 0.0 for the parameter angle, it's correct, but it's just correct with the value 0.0. Is there any answer for that

Thank for your help :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this