Move viewport render state mapping to renderer gl
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_viewport.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include "shader.h"
|
||||
#include "app.h"
|
||||
|
||||
@@ -11,24 +12,24 @@ void NodeViewport::draw()
|
||||
|
||||
GLint vp[4];
|
||||
GLfloat cc[4];
|
||||
glGetIntegerv(GL_VIEWPORT, vp);
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, cc);
|
||||
glGetIntegerv(pp::renderer::gl::viewport_query(), vp);
|
||||
glGetFloatv(pp::renderer::gl::color_clear_value_query(), cc);
|
||||
|
||||
glClearColor(1, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClear(pp::renderer::gl::framebuffer_color_buffer_mask());
|
||||
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);
|
||||
TextureManager::get(m_tex_id).bind();
|
||||
m_sampler->bind(0);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(pp::renderer::gl::blend_state());
|
||||
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(GL_BLEND);
|
||||
glDisable(pp::renderer::gl::blend_state());
|
||||
|
||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
|
||||
@@ -35,6 +35,9 @@ constexpr std::uint32_t gl_debug_severity_notification = 0x826BU;
|
||||
constexpr std::uint32_t gl_src_alpha = 0x0302U;
|
||||
constexpr std::uint32_t gl_one_minus_src_alpha = 0x0303U;
|
||||
constexpr std::uint32_t gl_line_smooth = 0x0B20U;
|
||||
constexpr std::uint32_t gl_viewport = 0x0BA2U;
|
||||
constexpr std::uint32_t gl_blend = 0x0BE2U;
|
||||
constexpr std::uint32_t gl_color_clear_value = 0x0C22U;
|
||||
constexpr std::uint32_t gl_scissor_test = 0x0C11U;
|
||||
constexpr std::uint32_t gl_depth_test = 0x0B71U;
|
||||
constexpr std::uint32_t gl_func_add = 0x8006U;
|
||||
@@ -480,6 +483,21 @@ std::uint32_t shading_language_version_string_name() noexcept
|
||||
return gl_shading_language_version;
|
||||
}
|
||||
|
||||
std::uint32_t viewport_query() noexcept
|
||||
{
|
||||
return gl_viewport;
|
||||
}
|
||||
|
||||
std::uint32_t color_clear_value_query() noexcept
|
||||
{
|
||||
return gl_color_clear_value;
|
||||
}
|
||||
|
||||
std::uint32_t blend_state() noexcept
|
||||
{
|
||||
return gl_blend;
|
||||
}
|
||||
|
||||
std::uint32_t depth_test_state() noexcept
|
||||
{
|
||||
return gl_depth_test;
|
||||
|
||||
@@ -99,6 +99,9 @@ struct OpenGlReadbackFormat {
|
||||
[[nodiscard]] std::uint32_t vendor_string_name() noexcept;
|
||||
[[nodiscard]] std::uint32_t renderer_string_name() noexcept;
|
||||
[[nodiscard]] std::uint32_t shading_language_version_string_name() noexcept;
|
||||
[[nodiscard]] std::uint32_t viewport_query() noexcept;
|
||||
[[nodiscard]] std::uint32_t color_clear_value_query() noexcept;
|
||||
[[nodiscard]] std::uint32_t blend_state() noexcept;
|
||||
[[nodiscard]] std::uint32_t depth_test_state() noexcept;
|
||||
[[nodiscard]] std::uint32_t scissor_test_state() noexcept;
|
||||
[[nodiscard]] std::uint32_t program_point_size_state() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user