OpenGL: Implement Framebuffers
This commit is contained in:
20
src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp
Normal file
20
src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - OpenGL Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void OpenGLWindowFramebuffer::Activate() const
|
||||
{
|
||||
GL::Context& context = m_renderWindow.GetContext();
|
||||
if (!GL::Context::SetCurrentContext(&context))
|
||||
throw std::runtime_error("failed to bind window context");
|
||||
|
||||
context.BindFramebuffer(GL::FramebufferTarget::Draw, 0);
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,19 @@ namespace Nz::GL
|
||||
}
|
||||
}
|
||||
|
||||
void Context::BindFramebuffer(GLuint fbo) const
|
||||
{
|
||||
if (m_state.boundDrawFBO != fbo || m_state.boundReadFBO != fbo)
|
||||
{
|
||||
if (!SetCurrentContext(this))
|
||||
throw std::runtime_error("failed to activate context");
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
m_state.boundDrawFBO = fbo;
|
||||
m_state.boundReadFBO = fbo;
|
||||
}
|
||||
}
|
||||
|
||||
void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const
|
||||
{
|
||||
if (textureUnit >= m_state.textureUnits.size())
|
||||
|
||||
Reference in New Issue
Block a user