#pragma once /// @file Display.hpp /// For complete documentation, see src/video/Display.cpp #include #include #include #include namespace hdk::sdl { class Display : public grid::PrimitiveWrapper { public: using grid::PrimitiveWrapper::PrimitiveWrapper; bool GetClosestFullscreenMode( int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode* closest) { return SDL_GetClosestFullscreenDisplayMode(*this, w, h, refresh_rate, include_high_density_modes, closest); } const SDL_DisplayMode* GetCurrentMode() const { return SDL_GetCurrentDisplayMode(*this); } SDL_DisplayOrientation GetCurrentOrientation() const { return SDL_GetCurrentDisplayOrientation(*this); } const SDL_DisplayMode* GetDesktopMode() const { return SDL_GetDesktopDisplayMode(*this); } bool GetBounds(SDL_Rect* rect) const { return SDL_GetDisplayBounds(*this, rect); } SDL_Rect GetBounds() const { SDL_Rect rect; if (GetBounds(&rect)) { return rect; } return SDL_Rect{ 0, 0, 0, 0 }; } float GetContentScale() const { return SDL_GetDisplayContentScale(*this); } static Display GetForPoint(const SDL_Point* point) { return Display(SDL_GetDisplayForPoint(point)); } static Display GetForRect(const SDL_Rect* rect) { return Display(SDL_GetDisplayForRect(rect)); } static Display GetForWindow(SDL_Window* window) { return Display(SDL_GetDisplayForWindow(window)); } const char* GetName() const { return SDL_GetDisplayName(*this); } Properties GetProperties() const { return Properties(SDL_GetDisplayProperties(*this)); } static SDL_DisplayID* GetDisplays(int* count) { return SDL_GetDisplays(count); } /** @see SDL_GetDisplays * @returns std::vector Display(s) available */ static std::vector GetDisplays() { int count; SDL_DisplayID* displayIDs = SDL_GetDisplays(&count); std::vector displays; if (displayIDs) { displays.reserve(count); for (int i = 0; i < count; ++i) { displays.emplace_back(displayIDs[i]); } SDL_free(displayIDs); } return displays; } bool GetUsableBounds(SDL_Rect* rect) const { return SDL_GetDisplayUsableBounds(*this, rect); } SDL_DisplayMode** GetFullscreenModes(int* count) const { return SDL_GetFullscreenDisplayModes(*this, count); } /** @see SDL_GetFullscreenDisplayModes * @returns std::vector of display modes available for fullscreen mode */ std::vector GetFullscreenModes() const { int count; SDL_DisplayMode** modes = SDL_GetFullscreenDisplayModes(*this, &count); std::vector displayModes; if (modes) { displayModes.reserve(count); for (int i = 0; i < count; ++i) { displayModes.push_back(*modes[i]); } SDL_free(modes); } return displayModes; } SDL_DisplayOrientation GetNaturalOrientation() const { return SDL_GetNaturalDisplayOrientation(*this); } static Display GetPrimaryDisplay() { return Display(SDL_GetPrimaryDisplay()); } }; }