diff options
author | Arisotura <thetotalworm@gmail.com> | 2019-05-03 19:28:15 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2019-05-03 19:28:15 +0200 |
commit | 83331bc7e59f483701285bcaf65dec8df80dda36 (patch) | |
tree | c89690f513505ee3fd2f94147acf409da91872df /src/libui_sdl | |
parent | dc68842db46e48529d951554661e1909ad7b54f7 (diff) |
lay base for hi-res rendering
IT'S A PILE OF HACKS
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/main.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 2705560..cc4e15d 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -95,7 +95,9 @@ bool SavestateLoaded; bool ScreenDrawInited = false; uiDrawBitmap* ScreenBitmap = NULL; -u32 ScreenBuffer[256*384]; +u32* ScreenBuffer; + +int ScreenScale; int ScreenGap = 0; int ScreenLayout = 0; @@ -396,6 +398,8 @@ int EmuThreadFunc(void* burp) uiGLMakeContextCurrent(GLContext); NDS::Init(); + ScreenBuffer = new u32[(256*ScreenScale) * (384*ScreenScale)]; + MainScreenPos[0] = 0; MainScreenPos[1] = 0; MainScreenPos[2] = 0; @@ -550,7 +554,7 @@ int EmuThreadFunc(void* burp) } } - memcpy(ScreenBuffer, GPU::Framebuffer, 256*384*4); + memcpy(ScreenBuffer, GPU::Framebuffer, (256*ScreenScale)*(384*ScreenScale)*4); uiAreaQueueRedrawAll(MainDrawArea); // framerate limiter based off SDL2_gfx @@ -616,6 +620,8 @@ int EmuThreadFunc(void* burp) if (joybuttons) delete[] joybuttons; + delete[] ScreenBuffer; + NDS::DeInit(); Platform::LAN_DeInit(); @@ -625,16 +631,17 @@ int EmuThreadFunc(void* burp) void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params) { + // TODO: recreate bitmap if screen scale changed if (!ScreenDrawInited) { ScreenDrawInited = true; - ScreenBitmap = uiDrawNewBitmap(params->Context, 256, 384); + ScreenBitmap = uiDrawNewBitmap(params->Context, 256*ScreenScale, 384*ScreenScale); } if (!ScreenBitmap) return; - uiRect top = {0, 0, 256, 192}; - uiRect bot = {0, 192, 256, 192}; + uiRect top = {0, 0, 256*ScreenScale, 192*ScreenScale}; + uiRect bot = {0, 192*ScreenScale, 256*ScreenScale, 192*ScreenScale}; uiDrawBitmapUpdate(ScreenBitmap, ScreenBuffer); @@ -817,6 +824,9 @@ void SetupScreenRects(int width, int height) screenH = 192; } + screenW *= ScreenScale; + screenH *= ScreenScale; + uiRect *topscreen, *bottomscreen; if (ScreenRotation == 1 || ScreenRotation == 2) { @@ -1010,6 +1020,9 @@ void SetMinSize(int w, int h) int cw, ch; uiWindowContentSize(MainWindow, &cw, &ch); + w *= ScreenScale; + h *= ScreenScale; + uiControlSetMinSize(uiControl(MainDrawArea), w, h); if ((cw < w) || (ch < h)) { @@ -1535,8 +1548,8 @@ void OnSetScreenSize(uiMenuItem* item, uiWindow* window, void* param) int factor = *(int*)param; bool isHori = (ScreenRotation == 1 || ScreenRotation == 3); - int w = 256*factor; - int h = 192*factor; + int w = 256*factor * ScreenScale; + int h = 192*factor * ScreenScale; if (ScreenLayout == 0) // natural { @@ -1947,6 +1960,9 @@ int main(int argc, char** argv) WindowWidth = w; WindowHeight = h; + //ScreenScale = 1; + ScreenScale = 2; // HAW HAW HAW + MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, w, h, Config::WindowMaximized, 1, 1); uiWindowOnClosing(MainWindow, OnCloseWindow, NULL); |