Handle backbuffer MSAA manually in love.graphics code

Previously love would use SDL APIs to make the system (WGL etc) handle it, which meant the OpenGL context had to be recreated whenever MSAA changed.
This commit is contained in:
Alex Szpakowski
2020-10-25 22:24:07 -03:00
parent 2b0f8495bf
commit 7934ce0a66
5 changed files with 175 additions and 76 deletions
+14 -2
View File
@@ -63,7 +63,7 @@ public:
love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
bool setMode(int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil) override;
bool setMode(int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) override;
void unSetMode() override;
void setActive(bool active) override;
@@ -79,6 +79,9 @@ public:
void present(void *screenshotCallbackData) override;
int getRequestedBackbufferMSAA() const override;
int getBackbufferMSAA() const override;
void setColor(Colorf c) override;
void setScissor(const Rect &rect) override;
@@ -138,15 +141,24 @@ private:
void getAPIStats(int &shaderswitches) const override;
void endPass();
void bindCachedFBO(const RenderTargets &targets);
GLuint bindCachedFBO(const RenderTargets &targets);
void discard(OpenGL::FramebufferTarget target, const std::vector<bool> &colorbuffers, bool depthstencil);
void updateBackbuffer(int width, int height, int pixelwidth, int pixelheight, int msaa);
GLuint getInternalBackbufferFBO() const;
GLuint getSystemBackbufferFBO() const;
void setDebug(bool enable);
std::unordered_map<RenderTargets, GLuint, CachedFBOHasher> framebufferObjects;
bool windowHasStencil;
GLuint mainVAO;
StrongRef<love::graphics::Texture> internalBackbuffer;
StrongRef<love::graphics::Texture> internalBackbufferDepthStencil;
GLuint internalBackbufferFBO;
int requestedBackbufferMSAA;
// Only needed for buffer types that can be bound to shaders.
StrongRef<love::graphics::Buffer> defaultBuffers[BUFFERTYPE_MAX_ENUM];