diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 6fd70bd23..5a5c36467 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6982,7 +6982,7 @@ bool FurnaceGUI::init() { return false; } - rend->preInit(); + rend->preInit(e->getConfObject()); logD("creating window..."); sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW,scrH,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0)|rend->getWindowFlags()); diff --git a/src/gui/gui.h b/src/gui/gui.h index 0f1839130..90e181259 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1509,7 +1509,7 @@ class FurnaceGUIRender { virtual const char* getDeviceName(); virtual const char* getAPIVersion(); virtual void setSwapInterval(int swapInterval); - virtual void preInit(); + virtual void preInit(const DivConfig& conf); virtual bool init(SDL_Window* win, int swapInterval); virtual void initGUI(SDL_Window* win); virtual void quitGUI(); @@ -1896,6 +1896,12 @@ class FurnaceGUI { int frameRateLimit; int displayRenderTime; int inputRepeat; + int glRedSize; + int glGreenSize; + int glBlueSize; + int glAlphaSize; + int glDepthSize; + int glDoubleBuffer; unsigned int maxUndoSteps; float vibrationStrength; int vibrationLength; @@ -2139,6 +2145,12 @@ class FurnaceGUI { frameRateLimit(60), displayRenderTime(0), inputRepeat(0), + glRedSize(8), + glGreenSize(8), + glBlueSize(8), + glAlphaSize(0), + glDepthSize(24), + glDoubleBuffer(1), maxUndoSteps(100), vibrationStrength(0.5f), vibrationLength(20), diff --git a/src/gui/render/abstract.cpp b/src/gui/render/abstract.cpp index c8d9be046..48710cb2f 100644 --- a/src/gui/render/abstract.cpp +++ b/src/gui/render/abstract.cpp @@ -128,7 +128,7 @@ const char* FurnaceGUIRender::getAPIVersion() { void FurnaceGUIRender::setSwapInterval(int swapInterval) { } -void FurnaceGUIRender::preInit() { +void FurnaceGUIRender::preInit(const DivConfig& conf) { } bool FurnaceGUIRender::init(SDL_Window* win, int swapInterval) { diff --git a/src/gui/render/renderDX11.cpp b/src/gui/render/renderDX11.cpp index 83ef53520..75ff58fc9 100644 --- a/src/gui/render/renderDX11.cpp +++ b/src/gui/render/renderDX11.cpp @@ -397,7 +397,7 @@ void FurnaceGUIRenderDX11::setSwapInterval(int swapInt) { swapInterval=swapInt; } -void FurnaceGUIRenderDX11::preInit() { +void FurnaceGUIRenderDX11::preInit(const DivConfig& conf) { } const float wipeVertices[4][4]={ diff --git a/src/gui/render/renderDX11.h b/src/gui/render/renderDX11.h index eba32218c..1fd015122 100644 --- a/src/gui/render/renderDX11.h +++ b/src/gui/render/renderDX11.h @@ -89,7 +89,7 @@ class FurnaceGUIRenderDX11: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/render/renderGL.cpp b/src/gui/render/renderGL.cpp index f8ba1a0d4..dffd16d20 100644 --- a/src/gui/render/renderGL.cpp +++ b/src/gui/render/renderGL.cpp @@ -580,7 +580,7 @@ void FurnaceGUIRenderGL::setSwapInterval(int swapInterval) { } } -void FurnaceGUIRenderGL::preInit() { +void FurnaceGUIRenderGL::preInit(const DivConfig& conf) { #if defined(USE_GLES) SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_PROFILE_ES); @@ -603,12 +603,12 @@ void FurnaceGUIRenderGL::preInit() { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,0); #endif - SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,0); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,24); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE,conf.getInt("glRedSize",8)); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,conf.getInt("glGreenSize",8)); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,conf.getInt("glBlueSize",8)); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,conf.getInt("glAlphaSize",0)); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,conf.getInt("glDoubleBuffer",1)); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,conf.getInt("glDepthSize",24)); } #define LOAD_PROC_MANDATORY(_v,_t,_s) \ diff --git a/src/gui/render/renderGL.h b/src/gui/render/renderGL.h index eb452eb9a..4664bec34 100644 --- a/src/gui/render/renderGL.h +++ b/src/gui/render/renderGL.h @@ -82,7 +82,7 @@ class FurnaceGUIRenderGL: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/render/renderGL1.cpp b/src/gui/render/renderGL1.cpp index 1ce8e054f..9fb4485b5 100644 --- a/src/gui/render/renderGL1.cpp +++ b/src/gui/render/renderGL1.cpp @@ -245,18 +245,18 @@ void FurnaceGUIRenderGL1::setSwapInterval(int swapInterval) { } } -void FurnaceGUIRenderGL1::preInit() { +void FurnaceGUIRenderGL1::preInit(const DivConfig& conf) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1); - SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,0); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,24); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE,conf.getInt("glRedSize",8)); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,conf.getInt("glGreenSize",8)); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,conf.getInt("glBlueSize",8)); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,conf.getInt("glAlphaSize",0)); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,conf.getInt("glDoubleBuffer",1)); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,conf.getInt("glDepthSize",24)); } #define LOAD_PROC_MANDATORY(_v,_t,_s) \ @@ -334,4 +334,4 @@ void FurnaceGUIRenderGL1::quitGUI() { // sadly, OpenGL 1.1 doesn't have the ability to recover from death... bool FurnaceGUIRenderGL1::isDead() { return false; -} \ No newline at end of file +} diff --git a/src/gui/render/renderGL1.h b/src/gui/render/renderGL1.h index d80ca073b..f6081be6a 100644 --- a/src/gui/render/renderGL1.h +++ b/src/gui/render/renderGL1.h @@ -56,7 +56,7 @@ class FurnaceGUIRenderGL1: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/render/renderMetal.h b/src/gui/render/renderMetal.h index db927e594..8aaa88d89 100644 --- a/src/gui/render/renderMetal.h +++ b/src/gui/render/renderMetal.h @@ -52,7 +52,7 @@ class FurnaceGUIRenderMetal: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/render/renderMetal.mm b/src/gui/render/renderMetal.mm index 45ed95562..8649b66a0 100644 --- a/src/gui/render/renderMetal.mm +++ b/src/gui/render/renderMetal.mm @@ -218,7 +218,7 @@ void FurnaceGUIRenderMetal::setSwapInterval(int swapInterval) { } } -void FurnaceGUIRenderMetal::preInit() { +void FurnaceGUIRenderMetal::preInit(const DivConfig& conf) { SDL_SetHint(SDL_HINT_RENDER_DRIVER,"metal"); priv=new FurnaceGUIRenderMetalPrivate; } diff --git a/src/gui/render/renderSDL.cpp b/src/gui/render/renderSDL.cpp index 7adfe62e5..a5f95ead9 100644 --- a/src/gui/render/renderSDL.cpp +++ b/src/gui/render/renderSDL.cpp @@ -182,7 +182,7 @@ void FurnaceGUIRenderSDL::setSwapInterval(int swapInterval) { } } -void FurnaceGUIRenderSDL::preInit() { +void FurnaceGUIRenderSDL::preInit(const DivConfig& conf) { } bool FurnaceGUIRenderSDL::init(SDL_Window* win, int swapInterval) { diff --git a/src/gui/render/renderSDL.h b/src/gui/render/renderSDL.h index 370b11289..46a47559a 100644 --- a/src/gui/render/renderSDL.h +++ b/src/gui/render/renderSDL.h @@ -50,7 +50,7 @@ class FurnaceGUIRenderSDL: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/render/renderSoftware.cpp b/src/gui/render/renderSoftware.cpp index 0b54c37bb..8ca812661 100644 --- a/src/gui/render/renderSoftware.cpp +++ b/src/gui/render/renderSoftware.cpp @@ -160,7 +160,7 @@ const char* FurnaceGUIRenderSoftware::getAPIVersion() { void FurnaceGUIRenderSoftware::setSwapInterval(int swapInterval) { } -void FurnaceGUIRenderSoftware::preInit() { +void FurnaceGUIRenderSoftware::preInit(const DivConfig& conf) { } bool FurnaceGUIRenderSoftware::init(SDL_Window* win, int swapInterval) { diff --git a/src/gui/render/renderSoftware.h b/src/gui/render/renderSoftware.h index 498dec69a..05315dab8 100644 --- a/src/gui/render/renderSoftware.h +++ b/src/gui/render/renderSoftware.h @@ -47,7 +47,7 @@ class FurnaceGUIRenderSoftware: public FurnaceGUIRender { const char* getDeviceName(); const char* getAPIVersion(); void setSwapInterval(int swapInterval); - void preInit(); + void preInit(const DivConfig& conf); bool init(SDL_Window* win, int swapInterval); void initGUI(SDL_Window* win); void quitGUI(); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index a3281d4a9..d316d0094 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -449,22 +449,60 @@ void FurnaceGUI::drawSettings() { if (ImGui::IsItemHovered()) { ImGui::SetTooltip("you may need to restart Furnace for this setting to take effect."); } - if (curRenderBackend=="SDL") { - if (ImGui::BeginCombo("Render driver",settings.renderDriver.empty()?"Automatic":settings.renderDriver.c_str())) { - if (ImGui::Selectable("Automatic",settings.renderDriver.empty())) { - settings.renderDriver=""; - settingsChanged=true; - } - for (String& i: availRenderDrivers) { - if (ImGui::Selectable(i.c_str(),i==settings.renderDriver)) { - settings.renderDriver=i; + + if (ImGui::TreeNode("Advanced render backend settings")) { + if (curRenderBackend=="SDL") { + if (ImGui::BeginCombo("Render driver",settings.renderDriver.empty()?"Automatic":settings.renderDriver.c_str())) { + if (ImGui::Selectable("Automatic",settings.renderDriver.empty())) { + settings.renderDriver=""; settingsChanged=true; } + for (String& i: availRenderDrivers) { + if (ImGui::Selectable(i.c_str(),i==settings.renderDriver)) { + settings.renderDriver=i; + settingsChanged=true; + } + } + ImGui::EndCombo(); } - ImGui::EndCombo(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("you may need to restart Furnace for this setting to take effect."); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("you may need to restart Furnace for this setting to take effect."); + } + } else if (curRenderBackend.find("OpenGL")==0) { + ImGui::TextWrapped("beware: changing these settings may render Furnace unusable! do so at your own risk.\nstart Furnace with -safemode if you mess something up."); + if (ImGui::InputInt("Red bits",&settings.glRedSize)) { + if (settings.glRedSize<0) settings.glRedSize=0; + if (settings.glRedSize>32) settings.glRedSize=32; + settingsChanged=true; + } + if (ImGui::InputInt("Green bits",&settings.glGreenSize)) { + if (settings.glGreenSize<0) settings.glGreenSize=0; + if (settings.glGreenSize>32) settings.glGreenSize=32; + settingsChanged=true; + } + if (ImGui::InputInt("Blue bits",&settings.glBlueSize)) { + if (settings.glBlueSize<0) settings.glBlueSize=0; + if (settings.glBlueSize>32) settings.glBlueSize=32; + settingsChanged=true; + } + if (ImGui::InputInt("Alpha bits",&settings.glAlphaSize)) { + if (settings.glAlphaSize<0) settings.glAlphaSize=0; + if (settings.glAlphaSize>32) settings.glAlphaSize=32; + settingsChanged=true; + } + if (ImGui::InputInt("Color depth",&settings.glDepthSize)) { + if (settings.glDepthSize<0) settings.glDepthSize=0; + if (settings.glDepthSize>128) settings.glDepthSize=128; + settingsChanged=true; + } + bool glDoubleBufferB=settings.glDoubleBuffer; + if (ImGui::Checkbox("Double buffer",&glDoubleBufferB)) { + settings.glDoubleBuffer=glDoubleBufferB; + settingsChanged=true; + } + + ImGui::TextWrapped("the following values are common (in red, green, blue, alpha order):\n- 24 bits: 8, 8, 8, 0\n- 16 bits: 5, 6, 5, 0\n- 32 bits (with alpha): 8, 8, 8, 8\n- 30 bits (deep): 10, 10, 10, 0"); + } } @@ -4123,6 +4161,13 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { settings.renderBackend=conf.getString("renderBackend",GUI_BACKEND_DEFAULT_NAME); settings.renderClearPos=conf.getInt("renderClearPos",0); + settings.glRedSize=conf.getInt("glRedSize",8); + settings.glGreenSize=conf.getInt("glGreenSize",8); + settings.glBlueSize=conf.getInt("glBlueSize",8); + settings.glAlphaSize=conf.getInt("glAlphaSize",0); + settings.glDepthSize=conf.getInt("glDepthSize",24); + settings.glDoubleBuffer=conf.getInt("glDoubleBuffer",1); + settings.vsync=conf.getInt("vsync",1); settings.frameRateLimit=conf.getInt("frameRateLimit",100); settings.displayRenderTime=conf.getInt("displayRenderTime",0); @@ -4657,6 +4702,12 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { clampSetting(settings.vibrationStrength,0.0f,1.0f); clampSetting(settings.vibrationLength,10,500); clampSetting(settings.inputRepeat,0,1); + clampSetting(settings.glRedSize,0,32); + clampSetting(settings.glGreenSize,0,32); + clampSetting(settings.glBlueSize,0,32); + clampSetting(settings.glAlphaSize,0,32); + clampSetting(settings.glDepthSize,0,128); + clampSetting(settings.glDoubleBuffer,0,1); if (settings.exportLoops<0.0) settings.exportLoops=0.0; if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0; @@ -4680,6 +4731,13 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { conf.set("renderBackend",settings.renderBackend); conf.set("renderClearPos",settings.renderClearPos); + conf.set("glRedSize",settings.glRedSize); + conf.set("glGreenSize",settings.glGreenSize); + conf.set("glBlueSize",settings.glBlueSize); + conf.set("glAlphaSize",settings.glAlphaSize); + conf.set("glDepthSize",settings.glDepthSize); + conf.set("glDoubleBuffer",settings.glDoubleBuffer); + conf.set("vsync",settings.vsync); conf.set("frameRateLimit",settings.frameRateLimit); conf.set("displayRenderTime",settings.displayRenderTime);