Route UI leaf render state through GL dispatch
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "log.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "node_viewport.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include "shader.h"
|
||||
#include "app.h"
|
||||
|
||||
@@ -10,29 +13,31 @@ void NodeViewport::draw()
|
||||
glm::mat4 cam = glm::lookAt(glm::vec3(sinf(angle) * 10, 0, -10), glm::vec3(0, 0, 0), glm::vec3(0, -1, 0));
|
||||
glm::mat4 proj = glm::perspective<float>(glm::radians(45.f), m_clip.z / m_clip.w, .1f, 100);
|
||||
|
||||
GLint vp[4];
|
||||
GLfloat cc[4];
|
||||
glGetIntegerv(pp::renderer::gl::viewport_query(), vp);
|
||||
glGetFloatv(pp::renderer::gl::color_clear_value_query(), cc);
|
||||
const auto vp = pp::legacy::ui_gl::query_viewport("NodeViewport");
|
||||
const auto cc = pp::legacy::ui_gl::query_clear_color("NodeViewport");
|
||||
|
||||
glClearColor(1, 0, 0, 1);
|
||||
glClear(pp::renderer::gl::framebuffer_color_buffer_mask());
|
||||
pp::legacy::ui_gl::clear_color_buffer({ 1.f, 0.f, 0.f, 1.f }, "NodeViewport");
|
||||
auto box = m_clip * root()->m_zoom;
|
||||
glm::ivec4 c = (glm::ivec4)glm::vec4(box.x, (int)(vp[3] - box.y - box.w), box.z, box.w);
|
||||
glViewport(c.x + App::I->off_x, c.y + App::I->off_y, c.z, c.w);
|
||||
pp::legacy::ui_gl::apply_viewport(
|
||||
static_cast<std::int32_t>(c.x + App::I->off_x),
|
||||
static_cast<std::int32_t>(c.y + App::I->off_y),
|
||||
c.z,
|
||||
c.w,
|
||||
"NodeViewport");
|
||||
TextureManager::get(m_tex_id).bind();
|
||||
m_sampler->bind(0);
|
||||
glEnable(pp::renderer::gl::blend_state());
|
||||
pp::legacy::ui_gl::set_blend_enabled(true, "NodeViewport");
|
||||
ShaderManager::use(kShader::Texture);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj * cam);
|
||||
m_faces->draw_fill();
|
||||
m_sampler->unbind();
|
||||
TextureManager::get(m_tex_id).unbind();
|
||||
glDisable(pp::renderer::gl::blend_state());
|
||||
pp::legacy::ui_gl::set_blend_enabled(false, "NodeViewport");
|
||||
|
||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
pp::legacy::ui_gl::apply_viewport(vp[0], vp[1], vp[2], vp[3], "NodeViewport");
|
||||
pp::legacy::ui_gl::set_clear_color(cc, "NodeViewport");
|
||||
}
|
||||
Node* NodeViewport::clone_instantiate() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user