SDL_BlitSurface problem

I'm using SDL_BlitSurface to get a single sprite out of a spritesheet. My code is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
SDL_Rect* src = frameRects.at(currentFrame);
if (src == NULL)
	Engine::getInstance().fail("Frame rect is null\n");
		
SDL_Rect dest;
dest.x = t.getPosition().x;
dest.y = t.getPosition().y;
dest.w = src->w;
dest.h = src->h;
		
if (textureSurface == NULL)
	std::cout << "Original is null";
		
if (SDL_BlitSurface(textureSurface, src, subSurf, &dest) != 0)
	Engine::getInstance().fail("Failed to blit\n");
		
SDL_Texture *subTex = SDL_CreateTextureFromSurface(renderer, textureSurface);
if (subTex == NULL)
	Engine::getInstance().fail("Failed to create texture");
		
SDL_RenderCopy(renderer, subTex, NULL, &dest);
	
currentFrame = (currentFrame + 1) % frameRects.size();


I've checked that the src and dest rects are correct, but after the surfaceBlit function, the dest-rect has 0 width and height, and nothing is drawn to the screen. Has anyone else had this problem?
Last edited on
Topic archived. No new replies allowed.