Route import and node texture setup through helpers

This commit is contained in:
2026-06-13 05:36:45 +02:00
parent bb05fac00f
commit e82bcb6d56
5 changed files with 35 additions and 15 deletions

View File

@@ -2049,9 +2049,11 @@ void Canvas::import_equirectangular_thread(std::string file_path, std::shared_pt
m_sampler.bind(0);
set_active_texture_unit(0);
tex.bind();
ShaderManager::use(kShader::Texture);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_mat4(kShaderUniform::MVP, glm::scale(glm::vec3(-1, -1, 1)));
pp::panopainter::setup_legacy_canvas_draw_merge_texture_shader(
pp::panopainter::LegacyCanvasDrawMergeTextureUniforms {
.mvp = glm::scale(glm::vec3(-1, -1, 1)),
.texture_slot = 0,
});
plane.draw_fill();
tex.unbind();
m_sampler.unbind();
@@ -2069,10 +2071,12 @@ void Canvas::import_equirectangular_thread(std::string file_path, std::shared_pt
m_sampler.bind(0);
set_active_texture_unit(0);
tex.bind();
ShaderManager::use(kShader::Texture);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_mat4(kShaderUniform::MVP, proj * camera *
glm::eulerAngleY(glm::radians(180.f)) * glm::scale(glm::vec3(1, -1, 1)));
pp::panopainter::setup_legacy_canvas_draw_merge_texture_shader(
pp::panopainter::LegacyCanvasDrawMergeTextureUniforms {
.mvp = proj * camera *
glm::eulerAngleY(glm::radians(180.f)) * glm::scale(glm::vec3(1, -1, 1)),
.texture_slot = 0,
});
sphere.draw_fill();
tex.unbind();
m_sampler.unbind();

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include "app_core/grid_ui.h"
#include "legacy_canvas_draw_merge_services.h"
#include "legacy_grid_ui_services.h"
#include "legacy_ui_overlay_services.h"
#include "log.h"
@@ -343,11 +344,11 @@ void NodePanelGrid::draw_heightmap(const glm::mat4& proj, const glm::mat4& camer
auto aspect_ratio = static_cast<float>(viewport.height) / static_cast<float>(viewport.width);
apply_grid_capability(pp::renderer::gl::blend_state(), true);
apply_grid_capability(pp::renderer::gl::depth_test_state(), false);
ShaderManager::use(kShader::Texture);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-1.f, 1.f, -1.f, 1.f) *
//glm::scale(glm::vec3(100)) *
glm::translate(glm::vec3(p2d, 0)) * glm::scale(glm::vec3(.1f * aspect_ratio, .1f, 1.f)));
pp::panopainter::setup_legacy_canvas_draw_merge_texture_shader({
.mvp = glm::ortho(-1.f, 1.f, -1.f, 1.f) *
//glm::scale(glm::vec3(100)) *
glm::translate(glm::vec3(p2d, 0)) * glm::scale(glm::vec3(.1f * aspect_ratio, .1f, 1.f)),
.texture_slot = 0});
set_grid_active_texture_unit(0U);
m_sampler_linear.bind(0);
constexpr auto sun_tex = const_hash("data/sun.png");

View File

@@ -2,6 +2,7 @@
#include <cstdint>
#include "legacy_canvas_draw_merge_services.h"
#include "log.h"
#include "legacy_ui_gl_dispatch.h"
#include "node_viewport.h"
@@ -28,9 +29,7 @@ void NodeViewport::draw()
TextureManager::get(m_tex_id).bind();
m_sampler->bind(0);
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);
pp::panopainter::setup_legacy_canvas_draw_merge_texture_shader({.mvp = proj * cam, .texture_slot = 0});
m_faces->draw_fill();
m_sampler->unbind();
TextureManager::get(m_tex_id).unbind();