SDL_Texture 编译器未找到

SDL_Texture not found by compiler

所以,我正在尝试为 SDL_RenderCopy() 制作一个包装器,但出于某种原因,我不断收到一个错误 "use of undefined type 'SDL_Texture'"。我链接了所有 SDL2 的库并包含了 headers。这是代码:

void drawImage(Uint32 tex, float x, float y){
    SDL_Rect rec;
    rec.x = x;
    rec.y = y;
    if(vcTextures.size() > tex){ //If the argument is in range
        if(vcTextures[tex] != 0){ //If the index points to an image
            rec.w = vcTextures[tex]->w;
            rec.h = vcTextures[tex]->h;
            SDL_RenderCopy(gvRender, vcTextures[tex], 0, &rec);
        };
    };
};

vcTexturesvector<SDL_Texture*> 类型,用于存储所有加载的纹理的地址,以便在执行结束时便于清理。这是唯一发生这种情况的地方。当我单击显示 "see declaration of 'SDL_Texture'" 的消息时,它会显示声明,因此我知道就文件而言类型存在。

完整的错误信息如下:

1>f:\c++\xyg\xyg_runtime\graphics.cpp(125) : error C2027: use of undefined type 'SDL_Texture'
1>        d:\sdl2\vc\include\sdl_render.h(127) : see declaration of 'SDL_Texture'
1>f:\c++\xyg\xyg_runtime\graphics.cpp(125) : error C2227: left of '->w' must point to class/struct/union/generic type

您不应该直接访问 SDL_Texture 的成员。这是一个 opaque type. I'm pretty sure the documentation doesn't make any mention of members w or h, so I don't know where you got the idea to do that. If you want to get information about the texture, you can use SDL_QueryTexture.

SDL_QueryTexture(vcTextures[tex], nullptr, nullptr, &rec.w, &rec.h);