设置sdl_blendmode_blend上的纹理中断渲染质量
我正在尝试创建纹理A,使其透明,然后将纹理b呈现给纹理A。问题是要使纹理成为透明的,我必须首先设置sdl_blendmode_blend the纹理上的打破纹理B渲染的方式。解决问题时,我想对纹理A呈现多种纹理。
纹理B包含一个白色的“新游戏”文本。蓝色背景分别渲染。
这是正确结果的图像,呈现纹理b直接
这是我没有呈现质地的图像设置SDL_BLENDMODE_BLEND。
这是我将渲染纹理a带有设置sdl_blendmode_blend的图像。
我注意到使用sdl_setrenderdrawcolor(r,255,255,255,255,0);
> 如果文本为白色,则纹理b可以正确地呈现,但是当文本为黑色时,它会呈现错误。
texA = SDL_CreateTexture(r, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_TARGET,
mWidth, mHeight);
SDL_SetRenderTarget(r, texA);
// breaks texB rendering, necessary to make texture transparent
SDL_SetTextureBlendMode(texA, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawBlendMode(r, SDL_BLENDMODE_NONE);
SDL_SetRenderDrawColor(r, 0, 0, 0, 0);
SDL_RenderFillRect(r, NULL);
SDL_RenderCopy(r, texB, NULL, NULL);
SDL_SetRenderTarget(r, nullptr);
I'm trying to create a texture A, make it transparent, and then render a texture B to the texture A. The problem is that to make the texture A transparent I have to first set SDL_BLENDMODE_BLEND on the texture A, which, sadly, breaks the way the texture B is being rendered. I want to render multiple textures to the texture A, when I resolve the issue.
The texture B contains a white "New Game" text. The blue background is rendered separately.
Here is an image of the correct result, rendering texture B directly
Here is an image of what I get rendering texture A without setting SDL_BLENDMODE_BLEND.
Here is an image of what I get rendering texture A with setting SDL_BLENDMODE_BLEND.
I noticed that when using SDL_SetRenderDrawColor(r, 255, 255, 255, 0);
the texture B renders correctly, if the text is white, but it renders incorrectly when the text is black.
texA = SDL_CreateTexture(r, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_TARGET,
mWidth, mHeight);
SDL_SetRenderTarget(r, texA);
// breaks texB rendering, necessary to make texture transparent
SDL_SetTextureBlendMode(texA, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawBlendMode(r, SDL_BLENDMODE_NONE);
SDL_SetRenderDrawColor(r, 0, 0, 0, 0);
SDL_RenderFillRect(r, NULL);
SDL_RenderCopy(r, texB, NULL, NULL);
SDL_SetRenderTarget(r, nullptr);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是创建自定义混合模式。偶然发现了这一点,所以我不确定为什么有效。
The solution was to create a custom blend mode. Figured that out by accident, so I'm not sure why that works.