GUI: add render preInit settings

This commit is contained in:
tildearrow 2024-05-07 13:44:16 -05:00
parent 5f89cb1dea
commit ae386f6269
16 changed files with 111 additions and 41 deletions

View file

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

View file

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

View file

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

View file

@ -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]={

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -449,6 +449,8 @@ void FurnaceGUI::drawSettings() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("you may need to restart Furnace for this setting to take effect.");
}
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())) {
@ -466,6 +468,42 @@ void FurnaceGUI::drawSettings() {
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");
}
}
ImGui::TextWrapped("current backend: %s\n%s\n%s\n%s",rend->getBackendName(),rend->getVendorName(),rend->getDeviceName(),rend->getAPIVersion());
@ -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);