Reputation: 49
I have the following code in which I'm attempting to render first a background, then some items on top of them. The only thing that comes out is the background.
Textures is a vector of a class I made, which basically just holds an SDL_Texture*
and an SDL_Rect*
. The textures aren't NULL
, the SDL_Rect positioning is on the screen, I'm not sure why they aren't showing up.
//Clear screen
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, background, NULL, NULL); //Render background
for (auto texture : textures) {
if (texture.getXPos() && texture.getYPos()) { //Position, if applicable
SDL_RenderCopy(renderer, texture.getTexture(), NULL, texture.getRect());
}
else {
SDL_RenderCopy(renderer, texture.getTexture(), NULL, NULL);
}
}
//Update screen
SDL_RenderPresent(renderer);
Upvotes: 0
Views: 75
Reputation: 49
Stupid error: When I was using SDL_Surface
I would set the w and h of the SDL_Rect
to 0, which evidently isn't how it's supposed to work with SDL_Texture
.
Upvotes: 1