[nostalgia] Break part of core out into Turbine and TeaGBA libraries

This commit is contained in:
2023-06-01 23:22:31 -05:00
parent 07284ac595
commit 8c43baedea
119 changed files with 1918 additions and 1873 deletions
+18
View File
@@ -46,6 +46,24 @@ template struct GLObject<deleteVertexArray>;
template struct GLObject<deleteProgram>;
template struct GLObject<deleteShader>;
const FrameBuffer *FrameBufferBind::s_activeFb = nullptr;
FrameBufferBind::FrameBufferBind(const FrameBuffer &fb) noexcept: m_restoreFb(s_activeFb) {
s_activeFb = &fb;
glBindFramebuffer(GL_FRAMEBUFFER, fb);
glViewport(0, 0, fb.width, fb.height);
}
FrameBufferBind::~FrameBufferBind() noexcept {
s_activeFb = m_restoreFb;
if (s_activeFb) {
glBindFramebuffer(GL_FRAMEBUFFER, *s_activeFb);
glViewport(0, 0, s_activeFb->width, s_activeFb->height);
} else {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, s_activeFb->width, s_activeFb->height);
}
}
void bind(const FrameBuffer &fb) noexcept {
glBindFramebuffer(GL_FRAMEBUFFER, fb);
+10
View File
@@ -4,6 +4,7 @@
#pragma once
#include <ox/std/bounds.hpp>
#include <ox/std/defines.hpp>
#include <glad/glad.h>
@@ -134,6 +135,15 @@ struct FrameBuffer {
}
};
class FrameBufferBind {
private:
static const FrameBuffer *s_activeFb;
const FrameBuffer *m_restoreFb = nullptr;
public:
explicit FrameBufferBind(const FrameBuffer &fb) noexcept;
~FrameBufferBind() noexcept;
};
void bind(const FrameBuffer &fb) noexcept;