如何更改 SDL_Texture 的不透明度?而且我不知道如何在我的函数中应用不透明度数。
我的代码
void drawTexture(SDL_Texture *img, int x, int y, int width, int height, double opacity)
{
SDL_Rect SrcR;
SDL_Rect DestR;
SrcR.x = 0;
SrcR.y = 0;
SrcR.w = width;
SrcR.h = height;
DestR.x = x;
DestR.y = y;
DestR.w = width;
DestR.h = height;
SDL_RenderCopy(_main::_main_renderer, img, &SrcR, &DestR);
}
最佳答案
SDL_SetTextureAlphaMod(img, opacity);
这将设置纹理的不透明度 (alpha),alpha 值必须是 Uint8
从 0
(完全透明也就是不可见)到 255
(完全不透明)。
关于c++ - SDL_Texture 不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20639426/