mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-05 22:30:29 +00:00
Changed transparent window test
This adds more alpha colours to hopefully diagnose problems with software transparency a bit better. Theoretically, the squares should be less visible the less alpha down, but with SDL_BLENDMODE_NONE, this is not the case, we need to use SDL_BLENDMODE_BLEND instead.
This commit is contained in:
parent
eb181c8d1a
commit
8c8f2bc86e
1 changed files with 6 additions and 3 deletions
|
|
@ -27,19 +27,21 @@ static void draw(SDL_Renderer *renderer)
|
|||
SDL_RenderClear(renderer);
|
||||
|
||||
if (w >= 3 * SQUARE_SIZE && h >= 3 * SQUARE_SIZE) {
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.y = h - SQUARE_SIZE;
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 170);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.x = w - SQUARE_SIZE;
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 85);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.y = 0.0f;
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 0);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +84,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Make sure we're setting the alpha channel while drawing */
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
/* But also make sure we're setting it to premultiplied alpha and not straight alpha. */
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
|
||||
/* We're ready to go! */
|
||||
while (!done) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue