diff --git a/src/graphic/Fast3D/Fast3dWindow.cpp b/src/graphic/Fast3D/Fast3dWindow.cpp index 44ba7a416..9d7b8c919 100644 --- a/src/graphic/Fast3D/Fast3dWindow.cpp +++ b/src/graphic/Fast3D/Fast3dWindow.cpp @@ -172,6 +172,40 @@ uint32_t Fast3dWindow::GetHeight() { return height; } +void Fast3dWindow::SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) { + mWindowManagerApi->set_dimensions(width, height, posX, posY); + SaveWindowToConfig(); +} + +void Fast3dWindow::SetCurrentDimensions(uint32_t width, uint32_t height) { + SetCurrentDimensions(width, height, GetPosX(), GetPosY()); +} + +void Fast3dWindow::SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, + int32_t posY) { + auto conf = Ship::Context::GetInstance()->GetConfig(); + if (!isFullscreen) { + conf->SetInt("Window.Width", (int32_t)width); + conf->SetInt("Window.Height", (int32_t)height); + conf->SetInt("Window.PositionX", posX); + conf->SetInt("Window.PositionY", posY); + } else { + conf->SetInt("Window.Fullscreen.Width", (int32_t)width); + conf->SetInt("Window.Fullscreen.Height", (int32_t)height); + } + mWindowManagerApi->set_fullscreen(isFullscreen); + mWindowManagerApi->set_dimensions(width, height, posX, posY); + SaveWindowToConfig(); +} + +void Fast3dWindow::SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) { + SetCurrentDimensions(isFullscreen, width, height, GetPosX(), GetPosY()); +} + +Ship::WindowRect Fast3dWindow::GetPrimaryMonitorRect() { + return mWindowManagerApi->get_primary_monitor_rect(); +} + int32_t Fast3dWindow::GetPosX() { uint32_t width, height; int32_t posX, posY; @@ -248,8 +282,8 @@ void Fast3dWindow::SetMsaaLevel(uint32_t value) { } void Fast3dWindow::SetFullscreen(bool isFullscreen) { - SaveWindowToConfig(); mWindowManagerApi->set_fullscreen(isFullscreen); + SaveWindowToConfig(); } bool Fast3dWindow::IsFullscreen() { diff --git a/src/graphic/Fast3D/Fast3dWindow.h b/src/graphic/Fast3D/Fast3dWindow.h index 86676cf9d..254a2b2c6 100644 --- a/src/graphic/Fast3D/Fast3dWindow.h +++ b/src/graphic/Fast3D/Fast3dWindow.h @@ -19,6 +19,11 @@ class Fast3dWindow : public Ship::Window { void SetCursorVisibility(bool visible) override; uint32_t GetWidth() override; uint32_t GetHeight() override; + void SetCurrentDimensions(uint32_t width, uint32_t height) override; + void SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) override; + void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) override; + void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) override; + Ship::WindowRect GetPrimaryMonitorRect() override; int32_t GetPosX() override; int32_t GetPosY() override; void SetMousePos(Ship::Coords pos) override; diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index b607bffc5..23aded4e0 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -77,6 +77,8 @@ static struct { bool dropped_frame; std::tuple h_Monitor; // 0: Handle, 1: Display Monitor Rect, 2: Is_Primary std::vector> monitor_list; + std::vector monitor_rects; + size_t primary_monitor_index; bool zero_latency; double detected_hz; double display_period; // (1000 / dxgi.detected_hz) in ms @@ -128,37 +130,43 @@ static void apply_maximum_frame_latency(bool first) { dxgi.applied_maximum_frame_latency = dxgi.maximum_frame_latency; } -std::vector> GetMonitorList() { - std::vector> monitors; +void UpdateMonitorList() { + dxgi.monitor_list.clear(); + dxgi.monitor_rects.clear(); EnumDisplayMonitors( nullptr, nullptr, [](HMONITOR hmon, HDC hdc, LPRECT rc, LPARAM lp) { UNREFERENCED_PARAMETER(hdc); UNREFERENCED_PARAMETER(rc); + UNREFERENCED_PARAMETER(lp); bool isPrimary; MONITORINFOEX mi = {}; mi.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(hmon, &mi); - auto monitors = (std::vector>*)lp; if (mi.dwFlags == MONITORINFOF_PRIMARY) { isPrimary = TRUE; } else { isPrimary = FALSE; } - monitors->push_back({ hmon, mi.rcMonitor, isPrimary }); + + dxgi.monitor_list.push_back({ hmon, mi.rcMonitor, isPrimary }); + dxgi.monitor_rects.push_back( + { mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom }); + if (isPrimary) { + dxgi.primary_monitor_index = dxgi.monitor_rects.size() - 1; + } + return TRUE; }, - (LPARAM)&monitors); - return monitors; + (LPARAM) nullptr); } // Uses coordinates to get a Monitor handle from a list -bool GetMonitorAtCoords(std::vector> MonitorList, int x, int y, UINT cx, UINT cy, - std::tuple& MonitorInfo) { +bool GetMonitorAtCoords(int x, int y, UINT cx, UINT cy, std::tuple& MonitorInfo) { RECT wr = { x, y, (x + cx), (y + cy) }; std::tuple primary; - for (std::tuple i : MonitorList) { + for (std::tuple i : dxgi.monitor_list) { if (PtInRect(&get<1>(i), POINT((x + (cx / 2)), (y + (cy / 2))))) { MonitorInfo = i; return true; @@ -171,7 +179,7 @@ bool GetMonitorAtCoords(std::vector> MonitorLis LONG area; LONG lastArea = 0; std::tuple biggest; - for (std::tuple i : MonitorList) { + for (std::tuple i : dxgi.monitor_list) { if (IntersectRect(&intersection, &get<1>(i), &wr)) { area = (intersection.right - intersection.left) * (intersection.bottom - intersection.top); if (area > lastArea) { @@ -188,6 +196,34 @@ bool GetMonitorAtCoords(std::vector> MonitorLis return false; } +static void apply_window_dimensions() { + RECT wr = { dxgi.posX, dxgi.posY, dxgi.posX + static_cast(dxgi.current_width), + dxgi.posY + static_cast(dxgi.current_height) }; + if (!dxgi.is_full_screen) { + // Set in window mode with the last saved position and size + SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); + + if (dxgi.last_maximized_state) { + SetWindowPos(dxgi.h_wnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); + ShowWindow(dxgi.h_wnd, SW_MAXIMIZE); + } else { + AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); + SetWindowPos(dxgi.h_wnd, NULL, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, SWP_FRAMECHANGED); + ShowWindow(dxgi.h_wnd, SW_RESTORE); + } + } else { + // Save if window is maximized or not + WINDOWPLACEMENT window_placement; + window_placement.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(dxgi.h_wnd, &window_placement); + dxgi.last_maximized_state = window_placement.showCmd == SW_SHOWMAXIMIZED; + + // Set borderless full screen to that monitor + SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_POPUP); + SetWindowPos(dxgi.h_wnd, HWND_TOP, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, SWP_FRAMECHANGED); + } +} + static void toggle_borderless_window_full_screen(bool enable, bool call_callback) { // Windows 7 + flip mode + waitable object can't go to exclusive fullscreen, // so do borderless instead. If DWM is enabled, this means we get one monitor @@ -198,52 +234,37 @@ static void toggle_borderless_window_full_screen(bool enable, bool call_callback return; } - if (!enable) { - // Set in window mode with the last saved position and size - SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); + auto conf = Ship::Context::GetInstance()->GetConfig(); - if (dxgi.last_maximized_state) { - SetWindowPos(dxgi.h_wnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); - ShowWindow(dxgi.h_wnd, SW_MAXIMIZE); - } else { + if (!enable) { + if (!dxgi.last_maximized_state) { std::tuple Monitor; - auto conf = Ship::Context::GetInstance()->GetConfig(); dxgi.current_width = conf->GetInt("Window.Width", 640); dxgi.current_height = conf->GetInt("Window.Height", 480); dxgi.posX = conf->GetInt("Window.PositionX", 100); dxgi.posY = conf->GetInt("Window.PositionY", 100); - if (!GetMonitorAtCoords(dxgi.monitor_list, dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, + if (!GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, Monitor)) { // Fallback to default when out of bounds. dxgi.posX = 100; dxgi.posY = 100; } - RECT wr = { dxgi.posX, dxgi.posY, dxgi.posX + static_cast(dxgi.current_width), - dxgi.posY + static_cast(dxgi.current_height) }; - AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); - SetWindowPos(dxgi.h_wnd, NULL, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, SWP_FRAMECHANGED); - ShowWindow(dxgi.h_wnd, SW_RESTORE); } - - dxgi.is_full_screen = false; } else { + dxgi.current_width = conf->GetInt("Window.Fullscreen.Width", 1920); + dxgi.current_height = conf->GetInt("Window.Fullscreen.Height", 1080); + dxgi.posX = 0; + dxgi.posY = 0; + // Save if window is maximized or not WINDOWPLACEMENT window_placement; window_placement.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(dxgi.h_wnd, &window_placement); dxgi.last_maximized_state = window_placement.showCmd == SW_SHOWMAXIMIZED; + } - // We already know on what monitor we are (gets it on init or move) - // Get info from that monitor - RECT r = get<1>(dxgi.h_Monitor); + dxgi.is_full_screen = enable; - // Set borderless full screen to that monitor - SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_POPUP); - // OTRTODO: This should be setting the resolution from config. - dxgi.current_width = r.right - r.left; - dxgi.current_height = r.bottom - r.top; - SetWindowPos(dxgi.h_wnd, HWND_TOP, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); - dxgi.is_full_screen = true; - } + apply_window_dimensions(); if (dxgi.on_fullscreen_changed != nullptr && call_callback) { dxgi.on_fullscreen_changed(enable); @@ -344,8 +365,7 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par case WM_SIZE: dxgi.current_width = LOWORD(l_param); dxgi.current_height = HIWORD(l_param); - GetMonitorAtCoords(dxgi.monitor_list, dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, - newMonitor); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, newMonitor); if (get<0>(newMonitor) != get<0>(dxgi.h_Monitor)) { dxgi.h_Monitor = newMonitor; GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); @@ -354,8 +374,7 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par case WM_MOVE: dxgi.posX = GET_X_LPARAM(l_param); dxgi.posY = GET_Y_LPARAM(l_param); - GetMonitorAtCoords(dxgi.monitor_list, dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, - newMonitor); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, newMonitor); if (get<0>(newMonitor) != get<0>(dxgi.h_Monitor)) { dxgi.h_Monitor = newMonitor; GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); @@ -433,9 +452,8 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par break; case WM_DISPLAYCHANGE: - dxgi.monitor_list = GetMonitorList(); - GetMonitorAtCoords(dxgi.monitor_list, dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, - dxgi.h_Monitor); + UpdateMonitorList(); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, dxgi.h_Monitor); GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); break; case WM_SETFOCUS: @@ -502,11 +520,10 @@ void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_i AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); dxgi.current_width = wr.right - wr.left; dxgi.current_height = wr.bottom - wr.top; - dxgi.monitor_list = GetMonitorList(); + UpdateMonitorList(); dxgi.posX = posX; dxgi.posY = posY; - if (!GetMonitorAtCoords(dxgi.monitor_list, dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, - dxgi.h_Monitor)) { + if (!GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, dxgi.h_Monitor)) { dxgi.posX = 100; dxgi.posY = 100; } @@ -643,6 +660,19 @@ static void gfx_dxgi_get_dimensions(uint32_t* width, uint32_t* height, int32_t* *posY = dxgi.posY; } +static void gfx_dxgi_set_dimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) { + dxgi.current_width = width; + dxgi.current_height = height; + dxgi.posX = posX; + dxgi.posY = posY; + + apply_window_dimensions(); +} + +static Ship::WindowRect gfx_dxgi_get_primary_monitor_rect() { + return dxgi.monitor_rects[dxgi.primary_monitor_index]; +} + static void gfx_dxgi_handle_events() { MSG msg; while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) { @@ -1057,6 +1087,8 @@ extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = { gfx_dxgi_init, gfx_dxgi_set_mouse_capture, gfx_dxgi_is_mouse_captured, gfx_dxgi_get_dimensions, + gfx_dxgi_set_dimensions, + gfx_dxgi_get_primary_monitor_rect, gfx_dxgi_handle_events, gfx_dxgi_start_frame, gfx_dxgi_swap_buffers_begin, diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index a4027d647..b348b9e04 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -49,6 +49,8 @@ static float mouse_wheel_y = 0.0f; // OTRTODO: These are redundant. Info can be queried from SDL. static int window_width = DESIRED_SCREEN_WIDTH; static int window_height = DESIRED_SCREEN_HEIGHT; +static int window_posx = 100; +static int window_posy = 100; static bool fullscreen_state; static bool is_running = true; static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen); @@ -57,6 +59,7 @@ static bool (*on_key_up_callback)(int scancode); static void (*on_all_keys_up_callback)(); static bool (*on_mouse_button_down_callback)(int btn); static bool (*on_mouse_button_up_callback)(int btn); +static void gfx_sdl_set_dimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY); #ifdef _WIN32 LONG_PTR SDL_WndProc; @@ -220,45 +223,63 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { { SDL_SCANCODE_KP_7, S { SDL_SCANCODE_KP_PERIOD, SDL_SCANCODE_DELETE }, { SDL_SCANCODE_KP_MULTIPLY, SDL_SCANCODE_PRINTSCREEN } }; -static void set_fullscreen(bool on, bool call_callback) { - if (fullscreen_state == on) { - return; - } - int display_in_use = SDL_GetWindowDisplayIndex(wnd); - if (display_in_use < 0) { - SPDLOG_WARN("Can't detect on which monitor we are. Probably out of display area?"); - SPDLOG_WARN(SDL_GetError()); - } - - if (on) { - // OTRTODO: Get mode from config. +static void apply_window_dimensions() { + if (fullscreen_state) { SDL_DisplayMode mode; + + int display_in_use = SDL_GetWindowDisplayIndex(wnd); + if (display_in_use < 0) { + SPDLOG_WARN("Can't detect on which monitor we are. Probably out of display area? ({})", SDL_GetError()); + } + if (SDL_GetDesktopDisplayMode(display_in_use, &mode) >= 0) { - SDL_SetWindowDisplayMode(wnd, &mode); + mode.w = window_width; + mode.h = window_height; + mode.driverdata = nullptr; + mode.format = 0; + mode.refresh_rate = 0; + + if (SDL_SetWindowDisplayMode(wnd, &mode) != 0) { + SPDLOG_ERROR("Failed to set SDL Window display Mode: ({})", SDL_GetError()); + } + } else { - SPDLOG_ERROR(SDL_GetError()); + SPDLOG_ERROR("Failed to get SDL Desktop Display Mode: ({})", SDL_GetError()); } } else { - auto conf = Ship::Context::GetInstance()->GetConfig(); + SDL_SetWindowPosition(wnd, window_posx, window_posy); + SDL_SetWindowSize(wnd, window_width, window_height); + } +} + +static void set_fullscreen(bool on, bool call_callback) { + if (fullscreen_state == on) { + return; + } + + auto conf = Ship::Context::GetInstance()->GetConfig(); + if (!on) { window_width = conf->GetInt("Window.Width", 640); window_height = conf->GetInt("Window.Height", 480); - int32_t posX = conf->GetInt("Window.PositionX", 100); - int32_t posY = conf->GetInt("Window.PositionY", 100); - if (display_in_use < 0) { // Fallback to default if out of bounds - posX = 100; - posY = 100; - } - SDL_SetWindowPosition(wnd, posX, posY); - SDL_SetWindowSize(wnd, window_width, window_height); + window_posx = conf->GetInt("Window.PositionX", 100); + window_posy = conf->GetInt("Window.PositionY", 100); + } else { + window_width = conf->GetInt("Window.Fullscreen.Width", 1920); + window_height = conf->GetInt("Window.Fullscreen.Height", 1080); + window_posx = 0; + window_posy = 0; } + + SDL_SetCursor(SDL_DISABLE); + bool original_state = fullscreen_state; + fullscreen_state = on; + apply_window_dimensions(); if (SDL_SetWindowFullscreen(wnd, on ? (CVarGetInteger(CVAR_SDL_WINDOWED_FULLSCREEN, 0) ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN) - : 0) >= 0) { - fullscreen_state = on; - } else { - SPDLOG_ERROR("Failed to switch from or to fullscreen mode."); - SPDLOG_ERROR(SDL_GetError()); + : 0) != 0) { + fullscreen_state = original_state; + SPDLOG_ERROR("Failed to switch from or to fullscreen mode {}.", SDL_GetError()); } if (on_fullscreen_changed_callback != NULL && call_callback) { @@ -311,9 +332,6 @@ static LRESULT CALLBACK gfx_sdl_wnd_proc(HWND h_wnd, UINT message, WPARAM w_para static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) { - window_width = width; - window_height = height; - #if SDL_VERSION_ATLEAST(2, 24, 0) /* fix DPI scaling issues on Windows */ SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2"); @@ -386,6 +404,8 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s posY = 100; } + gfx_sdl_set_dimensions(width, height, posX, posY); + if (use_opengl) { SDL_GL_GetDrawableSize(wnd, &window_width, &window_height); @@ -494,6 +514,31 @@ static void gfx_sdl_get_dimensions(uint32_t* width, uint32_t* height, int32_t* p SDL_GetWindowPosition(wnd, static_cast(posX), static_cast(posY)); } +static void gfx_sdl_set_dimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) { + window_width = width; + window_height = height; + window_posx = posX; + window_posy = posY; + + apply_window_dimensions(); +} + +static Ship::WindowRect gfx_sdl_get_primary_monitor_rect() { + SDL_DisplayMode mode; + + int display_in_use = SDL_GetWindowDisplayIndex(wnd); + if (display_in_use < 0) { + SPDLOG_WARN("Can't detect on which monitor we are. Probably out of display area? ({})", SDL_GetError()); + } + + if (SDL_GetDesktopDisplayMode(display_in_use, &mode) >= 0) { + return { 0, 0, mode.w, mode.h }; + } else { + SPDLOG_ERROR("Failed to get SDL Desktop Display Mode: ({})", SDL_GetError()); + } + return { 0, 0, 0, 0 }; +} + static int translate_scancode(int scancode) { if (scancode < 512) { return sdl_to_lus_table[scancode]; @@ -708,6 +753,8 @@ struct GfxWindowManagerAPI gfx_sdl = { gfx_sdl_init, gfx_sdl_set_mouse_capture, gfx_sdl_is_mouse_captured, gfx_sdl_get_dimensions, + gfx_sdl_set_dimensions, + gfx_sdl_get_primary_monitor_rect, gfx_sdl_handle_events, gfx_sdl_start_frame, gfx_sdl_swap_buffers_begin, diff --git a/src/graphic/Fast3D/gfx_window_manager_api.h b/src/graphic/Fast3D/gfx_window_manager_api.h index 9fd3555db..bca57cb6e 100644 --- a/src/graphic/Fast3D/gfx_window_manager_api.h +++ b/src/graphic/Fast3D/gfx_window_manager_api.h @@ -1,6 +1,7 @@ #ifndef GFX_WINDOW_MANAGER_API_H #define GFX_WINDOW_MANAGER_API_H +#include "window/Window.h" #include #include @@ -23,11 +24,13 @@ struct GfxWindowManagerAPI { void (*set_mouse_capture)(bool capture); bool (*is_mouse_captured)(); void (*get_dimensions)(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY); - void (*handle_events)(); - bool (*start_frame)(); - void (*swap_buffers_begin)(); - void (*swap_buffers_end)(); - double (*get_time)(); // For debug + void (*set_dimensions)(uint32_t width, uint32_t height, int32_t posX, int32_t posY); + Ship::WindowRect (*get_primary_monitor_rect)(void); + void (*handle_events)(void); + bool (*start_frame)(void); + void (*swap_buffers_begin)(void); + void (*swap_buffers_end)(void); + double (*get_time)(void); // For debug void (*set_target_fps)(int fps); void (*set_maximum_frame_latency)(int latency); const char* (*get_key_name)(int scancode); diff --git a/src/window/Window.h b/src/window/Window.h index 708b29bfe..31ab769b5 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -22,6 +22,13 @@ struct CoordsF { float y; }; +struct WindowRect { + int32_t Left; + int32_t Top; + int32_t Right; + int32_t Bottom; +}; + class Config; class Window { @@ -39,6 +46,12 @@ class Window { virtual void SetCursorVisibility(bool visible) = 0; virtual uint32_t GetWidth() = 0; virtual uint32_t GetHeight() = 0; + virtual void SetCurrentDimensions(uint32_t width, uint32_t height) = 0; + virtual void SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) = 0; + virtual void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) = 0; + virtual void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, + int32_t posY) = 0; + virtual WindowRect GetPrimaryMonitorRect() = 0; virtual int32_t GetPosX() = 0; virtual int32_t GetPosY() = 0; virtual void SetMousePos(Coords pos) = 0;