【发布时间】:2020-11-04 00:15:20
【问题描述】:
情况
我想在我的应用程序中加载和使用我的图像(即 .png)。但是,当我尝试加载图像时,出现以下错误
./sources/texture.c:9 处的错误:'纹理为 NULL'
> 无法打开 pawn.png
代码
texture.c
texture_t*
texture_load(renderer_t *renderer, const char *path) {
texture_t *tex = IMG_LoadTexture(renderer, path);
if (tex == NULL)
error_print(AT, "The texture is NULL");
return tex;
}
game.c
game_t*
game_create() {
...
IMG_Init(IMG_INIT_PNG);
...
texture_load(renderer, "pawn.png")
...
}
文件夹结构
.
├── build
│ ├── app
│ └── pawn.png
├── headers
│ ...
│ ├── game.h
| ...
│ ├── texture.h
│ ...
├── resources
│ └── pawn.png
└── sources
...
├── game.c
...
├── texture.c
...
奖金
如果您想查看我的项目的整个“图像”,那么您可以点击here
【问题讨论】: