Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to rotate text or image using SDL??


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 nicequeenbee   Members   -  Reputation: 122

Like
0Likes
Like

Posted 27 November 2005 - 08:56 PM

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

Sponsor:

#2 Kylotan   Moderators   -  Reputation: 3338

Like
0Likes
Like

Posted 28 November 2005 - 02:10 AM

I believe there is a library called SDL_gfx which can do the trick. Don't expect to use it in real-time, however.

#3 Rob Loach   Moderators   -  Reputation: 1500

Like
0Likes
Like

Posted 28 November 2005 - 03:33 AM

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]

#4 nicequeenbee   Members   -  Reputation: 122

Like
0Likes
Like

Posted 28 November 2005 - 12:53 PM

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

#5 BradDaBug   Members   -  Reputation: 893

Like
0Likes
Like

Posted 28 November 2005 - 01:11 PM

How are you rendering the string onto the screen? Are you using something like SDL_ttf?

#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 28 November 2005 - 03:50 PM

Look at the sample programs that come with SDL_gfx

#7 nicequeenbee   Members   -  Reputation: 122

Like
0Likes
Like

Posted 28 November 2005 - 03:54 PM

Yes, I rendering text on the screen by using SDL_ttf, I thinks that's good.

#8 BradDaBug   Members   -  Reputation: 893

Like
0Likes
Like

Posted 28 November 2005 - 04:43 PM

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.

#9 Drew_Benton   Crossbones+   -  Reputation: 1713

Like
0Likes
Like

Posted 28 November 2005 - 04:47 PM

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.

#10 DeadXorAlive   Members   -  Reputation: 535

Like
0Likes
Like

Posted 29 November 2005 - 08:48 AM

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.


#11 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 30 November 2005 - 12:20 AM

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 :)

#12 Spippo   Members   -  Reputation: 158

Like
0Likes
Like

Posted 01 December 2005 - 12:03 AM

How about:

SDL_Surface *image;
rotozoomSurface(image, double angle, double zoom, int smooth);




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS