Hi,
I improved SDL Surface code to allow rotation of a surface. For people
who want surface zoom & rotate, they have to install "SDL-gfx" before
compiling SDL ! It can be found here :
http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/
Thank your A. Schiffler !
My patch use rotozoomSurface instead of zoomSurface to use surface
angle. I also correct source.w and source.h because with zoom > 100% a
part of the surface wasn't displayed !
But my patch isn't perfect. Now I'm thinking about scale < 0 (for
flipping, like set_scale(-1,1) for horizontal flipping).
A question : Am I crazy or rotation and scaling is done on every call of
Surface::draw() ? Can't it be done on set_scale() and set_angle() ???
Ok SDL port doesn't look very fast (normal because most function are
made by software), but it works quite good !
Kenneth: I tried to keep ClanLib coding style.
Bye, Haypo
--- cl_cvs2/Sources/SDL/surface_sdl.cpp 2004-08-24 01:36:59.000000000 +0200
+++ cl_cvs/Sources/SDL/surface_sdl.cpp 2004-09-20 20:47:30.000000000 +0200
@@ -264,7 +264,9 @@
static_cast<Sint16>(t_params1->destHeight)
};
- if (t_params1->destWidth == params2->srcWidth && t_params1->destHeight == params2->srcHeight)
+ if ((t_params1->destWidth == params2->srcWidth)
+ && (t_params1->destHeight == params2->srcHeight)
+ && (params2->rotate_angle == 0))
{
if(surface->format->BitsPerPixel > 8)
{
@@ -276,13 +278,18 @@
else
{
#ifdef HAVE_LIBSDL_GFX
- SDL_Surface *zoom = zoomSurface (surface, t_params1->destWidth/params2->srcWidth, t_params1->destHeight/params2->srcHeight, SMOOTHING_ON);
+ source.w = dst.w;
+ source.h = dst.h;
+
+ float angle=params2->rotate_angle*180/M_PI;
+ SDL_Surface *zoom = rotozoomSurface (surface, angle, params2->scale_x, SMOOTHING_ON);
if(zoom->format->BitsPerPixel > 8)
{