diff --git a/include/renderer.hpp b/include/renderer.hpp index 91dd287b..5a2b40b4 100644 --- a/include/renderer.hpp +++ b/include/renderer.hpp @@ -14,6 +14,15 @@ class Renderer { static constexpr u32 regNum = 0x300; // Number of internal PICA registers const std::array& regs; + std::array fbSize; // The size of the framebuffer (ie both the colour and depth buffer)' + + u32 colourBufferLoc; // Location in 3DS VRAM for the colour buffer + PICA::ColorFmt colourBufferFormat; // Format of the colours stored in the colour buffer + + // Same for the depth/stencil buffer + u32 depthBufferLoc; + PICA::DepthFmt depthBufferFormat; + public: Renderer(GPU& gpu, const std::array& internalRegs); virtual ~Renderer(); @@ -29,11 +38,19 @@ class Renderer { virtual void screenshot(const std::string& name) = 0; - virtual void setFBSize(u32 width, u32 height) = 0; + void setFBSize(u32 width, u32 height) { + fbSize[0] = width; + fbSize[1] = height; + } - virtual void setColourFormat(PICA::ColorFmt format) = 0; - virtual void setDepthFormat(PICA::DepthFmt format) = 0; + void setColourFormat(PICA::ColorFmt format) { colourBufferFormat = format; } + void setDepthFormat(PICA::DepthFmt format) { + if (format == PICA::DepthFmt::Unknown1) { + Helpers::panic("[PICA] Undocumented depth-stencil mode!"); + } + depthBufferFormat = format; + } - virtual void setColourBufferLoc(u32 loc) = 0; - virtual void setDepthBufferLoc(u32 loc) = 0; + void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; } + void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; } }; \ No newline at end of file diff --git a/include/renderer_gl/renderer_gl.hpp b/include/renderer_gl/renderer_gl.hpp index 4c059f05..38219216 100644 --- a/include/renderer_gl/renderer_gl.hpp +++ b/include/renderer_gl/renderer_gl.hpp @@ -49,15 +49,6 @@ class RendererGL final : public Renderer { SurfaceCache colourBufferCache; SurfaceCache textureCache; - OpenGL::uvec2 fbSize; // The size of the framebuffer (ie both the colour and depth buffer)' - - u32 colourBufferLoc; // Location in 3DS VRAM for the colour buffer - PICA::ColorFmt colourBufferFormat; // Format of the colours stored in the colour buffer - - // Same for the depth/stencil buffer - u32 depthBufferLoc; - PICA::DepthFmt depthBufferFormat; - // Dummy VAO/VBO for blitting the final output OpenGL::VertexArray dummyVAO; OpenGL::VertexBuffer dummyVBO; @@ -88,20 +79,4 @@ class RendererGL final : public Renderer { // Take a screenshot of the screen and store it in a file void screenshot(const std::string& name); - - void setFBSize(u32 width, u32 height) { - fbSize.x() = width; - fbSize.y() = height; - } - - void setColourFormat(PICA::ColorFmt format) { colourBufferFormat = format; } - void setDepthFormat(PICA::DepthFmt format) { - if (format == PICA::DepthFmt::Unknown1) { - Helpers::panic("[PICA] Undocumented depth-stencil mode!"); - } - depthBufferFormat = format; - } - - void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; } - void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; } }; \ No newline at end of file diff --git a/src/core/renderer_gl/renderer_gl.cpp b/src/core/renderer_gl/renderer_gl.cpp index 08a7632c..0083364b 100644 --- a/src/core/renderer_gl/renderer_gl.cpp +++ b/src/core/renderer_gl/renderer_gl.cpp @@ -961,7 +961,7 @@ void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 co OpenGL::Framebuffer RendererGL::getColourFBO() { // We construct a colour buffer object and see if our cache has any matching colour buffers in it // If not, we allocate a texture & FBO for our framebuffer and store it in the cache - ColourBuffer sampleBuffer(colourBufferLoc, colourBufferFormat, fbSize.x(), fbSize.y()); + ColourBuffer sampleBuffer(colourBufferLoc, colourBufferFormat, fbSize[0], fbSize[1]); auto buffer = colourBufferCache.find(sampleBuffer); if (buffer.has_value()) { @@ -973,7 +973,7 @@ OpenGL::Framebuffer RendererGL::getColourFBO() { void RendererGL::bindDepthBuffer() { // Similar logic as the getColourFBO function - DepthBuffer sampleBuffer(depthBufferLoc, depthBufferFormat, fbSize.x(), fbSize.y()); + DepthBuffer sampleBuffer(depthBufferLoc, depthBufferFormat, fbSize[0], fbSize[1]); auto buffer = depthBufferCache.find(sampleBuffer); GLuint tex;