[英]SDL_Texture not found by compiler
因此,我试图为SDL_RenderCopy()
包装,并且由于某种原因,我不断收到一条错误消息,指出“使用未定义的类型'SDL_Texture'”。 我已链接了所有SDL2的库并包含标头。 这是代码:
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);
};
};
};
vcTextures
类型为vector<SDL_Texture*>
用于存储所有已加载纹理的地址,以便在执行结束时轻松清除。 这是唯一发生这种情况的地方。 当我单击“查看'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的成员。 它是不透明的类型 。 我很确定文档中没有提及成员w
或h
,所以我不知道您有何想法。 如果要获取有关纹理的信息,可以使用SDL_QueryTexture
。
SDL_QueryTexture(vcTextures[tex], nullptr, nullptr, &rec.w, &rec.h);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.