diff options
Diffstat (limited to 'src/GPU3D_OpenGL.cpp')
-rw-r--r-- | src/GPU3D_OpenGL.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index fb9f246..bee0430 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -97,7 +97,10 @@ void SetupDefaultTexParams(GLuint tex) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } -GLRenderer::GLRenderer(melonDS::GPU& gpu) noexcept : Renderer3D(true), GPU(gpu) +GLRenderer::GLRenderer(GLCompositor&& compositor, melonDS::GPU& gpu) noexcept : + Renderer3D(true), + GPU(gpu), + CurGLCompositor(std::move(compositor)) { // GLRenderer::New() will be used to actually initialize the renderer; // The various glDelete* functions silently ignore invalid IDs, @@ -108,9 +111,14 @@ std::unique_ptr<GLRenderer> GLRenderer::New(melonDS::GPU& gpu) noexcept { assert(glEnable != nullptr); + std::optional<GLCompositor> compositor = GLCompositor::New(); + if (!compositor) + return nullptr; + // Will be returned if the initialization succeeds, // or cleaned up via RAII if it fails. - std::unique_ptr<GLRenderer> result = std::unique_ptr<GLRenderer>(new GLRenderer(gpu)); + std::unique_ptr<GLRenderer> result = std::unique_ptr<GLRenderer>(new GLRenderer(std::move(*compositor), gpu)); + compositor = std::nullopt; glEnable(GL_DEPTH_TEST); glEnable(GL_STENCIL_TEST); @@ -327,14 +335,29 @@ GLRenderer::~GLRenderer() void GLRenderer::Reset() { + // This is where the compositor's Reset() method would be called, + // except there's no such method right now. +} + +void GLRenderer::SetBetterPolygons(bool betterpolygons) noexcept +{ + SetRenderSettings(betterpolygons, ScaleFactor); } -void GLRenderer::SetRenderSettings(const RenderSettings& settings) noexcept +void GLRenderer::SetScaleFactor(int scale) noexcept { - int scale = settings.GL_ScaleFactor; + SetRenderSettings(BetterPolygons, scale); +} + +void GLRenderer::SetRenderSettings(bool betterpolygons, int scale) noexcept +{ + if (betterpolygons == BetterPolygons && scale == ScaleFactor) + return; + + CurGLCompositor.SetScaleFactor(scale); ScaleFactor = scale; - BetterPolygons = settings.GL_BetterPolygons; + BetterPolygons = betterpolygons; ScreenW = 256 * scale; ScreenH = 192 * scale; @@ -1302,6 +1325,11 @@ void GLRenderer::RenderFrame() FrontBuffer = FrontBuffer ? 0 : 1; } +void GLRenderer::Stop() +{ + CurGLCompositor.Stop(GPU); +} + void GLRenderer::PrepareCaptureFrame() { // TODO: make sure this picks the right buffer when doing antialiasing @@ -1317,6 +1345,11 @@ void GLRenderer::PrepareCaptureFrame() glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, NULL); } +void GLRenderer::Blit() +{ + CurGLCompositor.RenderFrame(GPU, *this); +} + u32* GLRenderer::GetLine(int line) { int stride = 256; |