【发布时间】:2021-08-29 02:17:00
【问题描述】:
我将 png 文件加载到表面并从中创建纹理
稍后我修改表面然后使用 SDL_UpdateTexture
问题:
SDL_CreateTextureFromSurface 尊重从表面到纹理的颜色格式
而 SDL_UpdateTexture 没有(交换红色和蓝色)
SDL_UpdateTexture(texture, NULL, (Uint8*)surface->pixels, surface->w * sizeof(Uint32));
这是加载文件的代码,没什么花哨的
void MyClass::loadFromFile( std::string path)
{
surface = IMG_Load( path.c_str() );
//SDL_SetColorKey( surface, SDL_TRUE, SDL_MapRGB( surface->format, 0, 0xFF, 0xFF ) );
texture = SDL_CreateTextureFromSurface( core->getRenderer(), surface );
}
我试过了:
- 评论 SDL_SetColorKey
- 注释修改表面像素的代码(仅调用 SDL_UpdateTexture)
这看起来确实像一个 SDL 错误,因为我无法将任何格式传递给 SDL_UpdateTexture
我错过了什么吗?
【问题讨论】: