Patrick’s development blog

Drawing rectangles SDL

Posted in SDL / OpenGL by Patrick on June 24, 2009

Drawing rectangles can become such a pain in the ass after drawing them a couple of times. I made a helper function that makes this easier.

void FillRect(int x, int y, int w, int h, int color) {
SDL_Rect rect = {x,y,w,h};
SDL_FillRect(screen, &rect, color);
}

I want to add a 100×150 rectangle at the position (25,25) with the color white.

FillRect(25,25,100,150,0xFFFFFF);

Great, no more headache and code memorizing.