Jump to content
  • Advertisement
Sign in to follow this  

Transparency w/ Rotation (SDL_gfxDEVPAK)

This topic is 4826 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 recently obtained the SDL_gfx DEVPAK, which by the way I'm enjoying (RobLoach). Though, I -am- having some small troubles with it. First, with the rotations. Is there a way to use rotozoom to rotate a 2d surface about a point (px,py). I've tried creating numerous algorithms to reposition the surface using sin and cos so that it looks like its being rotated about a point, but I can't get anything solid. Second, I would like to know how you guys use the rotate and blit something transparently. Let's say I have a wheel that Im drawing. It's a circle with (255,0,255) as its transparency. (BTW I'm using bmp's at the moment). When I load my images I set its color key to this value and if I just make a call to SDL_BlitSurface(), it blits a surface w/o rotation with transparency... but when I rotate it, rotozoom doesn't see the (255,0,255) as transparent and I get this nice pinkish magenta color around the wheel... ><. Is this only to do with the file format or is there a way to do it. Looking for input. Thx in advance, toXic1337

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the feedback on the devpak....

SDL_gfx appears to not have a function that rotates a SDL_surface at the given coordinates. You could, however, make a new surface and offset the image original image onto the new surface. You then could use the rotozoom function to rotate the surface. It's a bit tricky, but it is possible. As for blitting a rotated surface with transparency, I had trouble with that as well. What you have to do is use the SDL_SetColorKey function on the new rotated surface after you rotate it. If you still have trouble, I'd recommend using the IMG_Load function with PNG images (that also works).

Share this post


Link to post
Share on other sites
Im not really familiar with PNG but would I still have to set the color key on a new surface set by rotozoom or is that all handled? And is it really that simple to just convert right over to another file format.. (ie IMG_Load())

Thx for the info I'll give her a shot

toXic1337

Share this post


Link to post
Share on other sites
Just thought of something. I've been working on your idea about offsetting the src surface and then blitting it to a new surface. And I've come into two scenarios:

1) If I offset the src surface onto a dst surface and then rotate it, wouldn't it clip the src? Like if I had a 30X30 src and I do this:
src.x -= px; <--px equals xpoint to rotate around
src.y -= py; <--py equals ypoint to rotate around
wouldn't I end up with a clipped version of the source in the dest.?

2) If I rotate the src first, then offset it, I end up with the problem of the x and y constantly changing. When I look at a square rotating CC, I see that the left boundary is decreased and the right boundary is increased. Same with top/bottom (respectively). The main thing is that I'm not quite sure what I would do to offset this so say a "wheel" may looked centered on an axle.

I would trial and error instead of asking about things popping in my head, but currently I'm at schoolz0rz. The sucktitude...

toXic1337

Share this post


Link to post
Share on other sites
You could also have something like this to force rotating at a point:
Normal Image:
#####
# #
# o #
# #
#####

New Image:
#####
# o#
# #
# #
#####


Then it would rotate around the bottom left corner of the original picture. As for IMG_Load, it is part of the SDL_image library. Very useful tool.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!