diff options
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/DlgVideoSettings.cpp | 174 | ||||
-rw-r--r-- | src/libui_sdl/PlatformConfig.cpp | 6 | ||||
-rw-r--r-- | src/libui_sdl/PlatformConfig.h | 3 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 303 |
4 files changed, 295 insertions, 191 deletions
diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp index aee6d51..3102873 100644 --- a/src/libui_sdl/DlgVideoSettings.cpp +++ b/src/libui_sdl/DlgVideoSettings.cpp @@ -37,7 +37,38 @@ namespace DlgVideoSettings bool opened; uiWindow* win; -// +uiRadioButtons* rbRenderer; +uiCheckbox* cbGLDisplay; +uiCheckbox* cbThreaded3D; +uiCombobox* cbResolution; +uiCheckbox* cbAntialias; + +int old_renderer; +int old_gldisplay; +int old_threaded3D; +int old_resolution; +int old_antialias; + + +void UpdateControls() +{ + int renderer = uiRadioButtonsSelected(rbRenderer); + + if (renderer == 0) + { + uiControlEnable(uiControl(cbGLDisplay)); + uiControlEnable(uiControl(cbThreaded3D)); + uiControlDisable(uiControl(cbResolution)); + uiControlDisable(uiControl(cbAntialias)); + } + else + { + uiControlDisable(uiControl(cbGLDisplay)); + uiControlDisable(uiControl(cbThreaded3D)); + uiControlEnable(uiControl(cbResolution)); + uiControlEnable(uiControl(cbAntialias)); + } +} int OnCloseWindow(uiWindow* window, void* blarg) @@ -46,17 +77,68 @@ int OnCloseWindow(uiWindow* window, void* blarg) return 1; } -void OnResolutionChanged(uiRadioButtons* rb, void* blarg) +void OnRendererChanged(uiRadioButtons* rb, void* blarg) { int id = uiRadioButtonsSelected(rb); +printf("RENDERER CHANGE: %d\n", id); + Config::_3DRenderer = id; + UpdateControls(); + ApplyNewSettings(2); +} - Config::ScreenScale = id; +void OnGLDisplayChanged(uiCheckbox* cb, void* blarg) +{ + Config::ScreenUseGL = uiCheckboxChecked(cb); ApplyNewSettings(2); } +void OnThreaded3DChanged(uiCheckbox* cb, void* blarg) +{ + Config::Threaded3D = uiCheckboxChecked(cb); + ApplyNewSettings(0); +} + +void OnResolutionChanged(uiCombobox* cb, void* blarg) +{ + int id = uiComboboxSelected(cb); + + Config::GL_ScaleFactor = id+1; + ApplyNewSettings(3); +} + +void OnAntialiasChanged(uiCheckbox* cb, void* blarg) +{ + Config::GL_Antialias = uiCheckboxChecked(cb); + ApplyNewSettings(3); +} + void OnCancel(uiButton* btn, void* blarg) { - // restore old settings here + if (old_renderer != Config::_3DRenderer) + { + Config::_3DRenderer = old_renderer; + ApplyNewSettings(2); + } + + if (old_gldisplay != Config::ScreenUseGL) + { + Config::ScreenUseGL = old_gldisplay; + ApplyNewSettings(2); + } + + if (old_threaded3D != Config::Threaded3D) + { + Config::Threaded3D = old_threaded3D; + ApplyNewSettings(0); + } + + if (old_resolution != Config::GL_ScaleFactor || + old_antialias != Config::GL_Antialias) + { + Config::GL_ScaleFactor = old_resolution; + Config::GL_Antialias = old_antialias; + ApplyNewSettings(3); + } uiControlDestroy(uiControl(win)); opened = false; @@ -64,8 +146,6 @@ void OnCancel(uiButton* btn, void* blarg) void OnOk(uiButton* btn, void* blarg) { - // set config entries here - Config::Save(); uiControlDestroy(uiControl(win)); @@ -101,76 +181,70 @@ void Open() uiBoxSetPadded(right, 1); { - uiGroup* grp = uiNewGroup("3D renderer"); + uiGroup* grp = uiNewGroup("Display settings"); uiBoxAppend(left, uiControl(grp), 0); uiGroupSetMargined(grp, 1); uiBox* in_ctrl = uiNewVerticalBox(); uiGroupSetChild(grp, uiControl(in_ctrl)); - uiRadioButtons* rbRenderer = uiNewRadioButtons(); + uiLabel* lbl = uiNewLabel("3D renderer:"); + uiBoxAppend(in_ctrl, uiControl(lbl), 0); + + rbRenderer = uiNewRadioButtons(); uiRadioButtonsAppend(rbRenderer, "Software"); uiRadioButtonsAppend(rbRenderer, "OpenGL"); + uiRadioButtonsOnSelected(rbRenderer, OnRendererChanged, NULL); uiBoxAppend(in_ctrl, uiControl(rbRenderer), 0); + + lbl = uiNewLabel(""); + uiBoxAppend(in_ctrl, uiControl(lbl), 0); + + cbGLDisplay = uiNewCheckbox("OpenGL display"); + uiCheckboxOnToggled(cbGLDisplay, OnGLDisplayChanged, NULL); + uiBoxAppend(in_ctrl, uiControl(cbGLDisplay), 0); } { uiGroup* grp = uiNewGroup("Software renderer"); - uiBoxAppend(left, uiControl(grp), 0); + uiBoxAppend(right, uiControl(grp), 0); uiGroupSetMargined(grp, 1); uiBox* in_ctrl = uiNewVerticalBox(); uiGroupSetChild(grp, uiControl(in_ctrl)); - uiCheckbox* cbThreaded3D = uiNewCheckbox("Threaded"); + cbThreaded3D = uiNewCheckbox("Threaded"); + uiCheckboxOnToggled(cbThreaded3D, OnThreaded3DChanged, NULL); uiBoxAppend(in_ctrl, uiControl(cbThreaded3D), 0); } { uiGroup* grp = uiNewGroup("OpenGL renderer"); - uiBoxAppend(left, uiControl(grp), 0); - uiGroupSetMargined(grp, 1); - - uiBox* in_ctrl = uiNewVerticalBox(); - uiGroupSetChild(grp, uiControl(in_ctrl)); - - uiCheckbox* cbAntialias = uiNewCheckbox("Antialiasing"); - uiBoxAppend(in_ctrl, uiControl(cbAntialias), 0); - } - - { - uiGroup* grp = uiNewGroup("Display settings"); uiBoxAppend(right, uiControl(grp), 0); uiGroupSetMargined(grp, 1); uiBox* in_ctrl = uiNewVerticalBox(); uiGroupSetChild(grp, uiControl(in_ctrl)); - uiLabel* lbl = uiNewLabel("Resolution:"); + uiLabel* lbl = uiNewLabel("Internal resolution:"); uiBoxAppend(in_ctrl, uiControl(lbl), 0); - uiRadioButtons* rbResolution = uiNewRadioButtons(); - uiRadioButtonsOnSelected(rbResolution, OnResolutionChanged, NULL); - uiRadioButtonsAppend(rbResolution, "1x"); - uiRadioButtonsAppend(rbResolution, "2x"); - uiRadioButtonsAppend(rbResolution, "4x"); - uiBoxAppend(in_ctrl, uiControl(rbResolution), 0); - - uiCheckbox* cbWidescreen = uiNewCheckbox("Stretch to 16:9"); - uiBoxAppend(in_ctrl, uiControl(cbWidescreen), 0); + cbResolution = uiNewCombobox(); + uiComboboxOnSelected(cbResolution, OnResolutionChanged, NULL); + for (int i = 1; i <= 8; i++) + { + char txt[64]; + sprintf(txt, "%dx native (%dx%d)", i, 256*i, 192*i); + uiComboboxAppend(cbResolution, txt); + } + uiBoxAppend(in_ctrl, uiControl(cbResolution), 0); lbl = uiNewLabel(""); uiBoxAppend(in_ctrl, uiControl(lbl), 0); - lbl = uiNewLabel("Apply upscaling to:"); - uiBoxAppend(in_ctrl, uiControl(lbl), 0); - - uiRadioButtons* rbApplyScalingTo = uiNewRadioButtons(); - uiRadioButtonsAppend(rbApplyScalingTo, "Both screens"); - uiRadioButtonsAppend(rbApplyScalingTo, "Emphasized screen (see 'Screen sizing')"); - //uiRadioButtonsAppend(rbApplyScalingTo, "Top screen"); - //uiRadioButtonsAppend(rbApplyScalingTo, "Bottom screen"); - uiBoxAppend(in_ctrl, uiControl(rbApplyScalingTo), 0); + cbAntialias = uiNewCheckbox("Antialiasing"); + uiCheckboxOnToggled(cbAntialias, OnAntialiasChanged, NULL); + uiBoxAppend(in_ctrl, uiControl(cbAntialias), 0); } { @@ -190,7 +264,23 @@ void Open() uiBoxAppend(in_ctrl, uiControl(btnok), 0); } - // + Config::_3DRenderer = Config::_3DRenderer ? 1 : 0; + + if (Config::GL_ScaleFactor < 1) Config::GL_ScaleFactor = 1; + else if (Config::GL_ScaleFactor > 8) Config::GL_ScaleFactor = 8; + + old_renderer = Config::_3DRenderer; + old_gldisplay = Config::ScreenUseGL; + old_threaded3D = Config::Threaded3D; + old_resolution = Config::GL_ScaleFactor; + old_antialias = Config::GL_Antialias; + + uiCheckboxSetChecked(cbGLDisplay, Config::ScreenUseGL); + uiCheckboxSetChecked(cbThreaded3D, Config::Threaded3D); + uiComboboxSetSelected(cbResolution, Config::GL_ScaleFactor-1); + uiCheckboxSetChecked(cbAntialias, Config::GL_Antialias); + uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer); + UpdateControls(); uiControlShow(uiControl(win)); } diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp index 065d9c2..f700ecb 100644 --- a/src/libui_sdl/PlatformConfig.cpp +++ b/src/libui_sdl/PlatformConfig.cpp @@ -40,9 +40,8 @@ int ScreenLayout; int ScreenSizing; int ScreenFilter; -int ScreenScale; +int ScreenUseGL; int ScreenRatio; -int ScreenScaleMode; int LimitFPS; @@ -105,9 +104,8 @@ ConfigEntry PlatformConfigFile[] = {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, - {"ScreenScale", 0, &ScreenScale, 0, NULL, 0}, + {"ScreenUseGL", 0, &ScreenUseGL, 1, NULL, 0}, {"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0}, - {"ScreenScaleMode", 0, &ScreenScaleMode, 0, NULL, 0}, {"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h index 0cff1d2..013a0a7 100644 --- a/src/libui_sdl/PlatformConfig.h +++ b/src/libui_sdl/PlatformConfig.h @@ -48,9 +48,8 @@ extern int ScreenLayout; extern int ScreenSizing; extern int ScreenFilter; -extern int ScreenScale; +extern int ScreenUseGL; extern int ScreenRatio; -extern int ScreenScaleMode; extern int LimitFPS; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index b499da7..f0d7b74 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -100,6 +100,9 @@ char PrevSRAMPath[1024]; // for savestate 'undo load' bool SavestateLoaded; +bool Screen_UseGL; +int _3DRenderer; + bool ScreenDrawInited = false; uiDrawBitmap* ScreenBitmap[2] = {NULL,NULL}; @@ -117,8 +120,7 @@ float GL_ScreenVertices[2 * 3*2 * 4]; // position/texcoord GLuint GL_ScreenTexture; bool GL_ScreenSizeDirty; -int ScreenScale[3]; -int ScreenScaleMode; +int GL_3DScale; int ScreenGap = 0; int ScreenLayout = 0; @@ -161,14 +163,14 @@ void GetSavestateName(int slot, char* filename, int len); -bool GLDrawing_Init() +bool GLScreen_Init() { if (!OpenGL_Init()) return false; if (!OpenGL_BuildShaderProgram(kScreenVS, kScreenFS, GL_ScreenShader, "ScreenShader")) return false; -printf("GL init looking good\n"); + GLuint uni_id; memset(&GL_ShaderConfig, 0, sizeof(GL_ShaderConfig)); @@ -211,11 +213,11 @@ printf("GL init looking good\n"); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, 1024, 1536, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, NULL); GL_ScreenSizeDirty = true; -printf("finished w/ err: %04X\n", glGetError()); + return true; } -void GLDrawing_DeInit() +void GLScreen_DeInit() { glDeleteTextures(1, &GL_ScreenTexture); @@ -225,7 +227,7 @@ void GLDrawing_DeInit() OpenGL_DeleteShaderProgram(GL_ScreenShader); } -void GLDrawing_DrawScreen() +void GLScreen_DrawScreen() { if (GL_ScreenSizeDirty) { @@ -233,8 +235,8 @@ void GLDrawing_DrawScreen() GL_ShaderConfig.uScreenSize[0] = WindowWidth; GL_ShaderConfig.uScreenSize[1] = WindowHeight; - GL_ShaderConfig.u3DScale = 1 << GPU3D::GetScale(); - + GL_ShaderConfig.u3DScale = GL_3DScale; +printf("updating GL scale: %d\n", GL_3DScale); glBindBuffer(GL_UNIFORM_BUFFER, GL_ShaderConfigUBO); void* unibuf = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY); if (unibuf) memcpy(unibuf, &GL_ShaderConfig, sizeof(GL_ShaderConfig)); @@ -257,8 +259,8 @@ void GLDrawing_DrawScreen() x1 = TopScreenRect.X + TopScreenRect.Width; y1 = TopScreenRect.Y + TopScreenRect.Height; - scwidth = 256;// << ScreenScale[0]; - scheight = 192;// << ScreenScale[0]; + scwidth = 256; + scheight = 192; switch (ScreenRotation) { @@ -303,8 +305,8 @@ void GLDrawing_DrawScreen() x1 = BottomScreenRect.X + BottomScreenRect.Width; y1 = BottomScreenRect.Y + BottomScreenRect.Height; - scwidth = 256;// << ScreenScale[1]; - scheight = 192;// << ScreenScale[1]; + scwidth = 256; + scheight = 192; switch (ScreenRotation) { @@ -376,7 +378,8 @@ void GLDrawing_DrawScreen() GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]); glActiveTexture(GL_TEXTURE1); - GPU3D::SetupAccelFrame(); + if (_3DRenderer != 0) + GPU3D::GLRenderer::SetupAccelFrame(); glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID); glBindVertexArray(GL_ScreenVertexArrayID); @@ -384,7 +387,89 @@ void GLDrawing_DrawScreen() glFlush(); uiGLSwapBuffers(GLContext); - uiAreaQueueRedrawAll(MainDrawArea); +} + +void ScreenCreateArea(bool opengl) +{ + bool opengl_good = opengl; + if (opengl_good) + { + MainDrawArea = uiNewGLArea(&MainDrawAreaHandler, kGLVersions); + uiWindowSetChild(MainWindow, uiControl(MainDrawArea)); + uiControlSetMinSize(uiControl(MainDrawArea), 256, 384); + uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); + GLContext = uiAreaGetGLContext(MainDrawArea); + if (!GLContext) opengl_good = false; + } + + if (opengl_good) + { + uiGLMakeContextCurrent(GLContext); + if (!GLScreen_Init()) opengl_good = false; + } + + if (opengl_good) + { + //if (_3DRenderer != 0) + { + _3DRenderer = GPU3D::SetRenderer(_3DRenderer); + if (_3DRenderer != 0) + GPU3D::GLRenderer::SetDisplaySettings(Config::GL_ScaleFactor, Config::GL_Antialias); + else if (RunningSomething) + GPU3D::SoftRenderer::SetupRenderThread(); + } + uiGLMakeContextCurrent(NULL); + } + else + { + if (opengl) + { + uiWindowSetChild(MainWindow, NULL); + uiControlDestroy(uiControl(MainDrawArea)); + } + + Screen_UseGL = false; + + MainDrawArea = uiNewArea(&MainDrawAreaHandler); + uiWindowSetChild(MainWindow, uiControl(MainDrawArea)); + uiControlSetMinSize(uiControl(MainDrawArea), 256, 384); + uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); + ScreenDrawInited = false; + } + + uiControlShow(uiControl(MainWindow)); + uiControlSetFocus(uiControl(MainDrawArea)); +} + +void ScreenSetMethod(bool opengl) +{ + int oldstatus = EmuRunning; + EmuRunning = 3; + while (EmuStatus != 3); + + if (Screen_UseGL) + { + uiGLMakeContextCurrent(GLContext); + if (_3DRenderer != 0) GPU3D::GLRenderer::DeInit(); + else GPU3D::SoftRenderer::DeInit(); + GLScreen_DeInit(); + uiGLMakeContextCurrent(NULL); + } + else + { + if (ScreenBitmap[0]) uiDrawFreeBitmap(ScreenBitmap[0]); + if (ScreenBitmap[1]) uiDrawFreeBitmap(ScreenBitmap[1]); + } + + uiWindowSetChild(MainWindow, NULL); + uiControlDestroy(uiControl(MainDrawArea)); + + Screen_UseGL = Config::ScreenUseGL; + _3DRenderer = Config::_3DRenderer; + + ScreenCreateArea(opengl); + + EmuRunning = oldstatus; } void MicLoadWav(char* name) @@ -642,8 +727,11 @@ void FeedMicInput() int EmuThreadFunc(void* burp) { - uiGLMakeContextCurrent(GLContext); - GLDrawing_Init(); + if (Screen_UseGL) + { + uiGLMakeContextCurrent(GLContext); + GLScreen_Init(); + } NDS::Init(); @@ -652,13 +740,8 @@ int EmuThreadFunc(void* burp) MainScreenPos[2] = 0; AutoScreenSizing = 0; - // FIXME - ScreenScale[2] = Config::ScreenScale; - ScreenScale[0] = ScreenScale[2]; - ScreenScale[1] = ScreenScale[2]; - - int lastscale[2] = {ScreenScale[0], ScreenScale[1]}; - GPU::SetDisplaySettings(ScreenScale[0], ScreenScale[1], false); + GPU::SetDisplaySettings(_3DRenderer != 0); + if (Screen_UseGL) uiGLMakeContextCurrent(NULL); Touching = false; KeyInputMask = 0xFFF; @@ -773,7 +856,7 @@ int EmuThreadFunc(void* burp) // microphone input FeedMicInput(); - uiGLMakeContextCurrent(GLContext); + if (Screen_UseGL) uiGLMakeContextCurrent(GLContext); // auto screen layout { @@ -804,22 +887,16 @@ int EmuThreadFunc(void* burp) } } - if (ScreenScale[0] != lastscale[0] || - ScreenScale[1] != lastscale[1]) - { - GPU::SetDisplaySettings(ScreenScale[0], ScreenScale[1], false); - ScreenDrawInited = false; - } - // emulate u32 nlines = NDS::RunFrame(); if (EmuRunning == 0) break; - GLDrawing_DrawScreen(); - - //uiAreaQueueRedrawAll(MainDrawArea); - //uiGLSwapBuffers(GLContext); + if (Screen_UseGL) + { + GLScreen_DrawScreen(); + } + uiAreaQueueRedrawAll(MainDrawArea); // framerate limiter based off SDL2_gfx float framerate = (1000.0f * nlines) / (60.0f * 263.0f); @@ -869,13 +946,16 @@ int EmuThreadFunc(void* burp) if (EmuRunning == 2) { - uiGLMakeContextCurrent(GLContext); - - //uiAreaQueueRedrawAll(MainDrawArea); - //uiGLSwapBuffers(GLContext); - GLDrawing_DrawScreen(); + if (Screen_UseGL) + { + uiGLMakeContextCurrent(GLContext); + GLScreen_DrawScreen(); + } + uiAreaQueueRedrawAll(MainDrawArea); } + if (Screen_UseGL) uiGLMakeContextCurrent(NULL); + EmuStatus = EmuRunning; SDL_Delay(100); @@ -889,7 +969,7 @@ int EmuThreadFunc(void* burp) NDS::DeInit(); Platform::LAN_DeInit(); - GLDrawing_DeInit(); + if (Screen_UseGL) GLScreen_DeInit(); return 44203; } @@ -897,22 +977,21 @@ int EmuThreadFunc(void* burp) void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params) { - // TODO: recreate bitmap if screen scale changed if (!ScreenDrawInited) { if (ScreenBitmap[0]) uiDrawFreeBitmap(ScreenBitmap[0]); if (ScreenBitmap[1]) uiDrawFreeBitmap(ScreenBitmap[1]); ScreenDrawInited = true; - ScreenBitmap[0] = uiDrawNewBitmap(params->Context, 256<<ScreenScale[0], 192<<ScreenScale[0]); - ScreenBitmap[1] = uiDrawNewBitmap(params->Context, 256<<ScreenScale[1], 192<<ScreenScale[1]); + ScreenBitmap[0] = uiDrawNewBitmap(params->Context, 256, 192); + ScreenBitmap[1] = uiDrawNewBitmap(params->Context, 256, 192); } if (!ScreenBitmap[0] || !ScreenBitmap[1]) return; if (!GPU::Framebuffer[0][0]) return; - uiRect top = {0, 0, 256<<ScreenScale[0], 192<<ScreenScale[0]}; - uiRect bot = {0, 0, 256<<ScreenScale[1], 192<<ScreenScale[1]}; + uiRect top = {0, 0, 256, 192}; + uiRect bot = {0, 0, 256, 192}; int frontbuf = GPU::FrontBuffer; uiDrawBitmapUpdate(ScreenBitmap[0], GPU::Framebuffer[frontbuf][0]); @@ -1097,33 +1176,6 @@ void SetupScreenRects(int width, int height) screenH = 192; } - if (ScreenScaleMode == 0 || sizemode == 0) - { - // scale both screens - screenW <<= ScreenScale[2]; - screenH <<= ScreenScale[2]; - - ScreenScale[0] = ScreenScale[2]; - ScreenScale[1] = ScreenScale[2]; - } - else - { - // scale emphasized screen - // screenW/screenH will apply to the non-emphasized screen - // the emphasized screen basically taking up all the remaining space - - if (sizemode == 1) - { - ScreenScale[0] = ScreenScale[2]; - ScreenScale[1] = 0; - } - else if (sizemode == 2) - { - ScreenScale[0] = 0; - ScreenScale[1] = ScreenScale[2]; - } - } - gap = ScreenGap; uiRect *topscreen, *bottomscreen; @@ -1798,35 +1850,7 @@ void OnOpenHotkeyConfig(uiMenuItem* item, uiWindow* window, void* blarg) void OnOpenVideoSettings(uiMenuItem* item, uiWindow* window, void* blarg) { - //DlgVideoSettings::Open(); - - int oldstatus = EmuRunning; - EmuRunning = 3; - while (EmuStatus != 3); - - uiGLMakeContextCurrent(GLContext); - GPU3D::GLRenderer::DeInit(); - GLDrawing_DeInit(); - uiGLMakeContextCurrent(NULL); - - uiWindowSetChild(MainWindow, NULL); - uiControlDestroy(uiControl(MainDrawArea)); - - - MainDrawArea = uiNewGLArea(&MainDrawAreaHandler, kGLVersions); - uiWindowSetChild(MainWindow, uiControl(MainDrawArea)); - uiControlSetMinSize(uiControl(MainDrawArea), 256, 384); - uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); - //uiControlShow(uiControl(MainDrawArea)); - GLContext = uiAreaGetGLContext(MainDrawArea); - - uiGLMakeContextCurrent(GLContext); - GLDrawing_Init(); - GPU3D::GLRenderer::Init(); - GPU3D::GLRenderer::SetDisplaySettings(1, true); - uiGLMakeContextCurrent(NULL); - - EmuRunning = oldstatus; + DlgVideoSettings::Open(); } void OnOpenAudioSettings(uiMenuItem* item, uiWindow* window, void* blarg) @@ -1850,17 +1874,11 @@ void EnsureProperMinSize() { bool isHori = (ScreenRotation == 1 || ScreenRotation == 3); - int w0 = 256 << ScreenScale[2]; - int h0 = 192 << ScreenScale[2]; + int w0 = 256; + int h0 = 192; int w1 = 256; int h1 = 192; - if (ScreenScale[2] != 0 && (ScreenScaleMode != 1 || ScreenSizing == 0 || ScreenSizing == 3)) - { - w1 <<= ScreenScale[2]; - h1 <<= ScreenScale[2]; - } - if (ScreenLayout == 0) // natural { if (isHori) @@ -1889,8 +1907,8 @@ void OnSetScreenSize(uiMenuItem* item, uiWindow* window, void* param) int factor = *(int*)param; bool isHori = (ScreenRotation == 1 || ScreenRotation == 3); - int w = 256*factor;// * ScreenScale; - int h = 192*factor;// * ScreenScale; + int w = 256*factor; + int h = 192*factor; // FIXME @@ -2003,16 +2021,23 @@ void OnSetLimitFPS(uiMenuItem* item, uiWindow* window, void* blarg) void ApplyNewSettings(int type) { + if (type == 2) + { + bool usegl = Config::ScreenUseGL || (Config::_3DRenderer != 0); + ScreenSetMethod(usegl); + return; + } + if (!RunningSomething) return; int prevstatus = EmuRunning; - EmuRunning = 2; - while (EmuStatus != 2); + EmuRunning = 3; + while (EmuStatus != 3); - if (type == 0) // general emu settings + if (type == 0) // software renderer thread { - // TODO!! REMOVE ME - GPU3D::SoftRenderer::SetupRenderThread(); + if (_3DRenderer == 0) + GPU3D::SoftRenderer::SetupRenderThread(); } else if (type == 1) // wifi settings { @@ -2025,15 +2050,18 @@ void ApplyNewSettings(int type) Platform::LAN_DeInit(); Platform::LAN_Init(); } - else if (type == 2) // upscaling/video settings + else if (type == 3) // GL renderer settings { - int scale = Config::ScreenScale; - if (scale != ScreenScale[2]) - { - ScreenScale[2] = scale; + GL_3DScale = Config::GL_ScaleFactor; - EnsureProperMinSize(); - SetupScreenRects(WindowWidth, WindowHeight); + if (_3DRenderer != 0) + { + uiGLMakeContextCurrent(GLContext); + printf("%04X\n", glGetError()); + printf("%04X\n", glGetError()); + GPU3D::GLRenderer::SetDisplaySettings(Config::GL_ScaleFactor, Config::GL_Antialias); + uiGLMakeContextCurrent(NULL); + GL_ScreenSizeDirty = true; } } @@ -2316,8 +2344,12 @@ int main(int argc, char** argv) WindowWidth = w; WindowHeight = h; - //ScreenScale = 1; - ScreenScale[2] = 0; // FIXME + Screen_UseGL = Config::ScreenUseGL || (Config::_3DRenderer != 0); + _3DRenderer = Config::_3DRenderer; + + GL_3DScale = Config::GL_ScaleFactor; + if (GL_3DScale < 1) GL_3DScale = 1; + else if (GL_3DScale > 8) GL_3DScale = 8; MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, w, h, Config::WindowMaximized, 1, 1); uiWindowOnClosing(MainWindow, OnCloseWindow, NULL); @@ -2346,11 +2378,7 @@ int main(int argc, char** argv) MainDrawAreaHandler.Resize = OnAreaResize; ScreenDrawInited = false; - //MainDrawArea = uiNewArea(&MainDrawAreaHandler); - MainDrawArea = uiNewGLArea(&MainDrawAreaHandler, kGLVersions); - uiWindowSetChild(MainWindow, uiControl(MainDrawArea)); - uiControlSetMinSize(uiControl(MainDrawArea), 256, 384); - uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); // TODO: make configurable? + ScreenCreateArea(Screen_UseGL); ScreenRotation = Config::ScreenRotation; ScreenGap = Config::ScreenGap; @@ -2377,15 +2405,6 @@ int main(int argc, char** argv) OnSetScreenRotation(MenuItem_ScreenRot[ScreenRotation], MainWindow, (void*)&kScreenRot[ScreenRotation]); - // TODO: fail gracefully, support older OpenGL, etc - GLContext = uiAreaGetGLContext(MainDrawArea); - uiGLMakeContextCurrent(GLContext); - - void* testor = uiGLGetProcAddress("glUseProgram"); - void* testor2 = uiGLGetProcAddress("glBindFramebuffer"); - printf("OPENGL: %p %p\n", testor, testor2); - uiGLMakeContextCurrent(NULL); - SDL_AudioSpec whatIwant, whatIget; memset(&whatIwant, 0, sizeof(SDL_AudioSpec)); whatIwant.freq = 47340; @@ -2454,8 +2473,6 @@ int main(int argc, char** argv) } } - uiControlShow(uiControl(MainWindow)); - uiControlSetFocus(uiControl(MainDrawArea)); uiMain(); EmuRunning = 0; |