mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 12:52:18 -05:00
use ini window resolution (#410)
* use ini window resolution * use arguments for directx window size * default 640x480 not 320x240 * kick off a build * and revert * default config 640x480 not 320x240 * add todo Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
parent
306cfd0654
commit
1ad2931f80
@ -69,8 +69,8 @@ namespace Ship {
|
|||||||
(*this)["KEYBOARD SHORTCUTS"]["KEY_FULLSCREEN"] = std::to_string(0x044);
|
(*this)["KEYBOARD SHORTCUTS"]["KEY_FULLSCREEN"] = std::to_string(0x044);
|
||||||
(*this)["KEYBOARD SHORTCUTS"]["KEY_CONSOLE"] = std::to_string(0x029);
|
(*this)["KEYBOARD SHORTCUTS"]["KEY_CONSOLE"] = std::to_string(0x029);
|
||||||
|
|
||||||
(*this)["WINDOW"]["WINDOW WIDTH"] = std::to_string(320);
|
(*this)["WINDOW"]["WINDOW WIDTH"] = std::to_string(640);
|
||||||
(*this)["WINDOW"]["WINDOW HEIGHT"] = std::to_string(240);
|
(*this)["WINDOW"]["WINDOW HEIGHT"] = std::to_string(480);
|
||||||
(*this)["WINDOW"]["FULLSCREEN WIDTH"] = std::to_string(1920);
|
(*this)["WINDOW"]["FULLSCREEN WIDTH"] = std::to_string(1920);
|
||||||
(*this)["WINDOW"]["FULLSCREEN HEIGHT"] = std::to_string(1080);
|
(*this)["WINDOW"]["FULLSCREEN HEIGHT"] = std::to_string(1080);
|
||||||
(*this)["WINDOW"]["FULLSCREEN"] = std::to_string(false);
|
(*this)["WINDOW"]["FULLSCREEN"] = std::to_string(false);
|
||||||
|
@ -278,7 +278,7 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_dxgi_init(const char *game_name, bool start_in_fullscreen) {
|
void gfx_dxgi_init(const char *game_name, bool start_in_fullscreen, uint32_t width, uint32_t height) {
|
||||||
LARGE_INTEGER qpc_init, qpc_freq;
|
LARGE_INTEGER qpc_init, qpc_freq;
|
||||||
QueryPerformanceCounter(&qpc_init);
|
QueryPerformanceCounter(&qpc_init);
|
||||||
QueryPerformanceFrequency(&qpc_freq);
|
QueryPerformanceFrequency(&qpc_freq);
|
||||||
@ -319,7 +319,7 @@ void gfx_dxgi_init(const char *game_name, bool start_in_fullscreen) {
|
|||||||
|
|
||||||
run_as_dpi_aware([&] () {
|
run_as_dpi_aware([&] () {
|
||||||
// We need to be dpi aware when calculating the size
|
// We need to be dpi aware when calculating the size
|
||||||
RECT wr = {0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT};
|
RECT wr = {0, 0, width, height};
|
||||||
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
|
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
|
||||||
dxgi.h_wnd = CreateWindowW(WINCLASS_NAME, w_title, WS_OVERLAPPEDWINDOW,
|
dxgi.h_wnd = CreateWindowW(WINCLASS_NAME, w_title, WS_OVERLAPPEDWINDOW,
|
||||||
|
@ -298,7 +298,7 @@ static bool gfx_glx_check_extension(const char *extensions, const char *extensio
|
|||||||
return false;
|
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,
|
// On NVIDIA proprietary driver, make the driver queue up to two frames on glXSwapBuffers,
|
||||||
// which means that glXSwapBuffers should be non-blocking,
|
// which means that glXSwapBuffers should be non-blocking,
|
||||||
// if we are sure to wait at least one vsync interval between calls.
|
// if we are sure to wait at least one vsync interval between calls.
|
||||||
|
@ -60,8 +60,7 @@ using namespace std;
|
|||||||
#define SCALE_3_8(VAL_) ((VAL_) * 0x24)
|
#define SCALE_3_8(VAL_) ((VAL_) * 0x24)
|
||||||
#define SCALE_8_3(VAL_) ((VAL_) / 0x24)
|
#define SCALE_8_3(VAL_) ((VAL_) / 0x24)
|
||||||
|
|
||||||
#define SCREEN_WIDTH 320
|
// SCREEN_WIDTH and SCREEN_HEIGHT are defined in the headerfile
|
||||||
#define SCREEN_HEIGHT 240
|
|
||||||
#define HALF_SCREEN_WIDTH (SCREEN_WIDTH / 2)
|
#define HALF_SCREEN_WIDTH (SCREEN_WIDTH / 2)
|
||||||
#define HALF_SCREEN_HEIGHT (SCREEN_HEIGHT / 2)
|
#define HALF_SCREEN_HEIGHT (SCREEN_HEIGHT / 2)
|
||||||
|
|
||||||
@ -2643,15 +2642,15 @@ void gfx_get_dimensions(uint32_t *width, uint32_t *height) {
|
|||||||
gfx_wapi->get_dimensions(width, height);
|
gfx_wapi->get_dimensions(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *game_name, bool start_in_fullscreen) {
|
void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *game_name, bool start_in_fullscreen, uint32_t width, uint32_t height) {
|
||||||
gfx_wapi = wapi;
|
gfx_wapi = wapi;
|
||||||
gfx_rapi = rapi;
|
gfx_rapi = rapi;
|
||||||
gfx_wapi->init(game_name, start_in_fullscreen);
|
gfx_wapi->init(game_name, start_in_fullscreen, width, height);
|
||||||
gfx_rapi->init();
|
gfx_rapi->init();
|
||||||
gfx_rapi->update_framebuffer_parameters(0, SCREEN_WIDTH, SCREEN_HEIGHT, 1, false, true, true, true);
|
gfx_rapi->update_framebuffer_parameters(0, width, height, 1, false, true, true, true);
|
||||||
gfx_current_dimensions.internal_mul = 1;
|
gfx_current_dimensions.internal_mul = 1;
|
||||||
gfx_current_dimensions.width = SCREEN_WIDTH;
|
gfx_current_dimensions.width = width;
|
||||||
gfx_current_dimensions.height = SCREEN_HEIGHT;
|
gfx_current_dimensions.height = height;
|
||||||
game_framebuffer = gfx_rapi->create_framebuffer();
|
game_framebuffer = gfx_rapi->create_framebuffer();
|
||||||
game_framebuffer_msaa_resolved = gfx_rapi->create_framebuffer();
|
game_framebuffer_msaa_resolved = gfx_rapi->create_framebuffer();
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
#include "U64/PR/ultra64/types.h"
|
#include "U64/PR/ultra64/types.h"
|
||||||
|
|
||||||
|
// TODO figure out why changing these to 640x480 makes the game only render in a quarter of the window
|
||||||
|
#define SCREEN_WIDTH 320
|
||||||
|
#define SCREEN_HEIGHT 240
|
||||||
|
|
||||||
struct GfxRenderingAPI;
|
struct GfxRenderingAPI;
|
||||||
struct GfxWindowManagerAPI;
|
struct GfxWindowManagerAPI;
|
||||||
|
|
||||||
@ -64,7 +68,7 @@ extern uint32_t gfx_msaa_level;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_init(struct GfxWindowManagerAPI* wapi, struct GfxRenderingAPI* rapi, const char* game_name, bool start_in_fullscreen);
|
void gfx_init(struct GfxWindowManagerAPI* wapi, struct GfxRenderingAPI* rapi, const char* game_name, bool start_in_fullscreen, uint32_t width = SCREEN_WIDTH, uint32_t height = SCREEN_HEIGHT);
|
||||||
struct GfxRenderingAPI* gfx_get_current_rendering_api(void);
|
struct GfxRenderingAPI* gfx_get_current_rendering_api(void);
|
||||||
void gfx_start_frame(void);
|
void gfx_start_frame(void);
|
||||||
void gfx_run(Gfx* commands, const std::unordered_map<Mtx*, MtxF>& mtx_replacements);
|
void gfx_run(Gfx* commands, const std::unordered_map<Mtx*, MtxF>& mtx_replacements);
|
||||||
|
@ -130,7 +130,7 @@ static int target_fps = 60;
|
|||||||
#define FRAME_INTERVAL_US_NUMERATOR 1000000
|
#define FRAME_INTERVAL_US_NUMERATOR 1000000
|
||||||
#define FRAME_INTERVAL_US_DENOMINATOR (target_fps)
|
#define FRAME_INTERVAL_US_DENOMINATOR (target_fps)
|
||||||
|
|
||||||
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_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
@ -153,6 +153,9 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) {
|
|||||||
char title[512];
|
char title[512];
|
||||||
int len = sprintf(title, "%s (%s)", game_name, GFX_API_NAME);
|
int len = sprintf(title, "%s (%s)", game_name, GFX_API_NAME);
|
||||||
|
|
||||||
|
window_width = width;
|
||||||
|
window_height = height;
|
||||||
|
|
||||||
wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
|
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct GfxWindowManagerAPI {
|
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_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_changed_callback)(void (*on_fullscreen_changed)(bool is_now_fullscreen));
|
||||||
void (*set_fullscreen)(bool enable);
|
void (*set_fullscreen)(bool enable);
|
||||||
|
@ -254,15 +254,18 @@ namespace Ship {
|
|||||||
|
|
||||||
SetAudioPlayer();
|
SetAudioPlayer();
|
||||||
bIsFullscreen = Ship::stob(Conf["WINDOW"]["FULLSCREEN"]);
|
bIsFullscreen = Ship::stob(Conf["WINDOW"]["FULLSCREEN"]);
|
||||||
dwWidth = Ship::stoi(Conf["WINDOW"]["WINDOW WIDTH"], 320);
|
if (bIsFullscreen) {
|
||||||
dwHeight = Ship::stoi(Conf["WINDOW"]["WINDOW HEIGHT"], 240);
|
dwWidth = Ship::stoi(Conf["WINDOW"]["FULLSCREEN WIDTH"], 1920);
|
||||||
dwWidth = Ship::stoi(Conf["WINDOW"]["FULLSCREEN WIDTH"], 1920);
|
dwHeight = Ship::stoi(Conf["WINDOW"]["FULLSCREEN HEIGHT"], 1080);
|
||||||
dwHeight = Ship::stoi(Conf["WINDOW"]["FULLSCREEN HEIGHT"], 1080);
|
} else {
|
||||||
|
dwWidth = Ship::stoi(Conf["WINDOW"]["WINDOW WIDTH"], 640);
|
||||||
|
dwHeight = Ship::stoi(Conf["WINDOW"]["WINDOW HEIGHT"], 480);
|
||||||
|
}
|
||||||
dwMenubar = Ship::stoi(Conf["WINDOW"]["menubar"], 0);
|
dwMenubar = Ship::stoi(Conf["WINDOW"]["menubar"], 0);
|
||||||
const std::string& gfx_backend = Conf["WINDOW"]["GFX BACKEND"];
|
const std::string& gfx_backend = Conf["WINDOW"]["GFX BACKEND"];
|
||||||
SetWindowManager(&WmApi, &RenderingApi, gfx_backend);
|
SetWindowManager(&WmApi, &RenderingApi, gfx_backend);
|
||||||
|
|
||||||
gfx_init(WmApi, RenderingApi, GetContext()->GetName().c_str(), bIsFullscreen);
|
gfx_init(WmApi, RenderingApi, GetContext()->GetName().c_str(), bIsFullscreen, dwWidth, dwHeight);
|
||||||
WmApi->set_fullscreen_changed_callback(Window::OnFullscreenChanged);
|
WmApi->set_fullscreen_changed_callback(Window::OnFullscreenChanged);
|
||||||
WmApi->set_keyboard_callbacks(Window::KeyDown, Window::KeyUp, Window::AllKeysUp);
|
WmApi->set_keyboard_callbacks(Window::KeyDown, Window::KeyUp, Window::AllKeysUp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user