So I was trying out SDL_gfx lib and tryed using the rotozoomSurface() Click Here which should've rotated my surface at runtime, but it seems that whenever I do that my surface turns invisible. It doesn't matter if I predefine the rotation or use it at runtime, the same happens, I've tryed using the other rotation functions, still the same. Any info on this?

SDL_Surface* rot = rotozoomSurface(surface[0], 10, 1, 0);
surface[0] = rot;
SDL_FreeSurface(rot);

Later I blit the surface[0] as usual. Note that without the code above the surface blits perfectly.

SDL_FreeSurface(rot);

you cant free the surface before you've even used it, put code after the code where youve already displayed it

What Chris said, also you have to update your surface after you blit.
This:

if( SDL_Flip( screen ) == -1 )
{
    return 1;    
}

updates your screen. You're probably going to want to put it into a loop too.

This was just a small part of the code. I can free the "rot" surface because the "surface[0]" already takes the rotated surface before I delete it. Like I've said, I'm using SDL for quite some time, I know how to blit properly and stuff like that, the thing is that after I use the rotation function on my surface it dissapears.

Oh my mistake, it seems that you were right about freeing the "rot" surface, since the "surface[0]" holds the adress of it later so if I free the "rot" surface, the "surface[0]" can't display anything.
The other thing I noticed that if I use a completely black painted surface and do everything correct, it doesnt't display the surface because it automatically makes the black color transparent, so if anyone has this problem just recolor the surface to some other color.

Anyways, thanks for your help.

The other thing that I need info on is using the rotozoomSurface() function inside my game loop, it seems if i predefine the surface's angle before the loop it rotates correctly, but if I use the function inside the loop and try to update the rotation every time, I get an unhandled exeption or a breakpoint.

OK. Let's see your code.

Nevermind, I've got it to work :) .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.