SDL_RenderCopy() memory leak

"myteon" <[email protected]>
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
Hello,

I see a spike in memory usage, about 1.5M, every time SDL_RenderCopy is called. I was wondering, what I am doing wrong?

The code for loading textures into memory:


Code:
void Textures::loadSprites(SDL_Renderer* render)
{
	surfaceRender = IMG_Load(("Images\\suits.xcf"));
	format = surfaceRender->format;
	SDL_SetColorKey(surfaceRender, true, SDL_MapRGB(format, 255, 0, 255));
	textures.push_back((SDL_CreateTextureFromSurface(render, surfaceRender)));
	surfaceRender = IMG_Load(("Images\\arrows.xcf"));
	format = surfaceRender->format;
	SDL_SetColorKey(surfaceRender, true, SDL_MapRGB(format, 255, 0, 255));
	textures.push_back((SDL_CreateTextureFromSurface(render, surfaceRender)));
	SDL_FreeSurface(surfaceRender);
}  



How each object keeps track of which texture and which part of the texture it needs to render:

Code:
class RenderData
{
	SDL_Texture* myTexture;
	SDL_Rect* myRenderRect;
......
};


How an object passes its data to the tool object for rendering

Code:
void Card::render()
{
	SDL_Rect rec = { 40, 40, 40, 40 };
	tool->render(&myPos, myRenderData->getMyRenderRect(), myRenderData->getMyTexture(), false);
	tool->textTool->renderText(std::to_string(cardIdent.value), myPos.xCoord, myPos.yCoord, tool->camera.get(),
	&rec, tool->getgRender());
	// testing code
	//tool->renderCoordMarker(myPos.xCoord, myPos.yCoord); 
	//tool->renderRenderBoxOutline(myPos, myRenderData->getMyRenderRect()->w, myRenderData->getMyRenderRect()->h);
}


And lastly the actual call to SDL_RenderCopy and where the leak is occurring:

Code:
void SDLToolBox::render(Coordinate* myCoord, SDL_Rect* myRect, SDL_Texture* myTexture, bool flip)
{
		renderQ = { (myCoord->xCoord - camera->getViewPortX()) / camera->getZoom(), 
					(myCoord->yCoord - camera->getViewPortY()) / camera->getZoom(),
					(myRect->w) / camera->getZoom(), (myRect->h) / camera->getZoom() };
		if (flip)
			SDL_RenderCopyEx(gRender, myTexture, myRect, &renderQ, 0, NULL, SDL_FLIP_HORIZONTAL);
		else
			SDL_RenderCopy(gRender, myTexture, myRect, &renderQ);
}



If any clarifications on my part are needed I'll be back in about 8 hours.
Thank you for your time and input.

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.