• Create Account

### #Actualbd36

Posted 19 March 2012 - 10:35 PM

Im not really sure where to even begin with that so I decided to just try the sdl_gfx to see if I could just get something to run so I can make some progress. I can change it later. However I am having some problems implementing it. My class for image that is being rotated has a SDL_Surface* image that is storing the image that needs to be displayed. In my update() method i am trying to do the follow:
SDL_Surface * rotation= rotozoomSurface(image, 10.0, 1, 1);
image = rotation;
SDL_FreeSurface(rotation);

I know that the problems is in the image=rotation line. I'm fairly certain it is because they are both pointers and thus point to the address in memory of rotation, which is then being assigned to image so they both now point to the same location. That location is then subsequently released. Later when I try to draw to image the memory has been released resulting in the heap corruption error that is thrown. I think that to solve this I need to set image equal to a copy of rotation. However, I do not know how to do that. I am still trying to figure pointers and how they work so if any of the above logic is wrong please let me know. Is this what I need to do/ how do I make a copy?

### #1bd36

Posted 19 March 2012 - 10:34 PM

Im not really sure where to even begin with that so I decided to just try the sdl_gfx to see if I could just get something to run so I can make some progress. I can change it later. However I am having some problems implementing it. My class for image that is being rotated has a SDL_Surface* image that is storing the image that needs to be displayed. In my update() method i am trying to do the follow:
SDL_Surface * rotation= rotozoomSurface(image, 10.0, 1, 1);
image = rotation;
SDL_FreeSurface(rotation);

I know that the problems is in the image=rotation line. I'm fairly certain it is because they are both points the address in memory of rotation is being assigned to image so they both now point to the same location. That location is then subsequently released. Later when I try to draw to image the memory has been released resulting in the heap corruption error that is thrown. I think that to solve this I need to set image equal to a copy of rotation. However I do not know how to do that. I am still trying to figure pointers and how they work so if any of the above logic is wrong please let me know. Is this what I need to do/ how do I make a copy?

PARTNERS