From edd85cf1536f3b094e62b03f79100f3c6aaa7a52 Mon Sep 17 00:00:00 2001 From: briaguya Date: Wed, 18 May 2022 12:48:28 -0400 Subject: [PATCH] super messy but it's loading stuff from the .ini --- libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp | 7 +++++-- libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp | 2 +- libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp | 9 +++++++-- .../libultraship/Lib/Fast3D/gfx_window_manager_api.h | 2 +- libultraship/libultraship/Window.cpp | 5 +++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp index d450558b2..0aebe20cf 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp @@ -298,7 +298,7 @@ static bool gfx_glx_check_extension(const char *extensions, const char *extensio return false; } -static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { +static void gfx_glx_init(const char *game_name, bool start_in_fullscreen, u_int32_t width, uint32_t height) { // On NVIDIA proprietary driver, make the driver queue up to two frames on glXSwapBuffers, // which means that glXSwapBuffers should be non-blocking, // if we are sure to wait at least one vsync interval between calls. @@ -322,7 +322,10 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { XSetWindowAttributes swa; swa.colormap = cmap; swa.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | FocusChangeMask; - glx.win = XCreateWindow(glx.dpy, glx.root, 0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa); + // glx.win = XCreateWindow(glx.dpy, glx.root, 0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa); + glx.win = XCreateWindow(glx.dpy, glx.root, 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa); + + glx.atom_wm_state = XInternAtom(glx.dpy, "_NET_WM_STATE", False); glx.atom_wm_state_fullscreen = XInternAtom(glx.dpy, "_NET_WM_STATE_FULLSCREEN", False); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 4d3f40d23..55252377b 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -2664,7 +2664,7 @@ void gfx_get_dimensions(uint32_t *width, uint32_t *height) { void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *game_name, bool start_in_fullscreen, uint32_t screen_width, uint32_t screen_height) { gfx_wapi = wapi; gfx_rapi = rapi; - gfx_wapi->init(game_name, start_in_fullscreen); + gfx_wapi->init(game_name, start_in_fullscreen, screen_width, screen_height); gfx_rapi->init(); gfx_rapi->update_framebuffer_parameters(0, screen_width, screen_height, 1, false, true, true, true); gfx_current_dimensions.internal_mul = 1; diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index e80097c81..754958b10 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -1,4 +1,6 @@ #include +#include + #if defined(ENABLE_OPENGL) @@ -94,6 +96,7 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { }; static void set_fullscreen(bool on, bool call_callback) { + std::cout << "\nwe hit set_fullscreen\n"; if (fullscreen_state == on) { return; } @@ -129,7 +132,7 @@ static int frameDivisor = 1; #define FRAME_INTERVAL_US_DENOMINATOR 3 #define FRAME_INTERVAL_US_NUMERATOR (FRAME_INTERVAL_US_NUMERATOR_ * frameDivisor) -static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) { +static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen, uint32_t width, uint32_t height) { SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); @@ -145,8 +148,10 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) { char title[512]; int len = sprintf(title, "%s (%s)", game_name, GFX_API_NAME); + std::cout << "\nwe hit gfx_sdl_init in gfx_sdl2.cpp\n"; + wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); + width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); if (start_in_fullscreen) { set_fullscreen(true, false); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_window_manager_api.h b/libultraship/libultraship/Lib/Fast3D/gfx_window_manager_api.h index 5d7442390..a2f7cb440 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_window_manager_api.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_window_manager_api.h @@ -5,7 +5,7 @@ #include struct GfxWindowManagerAPI { - void (*init)(const char *game_name, bool start_in_fullscreen); + void (*init)(const char *game_name, bool start_in_fullscreen, uint32_t width, uint32_t height); void (*set_keyboard_callbacks)(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void)); void (*set_fullscreen_changed_callback)(void (*on_fullscreen_changed)(bool is_now_fullscreen)); void (*set_fullscreen)(bool enable); diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index d2240928e..279fa19e6 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -275,7 +275,12 @@ namespace Ship { const std::string& gfx_backend = Conf["WINDOW"]["GFX BACKEND"]; SetWindowManager(&WmApi, &RenderingApi, gfx_backend); + std::cout << "\nwe're about to call gfx_init from Window.cpp Init\n"; + gfx_init(WmApi, RenderingApi, GetContext()->GetName().c_str(), bIsFullscreen, dwWidth, dwHeight); + + std::cout << "\nwe're back after calling gfx_init from Window.cpp Init\n"; + WmApi->set_fullscreen_changed_callback(Window::OnFullscreenChanged); WmApi->set_keyboard_callbacks(Window::KeyDown, Window::KeyUp, Window::AllKeysUp); }