简体   繁体   English

纹理不渲染

[英]Textures don't render

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* . Textures是我制作的类的向量,基本上只包含SDL_Texture*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. 纹理不是NULL ,SDL_Rect的位置在屏幕上,我不确定为什么它们没有显示出来。

//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);

愚蠢的错误:当我使用SDL_Surface我会将SDL_Rect的w和h设置为0,这显然不是SDL_Texture工作SDL_Texture

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM