redone basic graphics settings (vsync, resolution, fullscreen, gl/aa)

This commit is contained in:
Zeno Rogue 2021-02-06 01:39:18 +01:00
parent 50cb77e413
commit 015f6227fa
9 changed files with 343 additions and 195 deletions

View File

@ -8,8 +8,6 @@
#include "hyper.h" #include "hyper.h"
namespace hr { namespace hr {
EX int fontscale = 100;
#if HDR #if HDR
/** configuration of the current view */ /** configuration of the current view */
struct display_data { struct display_data {
@ -1035,48 +1033,103 @@ EX void displayColorButton(int x, int y, const string& name, int key, int align,
ld textscale() { ld textscale() {
return vid.fsize / (current_display->radius * cgi.crossf) * (1+pconf.alpha) * 2; return vid.fsize / (current_display->radius * cgi.crossf) * (1+pconf.alpha) * 2;
} }
EX bool setfsize = true;
EX bool vsync_off; EX void compute_fsize() {
println(hlog, "compute_fsize() called");
EX void do_setfsize() {
dual::split_or_do([&] { dual::split_or_do([&] {
vid.fsize = min(vid.yres * fontscale/ 3200, vid.xres * fontscale/ 4800), setfsize = false; if(vid.relative_font)
vid.fsize = min(vid.yres * vid.fontscale/ 3200, vid.xres * vid.fontscale/ 4800);
else
vid.fsize = vid.abs_fsize;
println(hlog, "set fsize to ", vid.fsize);
if(vid.fsize < 6) vid.fsize = 6;
}); });
} }
EX void disable_vsync() { EX bool graphics_on;
#if CAP_SDL && CAP_GL && !ISMOBWEB
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 ); EX bool want_vsync() {
#endif if(vrhr::active())
return false;
return vid.want_vsync;
} }
EX bool need_to_apply_screen_settings() {
if(vid.want_fullscreen != vid.full)
return true;
if(make_pair(vid.xres, vid.yres) != get_requested_resolution())
return true;
if(vid.want_antialias != vid.antialias)
return true;
if(vid.wantGL != vid.usingGL)
return true;
if(want_vsync() != vid.current_vsync)
return true;
return false;
}
EX void apply_screen_settings() {
if(!need_to_apply_screen_settings()) return;
if(!graphics_on) return;
#if ISANDROID
if(vid.full != vid.want_fullscreen)
addMessage(XLAT("Reenter HyperRogue to apply this setting"));
#endif
SDL_QuitSubSystem(SDL_INIT_VIDEO);
graphics_on = false;
android_settings_changed();
init_graph();
if(vid.usingGL) {
glhr::be_textured(); glhr::be_nontextured();
}
}
EX pair<int, int> get_requested_resolution() {
if(vid.want_fullscreen && vid.change_fullscr)
return { vid.fullscreen_x, vid.fullscreen_y };
else if(vid.want_fullscreen)
return { vid.xres = vid.xscr, vid.yres = vid.yscr };
else if(vid.relative_window_size)
return { vid.xscr * vid.window_rel_x + .5, vid.yscr * vid.window_rel_y + .5 };
else
return { vid.window_x, vid.window_y };
}
#if CAP_SDL #if CAP_SDL
EX void setvideomode() { EX void setvideomode() {
DEBBI(DF_INIT | DF_GRAPH, ("setvideomode")); DEBBI(DF_INIT | DF_GRAPH, ("setvideomode"));
if(!vid.full) { vid.full = vid.want_fullscreen;
if(vid.xres > vid.xscr) vid.xres = vid.xscr * 9/10, setfsize = true;
if(vid.yres > vid.yscr) vid.yres = vid.yscr * 9/10, setfsize = true;
}
if(setfsize) do_setfsize(); tie(vid.xres, vid.yres) = get_requested_resolution();
compute_fsize();
int flags = 0; int flags = 0;
vid.antialias = vid.want_antialias;
#if CAP_GL #if CAP_GL
vid.usingGL = vid.wantGL;
if(vid.usingGL) { if(vid.usingGL) {
flags = SDL_OPENGL | SDL_HWSURFACE; flags = SDL_OPENGL | SDL_HWSURFACE;
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
if(vsync_off) disable_vsync(); vid.current_vsync = want_vsync();
if(vid.current_vsync)
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
else
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
if(vid.antialias & AA_MULTI) { if(vid.antialias & AA_MULTI) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (vid.antialias & AA_MULTI16) ? 16 : 4); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (vid.antialias & AA_MULTI16) ? 16 : 4);
} }
} }
#else
vid.usingGL = false;
#endif #endif
int sizeflag = (vid.full ? SDL_FULLSCREEN : SDL_RESIZABLE); int sizeflag = (vid.full ? SDL_FULLSCREEN : SDL_RESIZABLE);
@ -1103,7 +1156,7 @@ EX void setvideomode() {
if(vid.full && !s) { if(vid.full && !s) {
vid.xres = vid.xscr; vid.xres = vid.xscr;
vid.yres = vid.yscr; vid.yres = vid.yscr;
do_setfsize(); vid.fsize = 10;
s = s_screen = SDL_SetVideoMode(vid.xres, vid.yres, 32, flags | SDL_FULLSCREEN); s = s_screen = SDL_SetVideoMode(vid.xres, vid.yres, 32, flags | SDL_FULLSCREEN);
} }
@ -1138,7 +1191,80 @@ EX void setvideomode() {
EX bool noGUI = false; EX bool noGUI = false;
EX void initgraph() { #if CAP_SDL
EX bool sdl_on = false;
EX int SDL_Init1(Uint32 flags) {
if(!sdl_on) {
sdl_on = true;
return SDL_Init(flags);
}
else
return SDL_InitSubSystem(flags);
}
#endif
EX void init_font() {
#if CAP_SDLTTF
if(TTF_Init() != 0) {
printf("Failed to initialize TTF.\n");
exit(2);
}
#endif
}
EX void close_font() {
#if CAP_SDLTTF
for(int i=0; i<=max_font_size; i++) if(font[i]) TTF_CloseFont(font[i]);
TTF_Quit();
#endif
#if CAL_GLFONT
for(int i=0; i<=max_glfont_size; i++) if(glfont[i]) delete glfont[i];
#endif
}
EX void init_graph() {
#if CAP_SDL
if (SDL_Init1(SDL_INIT_VIDEO) == -1)
{
printf("Failed to initialize video.\n");
exit(2);
}
graphics_on = true;
#if ISWEB
get_canvas_size();
#else
if(!vid.xscr) {
const SDL_VideoInfo *inf = SDL_GetVideoInfo();
vid.xscr = vid.xres = inf->current_w;
vid.yscr = vid.yres = inf->current_h;
}
#endif
#ifdef CUSTOM_CAPTION
SDL_WM_SetCaption(CUSTOM_CAPTION, CUSTOM_CAPTION);
#else
SDL_WM_SetCaption("HyperRogue " VER, "HyperRogue " VER);
#endif
#endif
#if CAP_SDL
setvideomode();
if(!s) {
printf("Failed to initialize graphics.\n");
exit(2);
}
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(1);
#endif
#if ISANDROID
vid.full = vid.want_fullscreen;
#endif
}
EX void initialize_all() {
DEBBI(DF_INIT | DF_GRAPH, ("initgraph")); DEBBI(DF_INIT | DF_GRAPH, ("initgraph"));
@ -1157,28 +1283,6 @@ EX void initgraph() {
return; return;
} }
#if CAP_SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) == -1)
{
printf("Failed to initialize video.\n");
exit(2);
}
#if ISWEB
get_canvas_size();
#else
const SDL_VideoInfo *inf = SDL_GetVideoInfo();
vid.xscr = vid.xres = inf->current_w;
vid.yscr = vid.yres = inf->current_h;
#endif
#ifdef CUSTOM_CAPTION
SDL_WM_SetCaption(CUSTOM_CAPTION, CUSTOM_CAPTION);
#else
SDL_WM_SetCaption("HyperRogue " VER, "HyperRogue " VER);
#endif
#endif
preparesort(); preparesort();
#if CAP_CONFIG #if CAP_CONFIG
loadConfig(); loadConfig();
@ -1191,26 +1295,12 @@ EX void initgraph() {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
arg::read(2); arg::read(2);
#endif #endif
init_graph();
check_cgi(); check_cgi();
cgi.require_basics(); cgi.require_basics();
#if CAP_SDL
setvideomode();
if(!s) {
printf("Failed to initialize graphics.\n");
exit(2);
}
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(1);
#endif
#if CAP_SDLTTF init_font();
if(TTF_Init() != 0) {
printf("Failed to initialize TTF.\n");
exit(2);
}
#endif
#if CAP_SDLJOY #if CAP_SDLJOY
initJoysticks(); initJoysticks();
@ -1219,22 +1309,16 @@ EX void initgraph() {
#if CAP_SDLAUDIO #if CAP_SDLAUDIO
initAudio(); initAudio();
#endif #endif
} }
EX void cleargraph() { EX void quit_all() {
DEBBI(DF_INIT, ("clear graph")); DEBBI(DF_INIT, ("clear graph"));
#if CAP_SDLTTF
for(int i=0; i<256; i++) if(font[i]) TTF_CloseFont(font[i]);
#endif
#if CAL_GLFONT
for(int i=0; i<128; i++) if(glfont[i]) delete glfont[i];
#endif
#if CAP_SDLJOY #if CAP_SDLJOY
closeJoysticks(); closeJoysticks();
#endif #endif
#if CAP_SDL #if CAP_SDL
SDL_Quit(); SDL_Quit();
sdl_on = false;
#endif #endif
} }

View File

@ -476,11 +476,11 @@ EX videopar vid;
#define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5) #define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5)
#define DEFAULT_MONMODE (ISMOBILE ? 2 : 4) #define DEFAULT_MONMODE (ISMOBILE ? 2 : 4)
#if ISANDROID EX void android_settings_changed() {
#define ANDROID_SETTINGS settingsChanged = true; #if ISANDROID
#else settingsChanged = true;
#define ANDROID_SETTINGS ; #endif
#endif }
extern color_t floorcolors[landtypes]; extern color_t floorcolors[landtypes];
@ -619,7 +619,19 @@ EX void initConfig() {
param_i(vid.msglimit, "message limit", 5); param_i(vid.msglimit, "message limit", 5);
param_i(vid.timeformat, "message log time format", 0); param_i(vid.timeformat, "message log time format", 0);
param_i(fontscale, "fontscale", 100);
param_b(vid.relative_font, "relative_font", true)
-> editable("set relative font size", 'r')
-> set_reaction(compute_fsize);
param_i(vid.fontscale, "fontscale", 100)
-> editable(25, 400, 10, "font scale", "", 'b')
-> set_reaction(compute_fsize)
-> set_sets([] { dialog::bound_low(0); });
param_i(vid.abs_fsize, "fsize", 12)
-> editable(1, 72, 1, "font size", "", 'b')
-> set_reaction(compute_fsize)
-> set_sets([] { dialog::bound_low(0); });
param_i(vid.mobilecompasssize, "mobile compass size", 0); // ISMOBILE || ISPANDORA ? 30 : 0); param_i(vid.mobilecompasssize, "mobile compass size", 0); // ISMOBILE || ISPANDORA ? 30 : 0);
param_i(vid.radarsize, "radarsize size", 120); param_i(vid.radarsize, "radarsize size", 120);
@ -655,8 +667,11 @@ EX void initConfig() {
// basic graphics // basic graphics
addsaver(vid.usingGL, "usingGL", true); param_b(vid.wantGL, "usingGL", true)
addsaver(vid.antialias, "antialias", AA_NOGL | AA_FONT | (ISWEB ? AA_MULTI : AA_LINES) | AA_LINEWIDTH | AA_VERSION); ->editable("openGL mode", 'o');
addsaver(vid.want_antialias, "antialias", AA_NOGL | AA_FONT | (ISWEB ? AA_MULTI : AA_LINES) | AA_VERSION);
addsaver(vid.fineline, "fineline", true);
param_f(vid.linewidth, "linewidth", 1); param_f(vid.linewidth, "linewidth", 1);
addsaver(precise_width, "precisewidth", .5); addsaver(precise_width, "precisewidth", .5);
addsaver(perfect_linewidth, "perfect_linewidth", 1); addsaver(perfect_linewidth, "perfect_linewidth", 1);
@ -664,7 +679,6 @@ EX void initConfig() {
addsaver(fat_edges, "fat-edges"); addsaver(fat_edges, "fat-edges");
param_f(vid.sspeed, "sspeed", "scrollingspeed", 0); param_f(vid.sspeed, "sspeed", "scrollingspeed", 0);
param_f(vid.mspeed, "mspeed", "movement speed", 1); param_f(vid.mspeed, "mspeed", "movement speed", 1);
addsaver(vid.full, "fullscreen", false);
addsaver(vid.aurastr, "aura strength", ISMOBILE ? 0 : 128); addsaver(vid.aurastr, "aura strength", ISMOBILE ? 0 : 128);
addsaver(vid.aurasmoothen, "aura smoothen", 5); addsaver(vid.aurasmoothen, "aura smoothen", 5);
param_enum(vid.graphglyph, "graphglyph", "graphical items/kills", 1) param_enum(vid.graphglyph, "graphglyph", "graphical items/kills", 1)
@ -675,9 +689,44 @@ EX void initConfig() {
addsaver(vid.particles, "extra effects", 1); addsaver(vid.particles, "extra effects", 1);
param_i(vid.framelimit, "frame limit", 999); param_i(vid.framelimit, "frame limit", 999);
addsaver(vid.xres, "xres");
addsaver(vid.yres, "yres"); param_b(vid.want_vsync, "vsync", true)
param_i(vid.fsize, "font size"); ->editable("vsync", 'v');
param_b(vid.want_fullscreen, "fullscreen", false)
->editable("fullscreen mode", 'f');
param_b(vid.change_fullscr, "fullscreen_change", false)
->editable("use specific fullscreen resolution", 'g');
param_b(vid.relative_window_size, "window_relative", true)
->editable("specify relative window size", 'g');
param_custom(vid.xres, "xres", [] (char ch) {}, 0);
param_custom(vid.yres, "yres", [] (char ch) {}, 0);
param_i(vid.fullscreen_x, "fullscreen_x", 1280)
-> editable(640, 3840, 640, "fullscreen resolution to use (X)", "", 'x')
-> set_sets([] { dialog::bound_low(640); });
param_i(vid.fullscreen_y, "fullscreen_y", 1024)
-> editable(480, 2160, 480, "fullscreen resolution to use (X)", "", 'x')
-> set_sets([] { dialog::bound_low(480); });
param_i(vid.window_x, "window_x", 1280)
-> editable(160, 3840, 160, "window resolution to use (X)", "", 'x')
-> set_sets([] { dialog::bound_low(160); });
param_i(vid.window_y, "window_y", 1024)
-> editable(120, 2160, 120, "window resolution to use (Y)", "", 'x')
-> set_sets([] { dialog::bound_low(120); });
param_f(vid.window_rel_x, "window_rel_x", .9)
-> editable(.1, 1, .1, "screen size percentage to use (X)", "", 'x')
-> set_sets([] { dialog::bound_low(.1); });
param_f(vid.window_rel_y, "window_rel_y", .9)
-> editable(.1, 1, .1, "screen size percentage to use (X)", "", 'x')
-> set_sets([] { dialog::bound_low(.1); });
param_b(vid.darkhepta, "mark heptagons", false); param_b(vid.darkhepta, "mark heptagons", false);
for(auto& lp: linepatterns::patterns) { for(auto& lp: linepatterns::patterns) {
@ -1389,24 +1438,21 @@ EX void show_vector_settings() {
vid.usingGL ? "" : XLAT("Line width setting is only taken into account in OpenGL.")); vid.usingGL ? "" : XLAT("Line width setting is only taken into account in OpenGL."));
}); });
dialog::addSelItem(XLAT("line quality"), its(vid.linequality), 'L'); dialog::addSelItem(XLAT("line quality"), its(vid.linequality), 'l');
dialog::add_action([] { dialog::add_action([] {
dialog::editNumber(vid.linequality, -3, 5, 1, 1, XLAT("line quality"), dialog::editNumber(vid.linequality, -3, 5, 1, 1, XLAT("line quality"),
XLAT("Higher numbers make the curved lines smoother, but reduce the performance.")); XLAT("Higher numbers make the curved lines smoother, but reduce the performance."));
}); });
dialog::addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'O'); dialog::addBoolItem("perfect width", perfect_linewidth == 2, 'p');
dialog::add_action([] () {
vid.antialias ^= AA_LINEWIDTH;
});
dialog::addBoolItem("perfect width", perfect_linewidth == 2, 'P');
if(perfect_linewidth == 1) if(perfect_linewidth == 1)
dialog::lastItem().value = XLAT("shots only"); dialog::lastItem().value = XLAT("shots only");
dialog::add_action([] { perfect_linewidth = (1 + perfect_linewidth) % 3; }); dialog::add_action([] { perfect_linewidth = (1 + perfect_linewidth) % 3; });
if(vid.antialias & AA_LINEWIDTH) { dialog::addBoolItem_action("finer lines at the boundary", vid.fineline, 'O');
dialog::addSelItem("variable width", fts(precise_width), 'M');
if(vid.fineline) {
dialog::addSelItem("variable width", fts(precise_width), 'm');
dialog::add_action([] () { dialog::add_action([] () {
dialog::editNumber(precise_width, 0, 2, 0.1, 0.5, dialog::editNumber(precise_width, 0, 2, 0.1, 0.5,
XLAT("variable width"), XLAT("lines longer than this value will be split into shorter lines, with width computed separately for each of them.") XLAT("variable width"), XLAT("lines longer than this value will be split into shorter lines, with width computed separately for each of them.")
@ -1419,11 +1465,11 @@ EX void show_vector_settings() {
dialog::addBreak(100); dialog::addBreak(100);
dialog::addInfo(XLAT("hint: press Alt while testing modes")); dialog::addInfo(XLAT("hint: press Alt while testing modes"));
dialog::addBreak(100); dialog::addBreak(100);
dialog::addBoolItem_action(XLAT("disable shadows"), noshadow, 'F'); dialog::addBoolItem_action(XLAT("disable shadows"), noshadow, 'f');
dialog::addBoolItem_action(XLAT("bright mode"), bright, 'G'); dialog::addBoolItem_action(XLAT("bright mode"), bright, 'g');
dialog::addBoolItem_action(XLAT("colorblind simulation"), cblind, 'H'); dialog::addBoolItem_action(XLAT("colorblind simulation"), cblind, 'h');
dialog::addBoolItem_action(XLAT("no fill in neon mode"), neon_nofill, 'N'); dialog::addBoolItem_action(XLAT("no fill in neon mode"), neon_nofill, 'n');
dialog::addBreak(50); dialog::addBreak(50);
dialog::addBack(); dialog::addBack();
@ -1436,19 +1482,76 @@ EX void showGraphConfig() {
dialog::init(XLAT("graphics configuration")); dialog::init(XLAT("graphics configuration"));
#if !ISIOS && !ISWEB
add_edit(vid.want_fullscreen);
if(vid.want_fullscreen) {
add_edit(vid.change_fullscr);
if(vid.change_fullscr)
add_edit(vid.fullscreen_x), add_edit(vid.fullscreen_y);
else
dialog::addBreak(200);
}
else {
add_edit(vid.relative_window_size);
if(vid.relative_window_size)
add_edit(vid.window_rel_x), add_edit(vid.window_rel_y);
else
add_edit(vid.window_x), add_edit(vid.window_y);
}
#endif
#if CAP_GLORNOT #if CAP_GLORNOT
dialog::addBoolItem(XLAT("openGL mode"), vid.usingGL, 'o'); add_edit(vid.wantGL);
#endif #endif
if(!vid.usingGL) if(!vid.usingGL) {
dialog::addBoolItem(XLAT("anti-aliasing"), vid.antialias & AA_NOGL, 'O'); dialog::addBoolItem(XLAT("anti-aliasing"), vid.want_antialias & AA_NOGL, 'O');
dialog::add_action([] {
if(vid.usingGL) if(!vid.usingGL)
vid.want_antialias ^= AA_NOGL | AA_FONT;
});
}
else {
dialog::addSelItem(XLAT("anti-aliasing"), dialog::addSelItem(XLAT("anti-aliasing"),
(vid.antialias & AA_POLY) ? "polygons" : (vid.want_antialias & AA_POLY) ? "polygons" :
(vid.antialias & AA_LINES) ? "lines" : (vid.want_antialias & AA_LINES) ? "lines" :
(vid.antialias & AA_MULTI) ? "multisampling" : (vid.want_antialias & AA_MULTI) ? "multisampling" :
"NO", 'O'); "NO", 'O');
dialog::add_action([] {
if(vid.want_antialias & AA_MULTI)
vid.want_antialias ^= AA_MULTI;
else if(vid.want_antialias & AA_POLY)
vid.want_antialias ^= AA_POLY | AA_LINES | AA_MULTI;
else if(vid.want_antialias & AA_LINES)
vid.want_antialias |= AA_POLY;
else
vid.want_antialias |= AA_LINES;
});
}
if(vid.usingGL) {
if(vrhr::active())
dialog::addInfo(XLAT("(vsync disabled in VR)"));
else
add_edit(vid.want_vsync);
}
else
dialog::addBreak(100);
if(need_to_apply_screen_settings()) {
dialog::addItem(XLAT("apply changes"), 'A');
dialog::add_action(apply_screen_settings);
dialog::addBreak(100);
}
else
dialog::addBreak(200);
add_edit(vid.relative_font);
if(vid.relative_font)
add_edit(vid.fontscale);
else
add_edit(vid.abs_fsize);
dialog::addSelItem(XLAT("vector settings"), XLAT("width") + " " + fts(vid.linewidth), 'w'); dialog::addSelItem(XLAT("vector settings"), XLAT("width") + " " + fts(vid.linewidth), 'w');
dialog::add_action_push(show_vector_settings); dialog::add_action_push(show_vector_settings);
@ -1458,11 +1561,7 @@ EX void showGraphConfig() {
if(getcstat == 'l') if(getcstat == 'l')
mouseovers = XLAT("Reduce the framerate limit to conserve CPU energy"); mouseovers = XLAT("Reduce the framerate limit to conserve CPU energy");
#endif #endif
#if !ISIOS && !ISWEB
dialog::addBoolItem(XLAT("fullscreen mode"), (vid.full), 'f');
#endif
dialog::addSelItem(XLAT("scrolling speed"), fts(vid.sspeed), 'a'); dialog::addSelItem(XLAT("scrolling speed"), fts(vid.sspeed), 'a');
dialog::addSelItem(XLAT("camera movement speed"), fts(camera_speed), 'c'); dialog::addSelItem(XLAT("camera movement speed"), fts(camera_speed), 'c');
@ -1489,8 +1588,6 @@ EX void showGraphConfig() {
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
dialog::handleNavigation(sym, uni); dialog::handleNavigation(sym, uni);
if(uni == 'O') uni = 'o', shiftmul = -1;
char xuni = uni | 96; char xuni = uni | 96;
if((uni >= 32 && uni < 64) || uni == 'L' || uni == 'C') xuni = uni; if((uni >= 32 && uni < 64) || uni == 'L' || uni == 'C') xuni = uni;
@ -1507,30 +1604,6 @@ EX void showGraphConfig() {
XLAT("movement animation speed"), XLAT("movement animation speed"),
XLAT("+5 = move instantly")); XLAT("+5 = move instantly"));
else if(xuni == 'f') switchFullscreen();
#if CAP_GLORNOT
else if(xuni == 'o' && shiftmul > 0) switchGL();
#endif
else if(xuni == 'o' && shiftmul < 0) {
if(!vid.usingGL)
vid.antialias ^= AA_NOGL | AA_FONT;
else if(vid.antialias & AA_MULTI)
vid.antialias ^= AA_MULTI;
else if(vid.antialias & AA_POLY)
vid.antialias ^= AA_POLY | AA_LINES | AA_MULTI;
else if(vid.antialias & AA_LINES)
vid.antialias |= AA_POLY;
else
vid.antialias |= AA_LINES;
#if CAP_SDL
setvideomode();
#endif
}
// if(xuni == 'b') vid.antialias ^= AA_LINEWIDTH;
#if CAP_FRAMELIMIT #if CAP_FRAMELIMIT
else if(xuni == 'l') { else if(xuni == 'l') {
dialog::editNumber(vid.framelimit, 5, 300, 10, 300, XLAT("framerate limit"), ""); dialog::editNumber(vid.framelimit, 5, 300, 10, 300, XLAT("framerate limit"), "");
@ -1545,36 +1618,6 @@ EX void showGraphConfig() {
}; };
} }
EX void switchFullscreen() {
vid.full = !vid.full;
#if ISANDROID
addMessage(XLAT("Reenter HyperRogue to apply this setting"));
ANDROID_SETTINGS
#endif
#if CAP_SDL
if(true) {
vid.xres = vid.full ? vid.xscr : 9999;
vid.yres = vid.full ? vid.yscr : 9999;
extern bool setfsize;
setfsize = true;
}
setvideomode();
#endif
}
EX void switchGL() {
vid.usingGL = !vid.usingGL;
if(vid.usingGL) addMessage(XLAT("openGL mode enabled"));
if(!vid.usingGL) addMessage(XLAT("openGL mode disabled"));
ANDROID_SETTINGS;
#if CAP_SDL
setvideomode();
if(vid.usingGL) {
glhr::be_textured(); glhr::be_nontextured();
}
#endif
}
EX void edit_whatever(char type, int index) { EX void edit_whatever(char type, int index) {
if(type == 'f') { if(type == 'f') {
dialog::editNumber(whatever[index], -10, 10, 1, 0, XLAT("whatever"), dialog::editNumber(whatever[index], -10, 10, 1, 0, XLAT("whatever"),
@ -1660,14 +1703,6 @@ EX void configureInterface() {
add_edit(vid.msgleft); add_edit(vid.msgleft);
dialog::addSelItem(XLAT("font scale"), its(fontscale), 'b');
dialog::add_action([] {
dialog::editNumber(fontscale, 25, 400, 10, 100, XLAT("font scale"), "");
const int minfontscale = ISMOBILE ? 50 : 25;
dialog::reaction = [] () { setfsize = true; do_setfsize(); };
dialog::bound_low(minfontscale);
});
add_edit(glyphsortorder); add_edit(glyphsortorder);
add_edit(vid.graphglyph); add_edit(vid.graphglyph);
@ -2576,12 +2611,12 @@ EX void selectLanguageScreen() {
if(uni == '0') { if(uni == '0') {
vid.language = -1; vid.language = -1;
ANDROID_SETTINGS; android_settings_changed();
} }
else if(uni >= 'a' && uni < 'a'+NUMLAN) { else if(uni >= 'a' && uni < 'a'+NUMLAN) {
vid.language = uni - 'a'; vid.language = uni - 'a';
ANDROID_SETTINGS; android_settings_changed();
} }
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
@ -2846,7 +2881,7 @@ EX int read_config_args() {
if(argis("-c")) { PHASE(1); shift(); conffile = argcs(); } if(argis("-c")) { PHASE(1); shift(); conffile = argcs(); }
// change the configuration from the command line // change the configuration from the command line
else if(argis("-aa")) { PHASEFROM(2); shift(); vid.antialias = argi(); } else if(argis("-aa")) { PHASEFROM(2); shift(); vid.want_antialias = argi(); apply_screen_settings(); }
else if(argis("-lw")) { PHASEFROM(2); shift_arg_formula(vid.linewidth); } else if(argis("-lw")) { PHASEFROM(2); shift_arg_formula(vid.linewidth); }
else if(argis("-wm")) { PHASEFROM(2); shift(); vid.wallmode = argi(); } else if(argis("-wm")) { PHASEFROM(2); shift(); vid.wallmode = argi(); }
else if(argis("-mm")) { PHASEFROM(2); shift(); vid.monmode = argi(); } else if(argis("-mm")) { PHASEFROM(2); shift(); vid.monmode = argi(); }
@ -2858,10 +2893,8 @@ EX int read_config_args() {
// non-configurable options // non-configurable options
else if(argis("-vsync_off")) { else if(argis("-vsync_off")) {
#if CAP_SDL && CAP_GL vid.want_vsync = false;
vsync_off = true; apply_screen_settings();
if(curphase == 3) setvideomode();
#endif
} }
else if(argis("-aura")) { else if(argis("-aura")) {
PHASEFROM(2); PHASEFROM(2);
@ -2923,7 +2956,7 @@ EX int read_config_args() {
sscanf(argcs(), "%dx%dx%d", &clWidth, &clHeight, &clFont); sscanf(argcs(), "%dx%dx%d", &clWidth, &clHeight, &clFont);
if(clWidth) vid.xres = clWidth; if(clWidth) vid.xres = clWidth;
if(clHeight) vid.yres = clHeight; if(clHeight) vid.yres = clHeight;
if(clFont) vid.fsize = clFont; if(clFont) vid.abs_fsize = clFont, vid.relative_font = true;
} }
else if(argis("-msm")) { else if(argis("-msm")) {
PHASEFROM(2); memory_saving_mode = true; PHASEFROM(2); memory_saving_mode = true;
@ -2969,8 +3002,8 @@ EX int read_config_args() {
else if(argis("-msens")) { else if(argis("-msens")) {
PHASEFROM(2); shift_arg_formula(mouseaim_sensitivity); PHASEFROM(2); shift_arg_formula(mouseaim_sensitivity);
} }
TOGGLE('o', vid.usingGL, switchGL()) TOGGLE('o', vid.usingGL, apply_screen_settings())
TOGGLE('f', vid.full, switchFullscreen()) TOGGLE('f', vid.want_fullscreen, apply_screen_settings())
else if(argis("-noshaders")) { else if(argis("-noshaders")) {
PHASE(1); PHASE(1);
glhr::noshaders = true; glhr::noshaders = true;

View File

@ -212,6 +212,14 @@ EX SDL_Joystick* sticks[8];
EX int numsticks; EX int numsticks;
EX void initJoysticks() { EX void initJoysticks() {
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
{
printf("Failed to initialize joysticks.\n");
numsticks = 0;
return;
}
DEBB(DF_INIT, ("init joysticks")); DEBB(DF_INIT, ("init joysticks"));
numsticks = SDL_NumJoysticks(); numsticks = SDL_NumJoysticks();
if(numsticks > 8) numsticks = 8; if(numsticks > 8) numsticks = 8;
@ -652,12 +660,17 @@ int cframelimit = 1000;
EX void resize_screen_to(int x, int y) { EX void resize_screen_to(int x, int y) {
dual::split_or_do([&] { dual::split_or_do([&] {
vid.xres = x;
vid.yres = y;
vid.killreduction = 0; vid.killreduction = 0;
if(vid.want_fullscreen) return;
if(vid.relative_window_size) {
vid.window_rel_x = x * 1. / vid.xscr;
vid.window_rel_y = y * 1. / vid.yscr;
}
else {
vid.window_x = x;
vid.window_y = y;
}
}); });
extern bool setfsize;
setfsize = true;
setvideomode(); setvideomode();
} }
@ -963,7 +976,8 @@ EX void handle_event(SDL_Event& ev) {
numlock_on = ev.key.keysym.mod & KMOD_NUM; numlock_on = ev.key.keysym.mod & KMOD_NUM;
if(sym == SDLK_RETURN && (ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { if(sym == SDLK_RETURN && (ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
sym = 0; uni = 0; sym = 0; uni = 0;
switchFullscreen(); vid.want_fullscreen = !vid.want_fullscreen;
apply_screen_settings();
} }
} }

View File

@ -790,7 +790,7 @@ EX ld scale_at(const shiftmatrix& T) {
EX int perfect_linewidth = 1; EX int perfect_linewidth = 1;
EX ld linewidthat(const shiftpoint& h) { EX ld linewidthat(const shiftpoint& h) {
if(!(vid.antialias & AA_LINEWIDTH)) return 1; if(!vid.fineline) return 1;
else if(hyperbolic && pmodel == mdDisk && pconf.alpha == 1 && !ISWEB && !flat_on) { else if(hyperbolic && pmodel == mdDisk && pconf.alpha == 1 && !ISWEB && !flat_on) {
double dz = h[LDIM]; double dz = h[LDIM];
if(dz < 1) return 1; if(dz < 1) return 1;

View File

@ -89,8 +89,9 @@ namespace spiral {
velx=1; vely=1; velx=1; vely=1;
bool dosave = false; bool dosave = false;
bool saveGL = vid.usingGL; bool saveGL = vid.wantGL;
if(saveGL) switchGL(); // { vid.usingGL = false; setvideomode(); } vid.wantGL = false;
apply_screen_settings();
while(true) { while(true) {
@ -138,7 +139,8 @@ namespace spiral {
breakloop: breakloop:
quickmap.clear(); quickmap.clear();
if(saveGL) switchGL(); // { vid.usingGL = true; setvideomode(); } vid.wantGL = saveGL;
apply_screen_settings();
} }
} }

17
hyper.h
View File

@ -300,7 +300,12 @@ struct videopar {
int linequality; int linequality;
bool want_fullscreen;
bool full; bool full;
bool change_fullscr;
bool relative_window_size;
bool want_vsync;
bool current_vsync;
int graphglyph; // graphical glyphs int graphglyph; // graphical glyphs
bool darkhepta; bool darkhepta;
@ -310,10 +315,15 @@ struct videopar {
int xscr, yscr; int xscr, yscr;
int fullscreen_x, fullscreen_y;
int window_x, window_y;
ld window_rel_x, window_rel_y;
bool grid; bool grid;
bool particles; bool particles;
int fsize; bool relative_font;
int fsize, abs_fsize, fontscale;
int flashtime; int flashtime;
int wallmode, monmode, axes, highlightmode; int wallmode, monmode, axes, highlightmode;
@ -322,13 +332,16 @@ struct videopar {
int msgleft, msglimit; int msgleft, msglimit;
bool wantGL;
int want_antialias;
bool fineline;
bool usingGL; bool usingGL;
int antialias; int antialias;
#define AA_NOGL 1 #define AA_NOGL 1
#define AA_VERSION 2 #define AA_VERSION 2
#define AA_LINES 4 #define AA_LINES 4
#define AA_POLY 8 #define AA_POLY 8
#define AA_LINEWIDTH 16
#define AA_FONT 32 #define AA_FONT 32
#define AA_MULTI 64 #define AA_MULTI 64
#define AA_MULTI16 128 // not configurable #define AA_MULTI16 128 // not configurable

View File

@ -51,10 +51,10 @@ void loadOldConfig(FILE *f) {
if(err == 4) { if(err == 4) {
vid.scale = a; pconf.alpha = c; vid.sspeed = d; vid.scale = a; pconf.alpha = c; vid.sspeed = d;
} }
err=fscanf(f, "%d%d%d%d%d%d%d", &vid.wallmode, &vid.monmode, &vid.axes, &musicvolume, &vid.framelimit, &gl, &vid.antialias); err=fscanf(f, "%d%d%d%d%d%d%d", &vid.wallmode, &vid.monmode, &vid.axes, &musicvolume, &vid.framelimit, &gl, &vid.want_antialias);
vid.usingGL = gl; vid.usingGL = gl;
if(vid.antialias == 0) vid.antialias = AA_VERSION | AA_LINES | AA_LINEWIDTH; if(vid.want_antialias == 0) vid.want_antialias = AA_VERSION | AA_LINES | AA_LINEWIDTH;
if(vid.antialias == 1) vid.antialias = AA_NOGL | AA_VERSION | AA_LINES | AA_LINEWIDTH | AA_FONT; if(vid.want_antialias == 1) vid.want_antialias = AA_NOGL | AA_VERSION | AA_LINES | AA_LINEWIDTH | AA_FONT;
double jps = vid.joypanspeed; double jps = vid.joypanspeed;
err=fscanf(f, "%d%d%d%lf%d%d", &vid.joyvalue, &vid.joyvalue2, &vid.joypanthreshold, &jps, &aa, &vid.flashtime); err=fscanf(f, "%d%d%d%lf%d%d", &vid.joyvalue, &vid.joyvalue2, &vid.joypanthreshold, &jps, &aa, &vid.flashtime);
vid.joypanspeed = jps; vid.joypanspeed = jps;

View File

@ -1575,7 +1575,7 @@ EX void initAll() {
firstland0 = firstland; firstland0 = firstland;
// initlanguage(); // initlanguage();
initgraph(); initialize_all();
#if CAP_SAVE #if CAP_SAVE
loadsave(); loadsave();
if(IRREGULAR) irr::auto_creator(); if(IRREGULAR) irr::auto_creator();
@ -1603,7 +1603,7 @@ EX void finishAll() {
#endif #endif
clearMemory(); clearMemory();
#if !ISMOBILE #if !ISMOBILE
cleargraph(); quit_all();
#endif #endif
achievement_close(); achievement_close();

2
vr.cpp
View File

@ -755,6 +755,8 @@ EX void start_vr() {
return; return;
} }
else println(hlog, "VR initialized successfully"); else println(hlog, "VR initialized successfully");
apply_screen_settings();
string driver = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String ); string driver = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String );
string display = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String ); string display = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String );