Search code examples
c++windowsdl-2

How to get client area size of window in SDL2


How can I get the resolution of window without taking border into account in SDL2? I need the function just like GetClientRect in WinAPI, but it seems like there is no equal function in SDL2.


Solution

  • Using SDL_GetWindowSize, you can grab the width and height of the client window.

    SDL_Window* window = SDL_CreateWindow("Window", 0, 0, 800, 600, 0);
    int width;
    int height;
    SDL_GetWindowSize(window, &width, &height);
    

    width = 800, height = 600