mirror of https://github.com/sm64pc/sm64pc.git
add fullscreen and filtering settings to options
filtering only applies to newly loaded textures
This commit is contained in:
parent
de49bf1ac2
commit
dbca0c413d
|
@ -16,9 +16,14 @@
|
||||||
#define TEXT_OPT_OPTIONS _("OPTIONS")
|
#define TEXT_OPT_OPTIONS _("OPTIONS")
|
||||||
#define TEXT_OPT_CAMERA _("CAMERA")
|
#define TEXT_OPT_CAMERA _("CAMERA")
|
||||||
#define TEXT_OPT_CONTROLS _("CONTROLS")
|
#define TEXT_OPT_CONTROLS _("CONTROLS")
|
||||||
|
#define TEXT_OPT_VIDEO _("DISPLAY")
|
||||||
#define TEXT_OPT_HIGHLIGHT _("O")
|
#define TEXT_OPT_HIGHLIGHT _("O")
|
||||||
#define TEXT_OPT_ANALOGUE _("Analogue Camera")
|
#define TEXT_OPT_ANALOGUE _("Analogue Camera")
|
||||||
#define TEXT_OPT_MOUSE _("Mouse Look")
|
#define TEXT_OPT_MOUSE _("Mouse Look")
|
||||||
|
#define TEXT_OPT_TEXFILTER _("Texture Filtering")
|
||||||
|
#define TEXT_OPT_FSCREEN _("Fullscreen")
|
||||||
|
#define TEXT_OPT_NEAREST _("Nearest")
|
||||||
|
#define TEXT_OPT_LINEAR _("Linear")
|
||||||
|
|
||||||
#define TEXT_OPT_UNBOUND _("NONE")
|
#define TEXT_OPT_UNBOUND _("NONE")
|
||||||
#define TEXT_OPT_PRESSKEY _("...")
|
#define TEXT_OPT_PRESSKEY _("...")
|
||||||
|
|
|
@ -31,22 +31,23 @@ static u8 optmenu_bind_idx = 0;
|
||||||
// menus: add a new submenu definition and a new
|
// menus: add a new submenu definition and a new
|
||||||
// option to the optsMain list
|
// option to the optsMain list
|
||||||
|
|
||||||
static const u8 toggleStr[][64] = {
|
static const u8 toggleStr[][16] = {
|
||||||
{ TEXT_OPT_DISABLED },
|
{ TEXT_OPT_DISABLED },
|
||||||
{ TEXT_OPT_ENABLED },
|
{ TEXT_OPT_ENABLED },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 menuStr[][64] = {
|
static const u8 menuStr[][32] = {
|
||||||
{ TEXT_OPT_HIGHLIGHT },
|
{ TEXT_OPT_HIGHLIGHT },
|
||||||
{ TEXT_OPT_BUTTON1 },
|
{ TEXT_OPT_BUTTON1 },
|
||||||
{ TEXT_OPT_BUTTON2 },
|
{ TEXT_OPT_BUTTON2 },
|
||||||
{ TEXT_OPT_OPTIONS },
|
{ TEXT_OPT_OPTIONS },
|
||||||
{ TEXT_OPT_CAMERA },
|
{ TEXT_OPT_CAMERA },
|
||||||
{ TEXT_OPT_CONTROLS },
|
{ TEXT_OPT_CONTROLS },
|
||||||
|
{ TEXT_OPT_VIDEO },
|
||||||
{ TEXT_EXIT_GAME },
|
{ TEXT_EXIT_GAME },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 optsCameraStr[][64] = {
|
static const u8 optsCameraStr[][32] = {
|
||||||
{ TEXT_OPT_CAMX },
|
{ TEXT_OPT_CAMX },
|
||||||
{ TEXT_OPT_CAMY },
|
{ TEXT_OPT_CAMY },
|
||||||
{ TEXT_OPT_INVERTX },
|
{ TEXT_OPT_INVERTX },
|
||||||
|
@ -57,7 +58,14 @@ static const u8 optsCameraStr[][64] = {
|
||||||
{ TEXT_OPT_MOUSE },
|
{ TEXT_OPT_MOUSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 bindStr[][64] = {
|
static const u8 optsVideoStr[][32] = {
|
||||||
|
{ TEXT_OPT_FSCREEN },
|
||||||
|
{ TEXT_OPT_TEXFILTER },
|
||||||
|
{ TEXT_OPT_NEAREST },
|
||||||
|
{ TEXT_OPT_LINEAR },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const u8 bindStr[][32] = {
|
||||||
{ TEXT_OPT_UNBOUND },
|
{ TEXT_OPT_UNBOUND },
|
||||||
{ TEXT_OPT_PRESSKEY },
|
{ TEXT_OPT_PRESSKEY },
|
||||||
{ TEXT_BIND_A },
|
{ TEXT_BIND_A },
|
||||||
|
@ -76,6 +84,11 @@ static const u8 bindStr[][64] = {
|
||||||
{ TEXT_BIND_RIGHT },
|
{ TEXT_BIND_RIGHT },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const u8 *filterChoices[] = {
|
||||||
|
optsVideoStr[2],
|
||||||
|
optsVideoStr[3],
|
||||||
|
};
|
||||||
|
|
||||||
enum OptType {
|
enum OptType {
|
||||||
OPT_INVALID = 0,
|
OPT_INVALID = 0,
|
||||||
OPT_TOGGLE,
|
OPT_TOGGLE,
|
||||||
|
@ -155,6 +168,11 @@ static struct Option optsControls[] = {
|
||||||
{ .type = OPT_BIND, .label = bindStr[15], .uval = configKeyStickRight, },
|
{ .type = OPT_BIND, .label = bindStr[15], .uval = configKeyStickRight, },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct Option optsVideo[] = {
|
||||||
|
{ .type = OPT_TOGGLE, .label = optsVideoStr[0], .bval = &configFullscreen, },
|
||||||
|
{ .type = OPT_CHOICE, .label = optsVideoStr[1], .uval = &configFiltering, .choices = filterChoices, .numChoices = 2 },
|
||||||
|
};
|
||||||
|
|
||||||
/* submenu definitions */
|
/* submenu definitions */
|
||||||
|
|
||||||
static struct SubMenu menuCamera = {
|
static struct SubMenu menuCamera = {
|
||||||
|
@ -169,12 +187,19 @@ static struct SubMenu menuControls = {
|
||||||
.numOpts = sizeof(optsControls) / sizeof(optsControls[0]),
|
.numOpts = sizeof(optsControls) / sizeof(optsControls[0]),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct SubMenu menuVideo = {
|
||||||
|
.label = menuStr[6],
|
||||||
|
.opts = optsVideo,
|
||||||
|
.numOpts = sizeof(optsVideo) / sizeof(optsVideo[0]),
|
||||||
|
};
|
||||||
|
|
||||||
/* main options menu definition */
|
/* main options menu definition */
|
||||||
|
|
||||||
static struct Option optsMain[] = {
|
static struct Option optsMain[] = {
|
||||||
{ .type = OPT_SUBMENU, .label = menuStr[4], .nextMenu = &menuCamera, },
|
{ .type = OPT_SUBMENU, .label = menuStr[4], .nextMenu = &menuCamera, },
|
||||||
{ .type = OPT_SUBMENU, .label = menuStr[5], .nextMenu = &menuControls, },
|
{ .type = OPT_SUBMENU, .label = menuStr[5], .nextMenu = &menuControls, },
|
||||||
{ .type = OPT_BUTTON, .label = menuStr[6], .actionFn = optmenu_act_exit, },
|
{ .type = OPT_SUBMENU, .label = menuStr[6], .nextMenu = &menuVideo, },
|
||||||
|
{ .type = OPT_BUTTON, .label = menuStr[7], .actionFn = optmenu_act_exit, },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct SubMenu menuMain = {
|
static struct SubMenu menuMain = {
|
||||||
|
@ -311,7 +336,7 @@ static void optmenu_opt_change(struct Option *opt, s32 val) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline s16 get_hudstr_centered_x(const s16 sx, const u8 *str) {
|
static inline s16 get_hudstr_centered_x(const s16 sx, const u8 *str) {
|
||||||
|
|
|
@ -32,7 +32,8 @@ struct ConfigOption {
|
||||||
*Config options and default values
|
*Config options and default values
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool configFullscreen = false;
|
bool configFullscreen = false;
|
||||||
|
unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point
|
||||||
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
|
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
|
||||||
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
|
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
|
||||||
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };
|
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };
|
||||||
|
@ -64,6 +65,7 @@ unsigned int configSkipIntro = 0;
|
||||||
|
|
||||||
static const struct ConfigOption options[] = {
|
static const struct ConfigOption options[] = {
|
||||||
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen},
|
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen},
|
||||||
|
{.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering},
|
||||||
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
|
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
|
||||||
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
|
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
|
||||||
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
|
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#define MAX_BINDS 3
|
#define MAX_BINDS 3
|
||||||
|
|
||||||
extern bool configFullscreen;
|
extern bool configFullscreen;
|
||||||
|
extern unsigned int configFiltering;
|
||||||
extern unsigned int configKeyA[];
|
extern unsigned int configKeyA[];
|
||||||
extern unsigned int configKeyB[];
|
extern unsigned int configKeyB[];
|
||||||
extern unsigned int configKeyStart[];
|
extern unsigned int configKeyStart[];
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "gfx_cc.h"
|
#include "gfx_cc.h"
|
||||||
#include "gfx_rendering_api.h"
|
#include "gfx_rendering_api.h"
|
||||||
|
#include "../configfile.h"
|
||||||
|
|
||||||
struct ShaderProgram {
|
struct ShaderProgram {
|
||||||
uint32_t shader_id;
|
uint32_t shader_id;
|
||||||
|
@ -408,9 +409,10 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) {
|
static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) {
|
||||||
|
const GLenum filter = (linear_filter && (configFiltering == 1)) ? GL_LINEAR : GL_NEAREST;
|
||||||
glActiveTexture(GL_TEXTURE0 + tile);
|
glActiveTexture(GL_TEXTURE0 + tile);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gfx_cm_to_opengl(cms));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gfx_cm_to_opengl(cms));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gfx_cm_to_opengl(cmt));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gfx_cm_to_opengl(cmt));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
static SDL_Window *wnd;
|
static SDL_Window *wnd;
|
||||||
static int inverted_scancode_table[512];
|
static int inverted_scancode_table[512];
|
||||||
|
|
||||||
extern bool configFullscreen;
|
static bool cur_fullscreen;
|
||||||
|
static uint32_t cur_width, cur_height;
|
||||||
|
|
||||||
const SDL_Scancode windows_scancode_table[] =
|
const SDL_Scancode windows_scancode_table[] =
|
||||||
{
|
{
|
||||||
|
@ -79,20 +80,18 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = {
|
||||||
{SDL_SCANCODE_KP_MULTIPLY, SDL_SCANCODE_PRINTSCREEN}
|
{SDL_SCANCODE_KP_MULTIPLY, SDL_SCANCODE_PRINTSCREEN}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gfx_sdl_set_fullscreen(bool fullscreen)
|
static void gfx_sdl_set_fullscreen(bool fullscreen) {
|
||||||
{
|
if (fullscreen == cur_fullscreen) return;
|
||||||
if (fullscreen)
|
|
||||||
{
|
if (fullscreen) {
|
||||||
SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_SetWindowFullscreen(wnd, 0);
|
SDL_SetWindowFullscreen(wnd, 0);
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
configFullscreen = fullscreen;
|
cur_fullscreen = fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_sdl_init(void) {
|
static void gfx_sdl_init(void) {
|
||||||
|
@ -190,13 +189,9 @@ static void gfx_sdl_onkeydown(int scancode) {
|
||||||
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
if (state[SDL_SCANCODE_LALT] && state[SDL_SCANCODE_RETURN])
|
if (state[SDL_SCANCODE_LALT] && state[SDL_SCANCODE_RETURN])
|
||||||
{
|
configFullscreen = !configFullscreen;
|
||||||
gfx_sdl_set_fullscreen(!configFullscreen);
|
|
||||||
}
|
|
||||||
else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen)
|
else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen)
|
||||||
{
|
configFullscreen = false;
|
||||||
gfx_sdl_set_fullscreen(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_sdl_onkeyup(int scancode) {
|
static void gfx_sdl_onkeyup(int scancode) {
|
||||||
|
@ -220,6 +215,9 @@ static void gfx_sdl_handle_events(void) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// just check if the fullscreen value has changed and toggle fullscreen if it has
|
||||||
|
if (configFullscreen != cur_fullscreen)
|
||||||
|
gfx_sdl_set_fullscreen(configFullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_sdl_start_frame(void) {
|
static bool gfx_sdl_start_frame(void) {
|
||||||
|
|
Loading…
Reference in New Issue