Commit 74252eee authored by Johannes Braun's avatar Johannes Braun
Browse files

Added global-like engine contexts

parent d9b0a3bd
#include <array>
#include <random>
#include <util/log.h>
#include <core/time.h>
int main()
{
Log_Info << sizeof(int*);
bool b = true;
system("pause");
}
\ No newline at end of file
......@@ -13,18 +13,17 @@ using namespace glare;
int main(int argc, char* argv[])
{
// Initialize engine from settings xml
core::state::initialize(files::asset("/preferences/default.xml"));
auto context_id = core::Context::createAsCurrent(files::asset("/preferences/default.xml"));
// Load a scene and attach it to the constant root
core::state::graph_root->attach(core::global_resources::scenes.get(files::asset("meshes/scenery/cbox.dae"), 1.0f));
core::Context::current().graph()->attach(core::global_resources::scenes.get(files::asset("meshes/scenery/cbox.dae"), 1.0f));
// Create a skybox
core::state::skybox->reset(core::Skybox::collectFilesFrom(files::asset("textures/ryfjallet/")));
core::Context::current().skybox()->reset(core::Skybox::collectFilesFrom(files::asset("textures/ryfjallet/")));
// Add a PlayerController to move around
core::state::camera->owner()->makeComponent<component::PlayerController>();
core::Context::current().camera()->owner()->makeComponent<component::PlayerController>();
// Render the scene with the pathtracer
core::state::mainLoop([]() { core::state::draw(core::state::DrawMode::eGBuffer); });
core::Context::current().loop([]() { core::Context::current().draw(core::Context::DrawMode::eGBuffer); });
}
\ No newline at end of file
......@@ -51,11 +51,11 @@ void drawSceneWindow();
// Implementation
int main(int argc, char* argv[])
{
core::state::initialize(engine_settings_path);
core::Callbacks::addKeyDownCallback("main_application", keyPress);
core::Context::createAsCurrent(engine_settings_path);
core::Context::current().callbacks().addKeyDownCallback("main_application", keyPress);
// Create a skybox from cube map.
core::state::skybox->reset(core::Skybox::collectFilesFrom(skybox_files_path));
core::Context::current().skybox()->reset(core::Skybox::collectFilesFrom(skybox_files_path));
// Load the pre-determined startup scene
loadScene(startup_scene_path, 1.f);
......@@ -63,7 +63,7 @@ int main(int argc, char* argv[])
// Make some ambient sound source
al::listenerf(al::ListenerParam::eGain, 0.02f);
auto audio_buffer = core::global_resources::sounds.get(env_audio_path);
auto environment_source = core::state::graph_root->makeComponent<core::SoundSource>(audio_buffer->id());
auto environment_source = core::Context::current().graph()->makeComponent<core::SoundSource>(audio_buffer->id());
environment_source->setLooping(true);
environment_source->play();
......@@ -72,20 +72,20 @@ int main(int argc, char* argv[])
pathtracer->loadSettings(pathtracer_settings_path);
// For debug purposes, add a frame rate counter to the root node, which will never be deleted/removed on runtime if not explicitly told so.
core::state::graph_root->makeComponent<component::FramerateCounter>();
core::Context::current().graph()->makeComponent<component::FramerateCounter>();
core::state::mainLoop([&]()
core::Context::current().loop([&]()
{
switch (render_mode)
{
case RenderMode::eLines:
core::state::draw(core::state::DrawMode::eWireframe);
core::Context::current().draw(core::Context::DrawMode::eWireframe);
break;
case RenderMode::eRaw:
core::state::draw(core::state::DrawMode::eColors);
core::Context::current().draw(core::Context::DrawMode::eColors);
break;
case RenderMode::eGBuffer:
core::state::draw(core::state::DrawMode::eGBuffer);
core::Context::current().draw(core::Context::DrawMode::eGBuffer);
break;
case RenderMode::ePathtrace:
pathtracer->draw();
......@@ -111,33 +111,33 @@ void keyPress(controls::Key key, controls::KeyMods mods)
void loadScene(const fs::path& path, float scale)
{
// Ain't no need for the last scene anymore.
bool had_player_controller = core::state::graph_root->find<component::PlayerController>() != nullptr;
core::state::graph_root->clearChildren();
bool had_player_controller = core::Context::current().graph()->find<component::PlayerController>() != nullptr;
core::Context::current().graph()->clearChildren();
//Initialize some scene graph from an obj file
// Don't use resources here, because of duplicating lights.
if (auto scene = core::Collada().load(path, scale))
{
core::state::graph_root->attach(scene);
core::Context::current().graph()->attach(scene);
}
else
{
core::state::quit();
core::Context::current().destroy();
console::prompt("Scene could not be loaded: " + path.string() + ". Press [ENTER] to exit.", 1);
}
std::shared_ptr<core::SceneNode> cam_node = core::state::graph_root->find<core::Camera>();
std::shared_ptr<core::SceneNode> cam_node = core::Context::current().graph()->find<core::Camera>();
if (cam_node)
{
//If there are any cameras in the collada file, take the first one.
core::state::camera = cam_node->getComponent<core::Camera>();
core::Context::current().switchCamera(cam_node->getComponent<core::Camera>());
}
else
{
//Add a camera to render from
cam_node = std::make_shared<core::SceneNode>("custom_camera");
cam_node->addComponent(core::state::camera);
core::state::graph_root->attach(cam_node);
cam_node->addComponent(core::Context::current().camera());
core::Context::current().graph()->attach(cam_node);
}
if(!had_player_controller)
......@@ -146,7 +146,7 @@ void loadScene(const fs::path& path, float scale)
// Reload Pathtracer if used.
if (pathtracer && pathtracer->collector())
pathtracer->reload(core::state::graph_root);
pathtracer->reload(core::Context::current().graph());
}
void drawSceneWindow()
......@@ -160,7 +160,7 @@ void drawSceneWindow()
{
ImGui::BeginChild("Graph", ImVec2(0, ImGui::GetContentRegionAvail().y * 0.5f));
ImGui::BeginSelectableTree("tree_scene_graph");
core::state::graph_root->debugGui();
core::Context::current().graph()->debugGui();
ImGui::EndSelectableTree();
ImGui::EndChild();
ImGui::Separator();
......@@ -599,16 +599,16 @@ void drawSettingsWindow()
}
else if (ImGui::FeatureButton("Initialize Pathtracer", ImVec2(ImGui::GetContentRegionAvailWidth(), 0)))
{
pathtracer->reload(core::state::graph_root);
pathtracer->reload(core::Context::current().graph());
}
}
else if (current_tab == 4)
{
ImGui::Title("General Settings");
auto vsync = static_cast<int>(core::state::window->getVSync());
auto vsync = static_cast<int>(core::Context::current().window().getVSync());
if (ImGui::Combo("VSync", &vsync, { "None", "60 FPS", "30 FPS", "20 FPS" }))
core::state::window->setVSync(static_cast<VSync>(vsync));
core::Context::current().window().setVSync(static_cast<VSync>(vsync));
ImGui::Spacing();
......
......@@ -14,8 +14,8 @@ namespace glare::component
PlayerController::PlayerController()
: SceneComponent("Player Controller"), m_id(s_current_id++)
{
core::Callbacks::addKeyActionCallback("player_controller" + std::to_string(m_id), std::bind(&PlayerController::onKeyAction, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
core::Callbacks::addMouseButtonCallback("player_controller" + std::to_string(m_id), std::bind(&PlayerController::onMouseButtonAction, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
core::Context::current().callbacks().addKeyActionCallback("player_controller" + std::to_string(m_id), std::bind(&PlayerController::onKeyAction, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
core::Context::current().callbacks().addMouseButtonCallback("player_controller" + std::to_string(m_id), std::bind(&PlayerController::onMouseButtonAction, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
registerForMessage(tags::camera);
}
......@@ -23,8 +23,8 @@ namespace glare::component
PlayerController::~PlayerController()
{
try {
core::Callbacks::removeKeyActionCallback("player_controller" + std::to_string(m_id));
core::Callbacks::removeMouseButtonCallback("player_controller" + std::to_string(m_id));
core::Context::current().callbacks().removeKeyActionCallback("player_controller" + std::to_string(m_id));
core::Context::current().callbacks().removeMouseButtonCallback("player_controller" + std::to_string(m_id));
unregisterForMessage(tags::camera);
}
catch (...)
......@@ -34,7 +34,7 @@ namespace glare::component
bool PlayerController::isPossessed() const
{
return core::state::camera->owner() == owner();
return core::Context::current().camera()->owner() == owner();
}
void PlayerController::handle(messaging::message_t &message)
......@@ -43,9 +43,9 @@ namespace glare::component
{
case tags::camera:
{
if (owner() != core::state::camera->owner())
if (owner() != core::Context::current().camera()->owner())
{
core::state::camera->owner()->addComponent(detachAs<PlayerController>());
core::Context::current().camera()->owner()->addComponent(detachAs<PlayerController>());
}
} break;
}
......@@ -58,7 +58,7 @@ namespace glare::component
switch (key)
{
case controls::Key::eEscape:
core::state::window->close();
core::Context::current().window().close();
return;
}
}
......
......@@ -5,26 +5,26 @@ namespace glare::controls
{
ButtonAction keyState(Key key)
{
return static_cast<ButtonAction>(core::state::window->getKeyState(static_cast<int>(key)));
return static_cast<ButtonAction>(core::Context::current().window().getKeyState(static_cast<int>(key)));
}
ButtonAction mouseButtonState(MouseButton button)
{
return static_cast<ButtonAction>(core::state::window->getMouseButtonState(static_cast<int>(button)));
return static_cast<ButtonAction>(core::Context::current().window().getMouseButtonState(static_cast<int>(button)));
}
glm::vec2 getCursorPosition()
{
return core::state::window->getCursorPosition();
return core::Context::current().window().getCursorPosition();
}
void setCursorGrabbed(bool grabbed)
{
glfwSetInputMode(core::state::window->glfw(), GLFW_CURSOR, grabbed ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
glfwSetInputMode(core::Context::current().window().glfw(), GLFW_CURSOR, grabbed ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
}
bool isCursorGrabbed()
{
return glfwGetInputMode(core::state::window->glfw(), GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
return glfwGetInputMode(core::Context::current().window().glfw(), GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
}
}
......@@ -3,7 +3,8 @@
#include <util/log.h>
#include <core/message_tags.h>
#include <imgui/imgui_glfw.h>
#include <imgui/imgui_glfw.h>
#include <core/state.h>
namespace glare::core
{
......@@ -13,7 +14,10 @@ namespace glare::core
}
Camera::Camera()
: SceneComponent("Camera"), m_adapt_to_screen(true), m_width(state::window->getWidth()), m_height(state::window->getHeight()), m_projection(Projection::ePerspective)
: SceneComponent("Camera"), m_adapt_to_screen(true),
m_width(0),
m_height(0),
m_projection(Projection::ePerspective)
{
}
......@@ -32,7 +36,7 @@ namespace glare::core
if (ImGui::Button("Make Default"))
{
core::state::camera = std::static_pointer_cast<Camera>(shared_from_this());
core::Context::current().switchCamera(std::static_pointer_cast<Camera>(shared_from_this()));
messaging::Handler::getInstance().submit(tags::camera, 1);
}
ImGui::PopID();
......@@ -52,8 +56,8 @@ namespace glare::core
{
if (m_adapt_to_screen)
{
m_width = state::window->getWidth();
m_height = state::window->getHeight();
m_width = core::Context::current().window().getWidth();
m_height = core::Context::current().window().getHeight();
}
const glm::vec3 world_position = owner()->worldTransform().position;
......
......@@ -3,7 +3,6 @@
#include <glm/ext.hpp>
#include <core/state.h>
#include <core/graph/component.h>
namespace glare::core
......
......@@ -3,6 +3,7 @@
#include <util/messaging.h>
#include <core/message_tags.h>
#include <core/numeric/geometry.h>
#include "core/state.h"
#include "material.h"
#include "mesh.h"
#include <core/rendering/batch_render_list.h>
......@@ -18,7 +19,7 @@ namespace glare::core
LightComponent::~LightComponent()
{
// Light has been removed
if (!core::state::window->isClosing())
if (core::Context::hasCurrentContext() && !core::Context::current().window().isClosing())
messaging::Handler::getInstance().submit(tags::light, LightUpdate{ m_id, nullptr });
}
......@@ -198,7 +199,7 @@ namespace glare::core
case DrawMode::eShaded:
{
if (m_shadow_map_renderer)
m_shadow_map_renderer->build(core::state::graph_root);
m_shadow_map_renderer->build(core::Context::current().graph());
if (m_id == 0) {
static uint64_t current_id = 1;
......@@ -207,15 +208,14 @@ namespace glare::core
// Light has been added
messaging::Handler::getInstance().submit(tags::light, LightUpdate{ m_id, this });
}
state::lights->submit(buildLightShadow());
core::Context::current().lights().submit(buildLightShadow());
static auto light_shader = std::make_shared<Program>(std::vector<std::shared_ptr<Shader>>{
std::make_shared<Shader>(gl::ShaderType::eVertex, files::shader("lamp/lamp.vert")),
std::make_shared<Shader>(gl::ShaderType::eFragment, files::shader("lamp/lamp.frag"))
});
static std::unique_ptr<Mesh> mesh = std::make_unique<Mesh>();
state::renderer->submit(light_shader, std::make_shared<BatchDrawable>([this](std::shared_ptr<Program> program)
Context::current().renderList().submit(light_shader, std::make_shared<BatchDrawable>([this](std::shared_ptr<Program> program)
{
program->uniform("u_color", m_color);
mesh->draw();
......
......@@ -32,16 +32,16 @@ namespace glare::core
int current_fb;
gl::getIntegerv(gl::GetParameter::eCurrentFramebuffer, &current_fb);
m_framebuffer->activate();
const auto main_camera = core::state::camera;
core::state::camera = m_camera;
const auto main_camera = core::Context::current().camera();
core::Context::current().camera() = m_camera;
gl::viewport(0, 0, m_size.x, m_size.y);
gl::clear(gl::ClearBufferBits::eColor | gl::ClearBufferBits::eDepth);
gl::setEnabled(gl::EnableParameter::eCullFace, false);
scene_root->draw(DrawMode::eUnshaded);
gl::setEnabled(gl::EnableParameter::eCullFace, true);
core::state::camera = main_camera;
gl::viewport(0, 0, static_cast<unsigned>(core::state::camera->getWidth()),
static_cast<unsigned>(core::state::camera->getWidth() / core::state::camera->getAspectRatio()));
core::Context::current().camera() = main_camera;
gl::viewport(0, 0, static_cast<unsigned>(core::Context::current().camera()->getWidth()),
static_cast<unsigned>(core::Context::current().camera()->getWidth() / core::Context::current().camera()->getAspectRatio()));
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, current_fb);
m_matrix = m_bias_matrix * m_camera->viewProjectionMatrix();
......
......@@ -92,7 +92,7 @@ namespace glare::core
{
if (mode == DrawMode::eShaded)
{
state::renderer->submit(m_cubemap_shader, m_drawable, glm::mat4(1.f));
Context::current().renderList().submit(m_cubemap_shader, m_drawable, glm::mat4(1.f));
}
}
......
......@@ -3,6 +3,7 @@
#include <core/objects/camera.h>
#include <core/objects/light.h>
#include <core/time.h>
#include <core/state.h>
namespace glare::core
{
......@@ -28,17 +29,17 @@ namespace glare::core
shader->use();
// Now apply a bunch of global and useful uniforms once for all objects drawn with this shader.
shader->uniform("globals.camera.view_matrix", state::camera->viewMatrix());
shader->uniform("globals.camera.projection_matrix", state::camera->projectionMatrix());
shader->uniform("globals.camera.view_projection_matrix", state::camera->viewProjectionMatrix());
shader->uniform("globals.camera.inv_view_projection_matrix", glm::inverse(state::camera->viewProjectionMatrix()));
shader->uniform("globals.camera.position", state::camera->owner()->transform.position);
shader->uniform("globals.camera.view_matrix", core::Context::current().camera()->viewMatrix());
shader->uniform("globals.camera.projection_matrix", core::Context::current().camera()->projectionMatrix());
shader->uniform("globals.camera.view_projection_matrix", core::Context::current().camera()->viewProjectionMatrix());
shader->uniform("globals.camera.inv_view_projection_matrix", glm::inverse(core::Context::current().camera()->viewProjectionMatrix()));
shader->uniform("globals.camera.position", core::Context::current().camera()->owner()->transform.position);
// Also upload the current time. Might be funny to use
shader->uniform("globals.time.delta", static_cast<float>(Time::deltaTime())); // seconds
shader->uniform("globals.time.current", static_cast<float>(Time::time())); // seconds
glm::vec2 screen_size(state::window->getWidth(), state::window->getHeight());
glm::vec2 screen_size(core::Context::current().window().getWidth(), core::Context::current().window().getHeight());
shader->uniform("globals.screen.size", screen_size);
shader->uniform("globals.screen.inv_size", glm::vec2(1) / screen_size);
......@@ -49,9 +50,9 @@ namespace glare::core
// The renderable shall not upload any global uniform.
// If it needs a separate one (like a different view matrix) it should be a separate variable.
shader->uniform("globals.camera.model_matrix", renderable.second);
shader->uniform("globals.camera.model_view_matrix", state::camera->viewMatrix() * renderable.second);
shader->uniform("globals.camera.model_view_projection_matrix", state::camera->projectionMatrix() * state::camera->viewMatrix() * renderable.second);
shader->uniform("globals.camera.normal_matrix", glm::inverse(glm::transpose(state::camera->viewMatrix() * renderable.second)));
shader->uniform("globals.camera.model_view_matrix", core::Context::current().camera()->viewMatrix() * renderable.second);
shader->uniform("globals.camera.model_view_projection_matrix", core::Context::current().camera()->projectionMatrix() * core::Context::current().camera()->viewMatrix() * renderable.second);
shader->uniform("globals.camera.normal_matrix", glm::inverse(glm::transpose(core::Context::current().camera()->viewMatrix() * renderable.second)));
renderable.first->draw_call(shader);
}
}
......
......@@ -36,7 +36,7 @@ namespace glare::core
case DrawMode::eShaded:
// Submit to draw list for rendering with the given shader.
if (m_drawable && program)
state::renderer->submit(program, m_drawable, owner()->worldTransform().matrix());
Context::current().renderList().submit(program, m_drawable, owner()->worldTransform().matrix());
break;
case DrawMode::eUnshaded:
// Same for all objects. Draw Directly.
......
......@@ -88,11 +88,11 @@ namespace glare::core
void GBuffer::draw() const
{
m_lights_buffer->upload<LightShadow>(state::lights->get(), gl::BufferUsage::eDynamicDraw);
m_lights_buffer->upload<LightShadow>(core::Context::current().lights().get(), gl::BufferUsage::eDynamicDraw);
m_temporary_framebuffer_01->activate();
static auto ssao_renderer = DefaultTextureRenderers::makeRenderer(files::shader("screenshader/ssao/ssao.frag"));
ssao_renderer->shader().uniform("projection_matrix", state::camera->projectionMatrix());
ssao_renderer->shader().uniform("projection_matrix", core::Context::current().camera()->projectionMatrix());
ssao_renderer->shader().uniform("screen_space_positions", m_gbuffer_framebuffer->colorAttachment(gl::Attachment::eColor3).makeTextureResident());
ssao_renderer->shader().uniform("screen_space_normals", m_gbuffer_framebuffer->colorAttachment(gl::Attachment::eColor5).makeTextureResident());
ssao_renderer->shader().uniform("u_gbuffer.depth", m_gbuffer_framebuffer->depthAttachment().makeTextureResident());
......@@ -123,9 +123,9 @@ namespace glare::core
m_texture_renderer->shader().uniform("environment", m_skybox->makeResident());
m_texture_renderer->shader().uniform("u_ssao_texture", m_temporary_framebuffer_01->colorAttachment(gl::Attachment::eColor0).makeTextureResident());
m_texture_renderer->shader().uniform("u_view", state::camera->viewMatrix());
m_texture_renderer->shader().uniform("u_projection", state::camera->projectionMatrix());
m_texture_renderer->shader().uniform("camera_position", glm::vec3(state::camera->owner()->worldTransform().position));
m_texture_renderer->shader().uniform("u_view", core::Context::current().camera()->viewMatrix());
m_texture_renderer->shader().uniform("u_projection", core::Context::current().camera()->projectionMatrix());
m_texture_renderer->shader().uniform("camera_position", glm::vec3(core::Context::current().camera()->owner()->worldTransform().position));
m_texture_renderer->draw();
gl::setEnabled(gl::EnableParameter::eDepthTest, true);
}
......
......@@ -3,6 +3,8 @@
#include <core/res/res.h>
#include <core/time.h>
#include <util/files.h>
#include <core/anim/animations.h>
#include <core/state.h>
#include "pugixml/pugixml.hpp"
namespace glare::core
......@@ -110,18 +112,18 @@ namespace glare::core
m_run_renderer = false;
};
core::state::animation_manager->addAnimation(anim);
core::Context::current().animations().addAnimation(anim);
core::Time::newFrame();
m_sound_source->play();
while (true)
{
core::Time::newFrame();
core::state::animation_manager->update();
core::Context::current().animations().update();
gl::clearColor(m_color.r, m_color.g, m_color.b, m_color.a);
gl::clear(gl::ClearBufferBits::eColor);
m_logo_renderer->draw(*m_texture);
glfwSwapBuffers(core::state::window->glfw());
glfwSwapBuffers(core::Context::current().window().glfw());
if (!m_run_renderer)
break;
......
......@@ -19,6 +19,53 @@ namespace glare::core
return *m_shader;
}
/**
* \brief Draws the given texture to the screen using a screen-filling triangle.
* \tparam TextureType The type of texture to render. (Mostly an implicite parameter, so usually no need to set it manually)
* \param texture The texture to render.
*/
void TextureRenderer::draw(uint64_t texture, unsigned samples) const
{
gl::setEnabled(gl::EnableParameter::eDepthTest, false);
m_shader->use();
if (m_pre_draw_callback)
m_pre_draw_callback(*m_shader);
m_shader->uniform("screen_texture", texture);
m_shader->uniform("u_sample_count", samples);
m_shader->uniform("u_inverse_resolution", glm::vec2(1) / Context::current().window().getResolution());
m_vertex_array->bind();
gl::drawArrays(gl::PrimitiveType::ePoints, 0, 1);
m_vertex_array->unbind();
if (m_post_draw_callback)
m_post_draw_callback();
gl::setEnabled(gl::EnableParameter::eDepthTest, true);
}
/**
* \brief Some default renderers because why not?
*/
void TextureRenderer::draw(unsigned samples) const
{
gl::setEnabled(gl::EnableParameter::eDepthTest, false);
m_shader->use();
if (m_pre_draw_callback)
m_pre_draw_callback(*m_shader);
m_shader->uniform("u_inverse_resolution", glm::vec2(1) / Context::current().window().getResolution());
m_shader->uniform("u_sample_count", samples);
m_vertex_array->bind();
gl::drawArrays(gl::PrimitiveType::ePoints, 0, 1);
m_vertex_array->unbind();
if (m_post_draw_callback)
m_post_draw_callback();
gl::setEnabled(gl::EnableParameter::eDepthTest, true);
}
void TextureRenderer::addPreDrawCallback(std::function<void(const Program& shader)> callback)
{
m_pre_draw_callback = callback;
......
......@@ -3,7 +3,6 @@
#include <memory>
#include <core/state.h>
#include <core/base/program.h>
#include <core/base/vertex_array.h>
......@@ -54,69 +53,7 @@ namespace glare::core
template <typename TextureType>
void TextureRenderer::draw(const TextureType& texture, unsigned samples) const
{
gl::setEnabled(gl::EnableParameter::eDepthTest, false);
m_shader->use();
if (m_pre_draw_callback)
m_pre_draw_callback(*m_shader);
m_shader->uniform("screen_texture", texture.makeTextureResident());
m_shader->uniform("u_inverse_resolution", glm::vec2(1) / state::window->getResolution());
m_shader->uniform("u_sample_count", samples);
m_vertex_array->bind();
gl::drawArrays(gl::PrimitiveType::ePoints, 0, 1);
m_vertex_array->unbind();
if (m_post_draw_callback)
m_post_draw_callback();
gl::setEnabled(gl::EnableParameter::eDepthTest, true);
}