Jump to content
  • Advertisement
Sign in to follow this  
coden4fun

SDL.rotateScaledBlit ?

This topic is 3914 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

SDL.rotateScaledBlit(src,dst,x,y,angle,scale) That's the function I'm pretty sure I need to use to rotate any blitted image that is on the surface; however, I have my own Graphics class that has the SDL_Surface* screen set to private, and the Graphics Class only deals with -Loading all type of images -drawing single images -drawing images from sprite sheets -Loading TTF fonts -drawing ttf font text The player's class -loads the tanks -draws the tanks through the Graphics class referencing the draw_sprite function to draw the image from a sprite sheet -moves the tanks -fire ammo from tank -and updates the tanks statistics in the game (i.e. Health, type of ammo, etc..) -the tank image from the sprite sheet is the SDL_Surface* src for the function above it is private and, the SDL_Surface* screen which in the function above is destination is set to private. So i have 2 private objects I need in 2 different classes. How do I use this function? Do I make those 2 private objects public? The function is to rotate the tank around in the game, so i figured I would throw it in the players class. Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
The rotozoom function of SDL_gfx is processor-based and only intended to prerender image rotations. If you want realtime image rotation done by the graphics card, use OpenGL in addition to SDL.

Share this post


Link to post
Share on other sites
If you are to wrap SDL_Surface* into a class, make sure it has all functionality you want or else provide some method to return it's internal pointer, which is pretty much unrecommended.

Quote:
The function is to rotate the tank around in the game, so i figured I would throw it in the players class.

You must rotate the tank's image, don't you?

Share this post


Link to post
Share on other sites
Yes rotate the tanks image which is in the players class as a private SDL_Surface*

So that way I only have to create one class of creating a tank image, having the x, y, w, h velocity for other players, and AI bots

So I must use OpenGL. Does anyone know what specific to use, and how to incorporate that with SDL?

Allegro makes it so much easier. Why must SDL be this complex?

Share this post


Link to post
Share on other sites
SDL is a thin layer and actually is simple to use if you're doing simple things. It's only complex when you want to do things outside its remit!

Share this post


Link to post
Share on other sites
Rotating in SDL isn't complex. You simply wrapped stuff with a graphic class that didn't have what you needed in it and now you are trying to hack your own class.

Real time rotation is not recommended for any blitters, be it SDL or Allegro. You want real time rotation? Do it with something that's hardware accelerated, as OpenGL. If you have only a few rotations to do per frame, then you could surely stick with rotated blitting with no problems.

Share this post


Link to post
Share on other sites
So using OpenGL to rotate something in "realtime" and having this game that I've spent a good 2 weeks making rendering classes, sfx classes, font, special fx text, animation classes, player classes, etc... Am I going to have to mod my own project just enough to

initialize
and draw graphics in OpenGL
and rotate them?

And if so can I still use SDL_image to load graphics, or must I use whatever custom loader there is in OpenGL. I'm not that familiar with OpenGL and I'm not sure if it's like Dx where I can just add the Xinput.lib and call XInput.h and use the xbox360 functions. I assume it is, but I don't want to make an ass out of myself.

I want a complete game engine/framework where I can build one tank game, and then make a couple of other 2d games just to say I can do it.

Thanks

Share this post


Link to post
Share on other sites
SDL supports opening an OpenGL context. You just have to specify that in the flags when you open the screen.

If you have a lot of graphics code already written then you might be better off just precalculating the tank images with rotozoom and storing them in a separate surface array.

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!