Den*_*tho 2 c++ sdl-image sdl-2
我有一个关于使用 SDL_image 库在 SDL2 中加载图像的问题。
不幸的是,我在 SDL_image 文档中没有找到有关 IMG_LoadTexture 的任何信息。那么使用 IMG_LoadTexture 直接加载 PNG 图像作为纹理与使用 IMG_Load 加载表面然后使用 SDL_CreateTextureFromSurface 将其转换为纹理之间有什么区别?使用一个比另一个有什么好处吗?
如有疑问,请检查源代码(可在https://hg.libsdl.org/轻松浏览)- https://hg.libsdl.org/SDL_image/file/ca95d0e31aec/IMG.c#l209:
SDL_Texture *IMG_LoadTexture(SDL_Renderer *renderer, const char *file)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_Load(file);
if (surface) {
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
}
return texture;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4739 次 |
| 最近记录: |