aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Config.cpp2
-rw-r--r--src/Config.h1
-rw-r--r--src/GPU.cpp42
-rw-r--r--src/GPU.h2
-rw-r--r--src/GPU2D.cpp2
-rw-r--r--src/GPU2D.h2
-rw-r--r--src/GPU3D.cpp51
-rw-r--r--src/GPU3D.h11
-rw-r--r--src/GPU3D_OpenGL.cpp144
-rw-r--r--src/GPU3D_Soft.cpp15
-rw-r--r--src/libui_sdl/DlgVideoSettings.cpp174
-rw-r--r--src/libui_sdl/PlatformConfig.cpp6
-rw-r--r--src/libui_sdl/PlatformConfig.h3
-rw-r--r--src/libui_sdl/main.cpp303
14 files changed, 403 insertions, 355 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index aca3d4f..42f18c7 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -31,6 +31,7 @@ const char* kConfigFile = "melonDS.ini";
int _3DRenderer;
int Threaded3D;
+int GL_ScaleFactor;
int GL_Antialias;
ConfigEntry ConfigFile[] =
@@ -38,6 +39,7 @@ ConfigEntry ConfigFile[] =
{"3DRenderer", 0, &_3DRenderer, 1, NULL, 0},
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
+ {"GL_ScaleFactor", 0, &GL_ScaleFactor, 1, NULL, 0},
{"GL_Antialias", 0, &GL_Antialias, 0, NULL, 0},
{"", -1, NULL, 0, NULL, 0}
diff --git a/src/Config.h b/src/Config.h
index 8dc97d5..6ffc495 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -43,6 +43,7 @@ void Save();
extern int _3DRenderer;
extern int Threaded3D;
+extern int GL_ScaleFactor;
extern int GL_Antialias;
}
diff --git a/src/GPU.cpp b/src/GPU.cpp
index 8b94c94..959129e 100644
--- a/src/GPU.cpp
+++ b/src/GPU.cpp
@@ -73,7 +73,6 @@ u32 VRAMMap_ARM7[2];
int FrontBuffer;
u32* Framebuffer[2][2];
-int ScreenScale[2];
bool Accelerated;
GPU2D* GPU2D_A;
@@ -89,8 +88,8 @@ bool Init()
FrontBuffer = 0;
Framebuffer[0][0] = NULL; Framebuffer[0][1] = NULL;
Framebuffer[1][0] = NULL; Framebuffer[1][1] = NULL;
- ScreenScale[0] = -1; ScreenScale[1] = -1; Accelerated = false;
- SetDisplaySettings(0, 0, false);
+ Accelerated = false;
+ SetDisplaySettings(false);
return true;
}
@@ -247,12 +246,10 @@ void AssignFramebuffers()
}
}
-void SetDisplaySettings(int topscale, int bottomscale, bool accel)
-{accel=true;
+void SetDisplaySettings(bool accel)
+{
if (accel != Accelerated)
{
- ScreenScale[0] = accel ? 0 : topscale;
-
int fbsize;
if (accel) fbsize = (256*3 + 2) * 192;
else fbsize = 256 * 192;
@@ -273,35 +270,8 @@ void SetDisplaySettings(int topscale, int bottomscale, bool accel)
AssignFramebuffers();
}
- if (topscale != ScreenScale[0])
- {
- ScreenScale[0] = topscale;
-
- if (NDS::PowerControl9 & (1<<15))
- {
- GPU2D_A->SetDisplaySettings(ScreenScale[0], accel);
- GPU3D::SetDisplaySettings(ScreenScale[0], accel);
- }
- else
- {
- GPU2D_B->SetDisplaySettings(ScreenScale[0], accel);
- }
- }
-
- if (bottomscale != ScreenScale[1] || accel != Accelerated)
- {
- ScreenScale[1] = bottomscale;
-
- if (NDS::PowerControl9 & (1<<15))
- {
- GPU2D_B->SetDisplaySettings(ScreenScale[1], accel);
- }
- else
- {
- GPU2D_A->SetDisplaySettings(ScreenScale[1], accel);
- GPU3D::SetDisplaySettings(ScreenScale[1], accel);
- }
- }
+ GPU2D_A->SetDisplaySettings(accel);
+ GPU2D_B->SetDisplaySettings(accel);
Accelerated = accel;
}
diff --git a/src/GPU.h b/src/GPU.h
index cfa8d7d..b6f6473 100644
--- a/src/GPU.h
+++ b/src/GPU.h
@@ -75,7 +75,7 @@ void Stop();
void DoSavestate(Savestate* file);
-void SetDisplaySettings(int topscale, int bottomscale, bool accel);
+void SetDisplaySettings(bool accel);
void MapVRAM_AB(u32 bank, u8 cnt);
diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp
index fe1645e..88249ba 100644
--- a/src/GPU2D.cpp
+++ b/src/GPU2D.cpp
@@ -215,7 +215,7 @@ void GPU2D::SetFramebuffer(u32* buf)
Framebuffer = buf;
}
-void GPU2D::SetDisplaySettings(int scale, bool accel)
+void GPU2D::SetDisplaySettings(bool accel)
{
Accelerated = accel;
diff --git a/src/GPU2D.h b/src/GPU2D.h
index eb159f7..78e62f5 100644
--- a/src/GPU2D.h
+++ b/src/GPU2D.h
@@ -31,7 +31,7 @@ public:
void SetEnabled(bool enable) { Enabled = enable; }
void SetFramebuffer(u32* buf);
- void SetDisplaySettings(int scale, bool accel);
+ void SetDisplaySettings(bool accel);
u8 Read8(u32 addr);
u16 Read16(u32 addr);
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp
index 04ec55e..0ca3cd4 100644
--- a/src/GPU3D.cpp
+++ b/src/GPU3D.cpp
@@ -156,6 +156,8 @@ u32 NumCommands, CurCommand, ParamCount, TotalParams;
bool GeometryEnabled;
bool RenderingEnabled;
+int Renderer;
+
u32 DispCnt;
u8 AlphaRefVal, AlphaRef;
@@ -275,16 +277,16 @@ bool Init()
CmdStallQueue = new FIFO<CmdFIFOEntry>(64);
- //if (!SoftRenderer::Init()) return false;
- if (!GLRenderer::Init()) return false;
+ Renderer = -1;
+ // SetRenderer() will be called to set it up later
return true;
}
void DeInit()
{
- //SoftRenderer::DeInit();
- GLRenderer::DeInit();
+ if (Renderer == 0) SoftRenderer::DeInit();
+ else GLRenderer::DeInit();
delete CmdFIFO;
delete CmdPIPE;
@@ -384,8 +386,8 @@ void Reset()
FlushAttributes = 0;
ResetRenderingState();
- //SoftRenderer::Reset();
- GLRenderer::Reset();
+ if (Renderer == 0) SoftRenderer::Reset();
+ else GLRenderer::Reset();
}
void DoSavestate(Savestate* file)
@@ -607,14 +609,24 @@ void SetEnabled(bool geometry, bool rendering)
if (!rendering) ResetRenderingState();
}
-void SetDisplaySettings(int scale, bool accel)
-{
- GLRenderer::SetDisplaySettings(scale, accel);
-}
-int GetScale()
+int SetRenderer(int renderer)
{
- return GLRenderer::GetScale();
+ //if (renderer == Renderer) return renderer;
+
+ //if (Renderer == 0) SoftRenderer::DeInit();
+ //else GLRenderer::DeInit();
+
+ if (renderer == 1)
+ {
+ if (!GLRenderer::Init())
+ renderer = 0;
+ }
+
+ if (renderer == 0) SoftRenderer::Init();
+
+ Renderer = renderer;
+ return renderer;
}
@@ -2354,7 +2366,7 @@ void CheckFIFODMA()
void VCount144()
{
- //SoftRenderer::VCount144();
+ if (Renderer == 0) SoftRenderer::VCount144();
}
@@ -2436,19 +2448,14 @@ void VBlank()
void VCount215()
{
- //SoftRenderer::RenderFrame();
- GLRenderer::RenderFrame();
+ if (Renderer == 0) SoftRenderer::RenderFrame();
+ else GLRenderer::RenderFrame();
}
u32* GetLine(int line)
{
- //return SoftRenderer::GetLine(line);
- return GLRenderer::GetLine(line);
-}
-
-void SetupAccelFrame()
-{
- GLRenderer::SetupAccelFrame();
+ if (Renderer == 0) return SoftRenderer::GetLine(line);
+ else return GLRenderer::GetLine(line);
}
diff --git a/src/GPU3D.h b/src/GPU3D.h
index 280b99e..36c6c0f 100644
--- a/src/GPU3D.h
+++ b/src/GPU3D.h
@@ -97,8 +97,8 @@ void Reset();
void DoSavestate(Savestate* file);
void SetEnabled(bool geometry, bool rendering);
-void SetDisplaySettings(int scale, bool accel);
-int GetScale();
+
+int SetRenderer(int renderer);
void ExecuteCommand();
@@ -129,15 +129,11 @@ bool Init();
void DeInit();
void Reset();
-void SetDisplaySettings(int scale, bool accel);
-int GetScale();
-
void SetupRenderThread();
void VCount144();
void RenderFrame();
u32* GetLine(int line);
-void SetupAccelFrame();
}
@@ -148,8 +144,7 @@ bool Init();
void DeInit();
void Reset();
-void SetDisplaySettings(int scale, bool accel);
-int GetScale();
+void SetDisplaySettings(int scale, bool antialias);
void RenderFrame();
void PrepareCaptureFrame();
diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp
index 0bb7e42..30c77bf 100644
--- a/src/GPU3D_OpenGL.cpp
+++ b/src/GPU3D_OpenGL.cpp
@@ -95,13 +95,13 @@ GLuint TexMemID;
GLuint TexPalMemID;
int ScaleFactor;
-bool Accelerated;
+bool Antialias;
int ScreenW, ScreenH;
GLuint FramebufferTex[8];
int FrontBuffer;
GLuint FramebufferID[4], PixelbufferID;
-u32* Framebuffer = NULL;
+u32 Framebuffer[256*192];
@@ -176,26 +176,6 @@ bool Init()
printf("OpenGL: renderer: %s\n", renderer);
printf("OpenGL: version: %s\n", version);
- int barg1, barg2;
- glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &barg1);
- glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &barg2);
- printf("max texture: %d\n", barg1);
- printf("max comb. texture: %d\n", barg2);
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &barg1);
- printf("max tex size: %d\n", barg1);
-
- glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &barg1);
- printf("max arraytex levels: %d\n", barg1);
-
- /*glGetIntegerv(GL_NUM_EXTENSIONS, &barg1);
- printf("extensions: %d\n", barg1);
- for (int i = 0; i < barg1; i++)
- {
- const GLubyte* ext = glGetStringi(GL_EXTENSIONS, i);
- printf("- %s\n", ext);
- }*/
-
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
@@ -317,6 +297,12 @@ bool Init()
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[1]);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[1], 0);
+ glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0);
+ glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0);
+ glDrawBuffers(2, fbassign);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[2]);
+ glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[2], 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[6], 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[7], 0);
glDrawBuffers(2, fbassign);
@@ -324,8 +310,9 @@ bool Init()
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]);
glEnable(GL_BLEND);
+ // TODO: these are said to require GL 4.0; use the regular ones instead?
glBlendFuncSeparatei(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
- glBlendEquationSeparatei(0, GL_ADD, GL_MAX);
+ glBlendEquationSeparatei(0, GL_FUNC_ADD, GL_MAX);
glBlendFuncSeparatei(1, GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
glGenBuffers(1, &PixelbufferID);
@@ -347,7 +334,7 @@ bool Init()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1024, 48, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
-
+printf("init done. %04X\n", glGetError());
return true;
}
@@ -375,44 +362,55 @@ void DeInit()
void Reset()
{
- //
}
-void SetDisplaySettings(int scale, bool accel)
+void SetDisplaySettings(int scale, bool antialias)
{
+ if (antialias) scale *= 2;
+
ScaleFactor = scale;
- Accelerated = accel;
-
- // TODO: antialiasing setting
- ScreenW = 256 << scale;
- ScreenH = 192 << scale;
-
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[1]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW/2, ScreenH/2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[6]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
- glBindTexture(GL_TEXTURE_2D, FramebufferTex[7]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
+ Antialias = antialias;
- glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID);
- glBufferData(GL_PIXEL_PACK_BUFFER, 256*192*4, NULL, GL_DYNAMIC_READ);
+ ScreenW = 256 * scale;
+ ScreenH = 192 * scale;
- if (Framebuffer) delete[] Framebuffer;
- if (accel) Framebuffer = new u32[256*192];
- else Framebuffer = new u32[ScreenW*ScreenH];
-}
+ if (!antialias)
+ {
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[0]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[1]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[6]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[7]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[0]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW/2, ScreenH/2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[1]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW/2, ScreenH/2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW/2, ScreenH/2, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW/2, ScreenH/2, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[6]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
+ glBindTexture(GL_TEXTURE_2D, FramebufferTex[7]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
+ }
-int GetScale()
-{
- return ScaleFactor;
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID);
+ glBufferData(GL_PIXEL_PACK_BUFFER, 256*192*4, NULL, GL_DYNAMIC_READ);
}
@@ -496,10 +494,10 @@ void BuildPolygons(RendererPolygon* polygons, int npolys)
while (z > 0xFFFF) { z >>= 1; zshift++; }
u32 x, y;
- if (ScaleFactor > 0)
+ if (ScaleFactor > 1)
{
- x = vtx->HiresPosition[0] >> (4-ScaleFactor);
- y = vtx->HiresPosition[1] >> (4-ScaleFactor);
+ x = (vtx->HiresPosition[0] * ScaleFactor) >> 4;
+ y = (vtx->HiresPosition[1] * ScaleFactor) >> 4;
}
else
{
@@ -829,8 +827,8 @@ void RenderFrame()
glViewport(0, 0, ScreenW, ScreenH);
- glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[FrontBuffer]);
- FrontBuffer = FrontBuffer ? 0 : 1;
+ if (Antialias) glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[2]);
+ else glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[FrontBuffer]);
glDisable(GL_BLEND);
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -902,26 +900,15 @@ void RenderFrame()
RenderSceneChunk(0, 192);
}
- if (false)
+ if (Antialias)
{
- glBindFramebuffer(GL_READ_FRAMEBUFFER, FramebufferID[0]);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, FramebufferID[1]);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, FramebufferID[2]);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, FramebufferID[FrontBuffer]);
glBlitFramebuffer(0, 0, ScreenW, ScreenH, 0, 0, ScreenW/2, ScreenH/2, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-
- glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[1]);
}
- else
- {
- glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]);
- }
-
- /*if (!Accelerated)
- {
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID);
- glReadPixels(0, 0, 256<<ScaleFactor, 192<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
- }*/
+ glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[FrontBuffer]);
+ FrontBuffer = FrontBuffer ? 0 : 1;
}
void PrepareCaptureFrame()
@@ -937,14 +924,11 @@ void PrepareCaptureFrame()
glBindFramebuffer(GL_READ_FRAMEBUFFER, FramebufferID[3]);
glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-
- //glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[original_fb]);
- //glFlush();
}
u32* GetLine(int line)
{
- int stride = 256;// << (ScaleFactor*2);
+ int stride = 256;
if (line == 0)
{
diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp
index 23e45c2..932b5d4 100644
--- a/src/GPU3D_Soft.cpp
+++ b/src/GPU3D_Soft.cpp
@@ -138,16 +138,6 @@ void Reset()
SetupRenderThread();
}
-void SetDisplaySettings(int scale, bool accel)
-{
- printf("SOFT RENDERER SCALE FACTOR: TODO!!!\n");
-}
-
-int GetScale()
-{
- return 0;
-}
-
// Notes on the interpolator:
@@ -2127,10 +2117,5 @@ u32* GetLine(int line)
return &ColorBuffer[(line * ScanlineWidth) + FirstPixelOffset];
}
-void SetupAccelFrame()
-{
- // TODO
-}
-
}
}
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;