Share retained mesh dispatch bridge
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "legacy_gl_mesh_dispatch.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "node_colorwheel.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -6,6 +7,10 @@
|
||||
#include "log.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
Node* NodeColorWheel::clone_instantiate() const
|
||||
{
|
||||
return new NodeColorWheel;
|
||||
@@ -47,45 +52,47 @@ void NodeColorWheel::loaded()
|
||||
|
||||
App::I->render_task([&]
|
||||
{
|
||||
const auto buffer_target = pp::renderer::gl::array_buffer_target();
|
||||
const auto upload_usage = pp::renderer::gl::static_draw_buffer_usage();
|
||||
const auto attribute_type = pp::renderer::gl::vertex_attribute_float_component_type();
|
||||
const auto attribute_normalized =
|
||||
static_cast<GLboolean>(pp::renderer::gl::vertex_attribute_not_normalized());
|
||||
static_cast<std::uint8_t>(pp::renderer::gl::vertex_attribute_not_normalized());
|
||||
const std::array<pp::renderer::gl::OpenGlVertexAttribute, 3> attributes {
|
||||
pp::renderer::gl::OpenGlVertexAttribute {
|
||||
.index = 0U,
|
||||
.component_count = 4,
|
||||
.component_type = attribute_type,
|
||||
.normalized = attribute_normalized,
|
||||
.stride = static_cast<std::int32_t>(sizeof(vertex_t)),
|
||||
.offset = 0U,
|
||||
},
|
||||
pp::renderer::gl::OpenGlVertexAttribute {
|
||||
.index = 1U,
|
||||
.component_count = 2,
|
||||
.component_type = attribute_type,
|
||||
.normalized = attribute_normalized,
|
||||
.stride = static_cast<std::int32_t>(sizeof(vertex_t)),
|
||||
.offset = static_cast<std::uintptr_t>(offsetof(vertex_t, uvs)),
|
||||
},
|
||||
pp::renderer::gl::OpenGlVertexAttribute {
|
||||
.index = 2U,
|
||||
.component_count = 4,
|
||||
.component_type = attribute_type,
|
||||
.normalized = attribute_normalized,
|
||||
.stride = static_cast<std::int32_t>(sizeof(vertex_t)),
|
||||
.offset = static_cast<std::uintptr_t>(offsetof(vertex_t, col)),
|
||||
},
|
||||
};
|
||||
|
||||
glGenBuffers(1, &buffers);
|
||||
glBindBuffer(buffer_target, buffers);
|
||||
glBufferData(buffer_target, vertices.size() * sizeof(vertex_t), vertices.data(), upload_usage);
|
||||
glBindBuffer(buffer_target, 0);
|
||||
|
||||
glGenVertexArrays(1, &arrays);
|
||||
glBindVertexArray(arrays);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glBindBuffer(buffer_target, buffers);
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
4,
|
||||
attribute_type,
|
||||
attribute_normalized,
|
||||
sizeof(vertex_t),
|
||||
(GLvoid*)0);
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
attribute_type,
|
||||
attribute_normalized,
|
||||
sizeof(vertex_t),
|
||||
(GLvoid*)offsetof(vertex_t, uvs));
|
||||
glVertexAttribPointer(
|
||||
2,
|
||||
4,
|
||||
attribute_type,
|
||||
attribute_normalized,
|
||||
sizeof(vertex_t),
|
||||
(GLvoid*)offsetof(vertex_t, col));
|
||||
glBindVertexArray(0);
|
||||
const auto mesh = pp::legacy::gl_mesh::create_mesh_objects(
|
||||
pp::renderer::gl::OpenGlMeshUpload {
|
||||
.vertex_data = vertices.data(),
|
||||
.vertex_byte_count = static_cast<std::intptr_t>(vertices.size() * sizeof(vertex_t)),
|
||||
.indexed = false,
|
||||
.vertex_array_count = 1U,
|
||||
.attributes = attributes,
|
||||
},
|
||||
"NodeColorWheel::loaded");
|
||||
buffers = static_cast<GLuint>(mesh.vertex_buffer);
|
||||
arrays = static_cast<GLuint>(mesh.vertex_arrays[0]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -97,13 +104,6 @@ void NodeColorWheel::draw()
|
||||
ShaderManager::u_int(kShaderUniform::Direction, 0); // set horizontal
|
||||
m_circle.draw_fill();
|
||||
|
||||
// ShaderManager::use(kShader::ColorTri);
|
||||
// ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp);
|
||||
// ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(m_hsv, 0.f));
|
||||
// glBindVertexArray(arrays);
|
||||
// glDrawArrays(pp::renderer::gl::primitive_mode_for_fill_count(3U), 0, 3);
|
||||
// glBindVertexArray(0);
|
||||
|
||||
ShaderManager::use(kShader::Color);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::eulerAngleZ(glm::radians(-360.f * m_hsv.x)) * glm::translate(glm::vec3(.45f,0.f,0.f)));
|
||||
ShaderManager::u_vec4(kShaderUniform::Col, {convert_hsv2rgb({glm::fract(m_hsv.x + 0.5f), 1.f, 1.f}), 1.f});
|
||||
|
||||
Reference in New Issue
Block a user