API reference / Windows and drawing
SDL_SetRenderDrawColor
Function, SDL3
Sets the color for the next drawing calls. The color stays until you set another one.
Declaration
#include <SDL3/SDL.h>
bool SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);Parameters
renderer | The renderer. |
r | The red part, from 0 to 255. |
g | The green part, from 0 to 255. |
b | The blue part, from 0 to 255. |
a | The alpha part, from 0 to 255. Use SDL_ALPHA_OPAQUE for a solid color. |
Return value
True on success. On failure it returns false.
Example
SDL_SetRenderDrawColor(renderer, 32, 96, 160, SDL_ALPHA_OPAQUE);See this code run in Open a window. Download the full program (.zip)
In Draw a rectangle
SDL_SetRenderDrawColor(renderer, 24, 26, 32, SDL_ALPHA_OPAQUE);See this code run in Draw a rectangle. Download the full program (.zip)
Notes
- Alpha has no effect unless you set a blend mode.
In SDL2
The name is the same.