Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDL: Get window height/width/rect?

Tags:

sdl

sdl-2

in previously versions of SDL I was able to get the height and width of my problem using the main surface, which had a clip_rect member. Since 2.0 I am using SDL_Renderer & SDL_Window.

How do I get the window size or even better the rect of my current program?

like image 910
Jannik Avatar asked Dec 11 '22 06:12

Jannik


2 Answers

To get the height and width of the window:

void SDL_GetWindowSize(SDL_Window* window,int* w,int* h)

You can look here for more functions for whatever you want that deals with windows. https://wiki.libsdl.org/CategoryVideo

like image 98
jofra Avatar answered Jan 31 '23 10:01

jofra


If you're just looking for width and height and anything else you'd normally find within an SDL_Surface this works just as well, if not better:

Width:

SDL_GetWindowSurface(m_window)->w;

Height:

SDL_GetWindowSurface(m_window)->h;
like image 35
Semirix Avatar answered Jan 31 '23 11:01

Semirix