super messy but it's loading stuff from the .ini

This commit is contained in:
briaguya 2022-05-18 12:48:28 -04:00
commit edd85cf153
5 changed files with 19 additions and 6 deletions

View file

@ -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);

View file

@ -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;

View file

@ -1,4 +1,6 @@
#include <stdio.h>
#include <iostream>
#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);

View file

@ -5,7 +5,7 @@
#include <stdbool.h>
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);

View file

@ -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);
}