The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
rotozoomSurface
MrTAToad
Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
Posted: Thu Feb 13, 2014 10:12 pm
I'm having a bit of a problem with this - whilst rotating is okay and has no discernible effect on program speed, scaling is another matter : It slows down the program no end, and only seems to be able to scale in integer values (despite being sent floating-point numbers).
My display code is :
Code:
oid __GLBASIC__::__DRAWSPRITE(int id,int frame,int x,int y,DGNat angle,DGNat scale)
{
SDL_Surface *tempSurface=NULL,*rotSurface=NULL;
SDL_Texture *texture=NULL;
SDL_Rect sourcePos,destPos,pos;
int ax,ay;
if ((id>=0 && id<BOUNDS(sprites,0)) && (frame>=0 && frame<sprites(id).framesAcross*sprites(id).framesDown))
{
if (sprites(id).surface)
{
tempSurface=SDL_CreateRGBSurface(0,sprites(id).width,sprites(id).height,32,0,0,0,255);
if (tempSurface)
{
ax=(int) (frame/sprites(id).framesAcross);
ay=(int) (frame-(ax*sprites(id).framesAcross));
if (SDL_BlitSurface(sprites(id).surface,&sourcePos,tempSurface,&destPos)==0)
{
rotSurface=rotozoomSurface(tempSurface,angle,scale,1.0);
if (rotSurface)
{
texture=SDL_CreateTextureFromSurface(m_mainRenderer,rotSurface);
if (texture)
{
pos.x=x;
pos.y=y;
pos.w=rotSurface->w;
pos.h=rotSurface->h;