Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a rectangle outline in SDL 2.0

Tags:

sdl

sdl-2

I'm trying to draw a rectangle outline in SDL 2.0 in order to use as a selection box. Does anyone know how to make one in SDL 2.0?

like image 807
Ben McAlindin Avatar asked Mar 21 '23 14:03

Ben McAlindin


1 Answers

You are looking for the SDL_RenderDrawRect:

int SDL_RenderDrawRect(SDL_Renderer*   renderer,
                   const SDL_Rect* rect);

Typical usage would be:

SDL_Rect rectToDraw = {100,100,100,100} // Just some random rect

//Set Color of Rect with SDL_SetRenderDrawColor if needed

SDL_RenderDrawRect(renderer, &rectToDraw);

To draw a filled rect it would then be with SDL_RenderFillRect

like image 173
Xonar Avatar answered Apr 27 '23 13:04

Xonar