SDL_RenderFillRect handles alpha incorrectly on GL backend

Try this:

Create a texture with an arbitrary image.

Render it to the screen.
Before calling SDL_RenderPresent, try to tint the image red as follows:

SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100);
SDL_RenderFillRect(renderer, dstRect);

EXPECTED:

I should see the image, with a translucent red rectangle over it.

OBSERVED:
I see a solid red rectangle.

This appears to be because GL_RenderFillRects calls GL_SetDrawingState, which calls GL_SetShader(data, SHADER_SOLID), which references a shader with no alpha blending capabilities.

Anyone know how to fix this?

Mason

You want to set the draw blend mode, e.g.:
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);On Tue, Jul 24, 2012 at 7:13 PM, Mason Wheeler wrote:

Try this:

Create a texture with an arbitrary image.
Render it to the screen.
Before calling SDL_RenderPresent, try to tint the image red as follows:

SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100);
SDL_RenderFillRect(renderer, dstRect);

EXPECTED:
I should see the image, with a translucent red rectangle over it.

OBSERVED:
I see a solid red rectangle.

This appears to be because GL_RenderFillRects calls GL_SetDrawingState,
which calls GL_SetShader(data, SHADER_SOLID), which references a shader
with no alpha blending capabilities.

Anyone know how to fix this?

Mason


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org