Move color wheel state mapping to renderer gl
This commit is contained in:
@@ -174,6 +174,9 @@ Known local toolchain state:
|
|||||||
`NodeImage` drawing and remote-image texture creation also consume
|
`NodeImage` drawing and remote-image texture creation also consume
|
||||||
backend-owned mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA
|
backend-owned mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA
|
||||||
texture format mapping.
|
texture format mapping.
|
||||||
|
`NodeColorWheel` triangle-buffer setup and draw-state handling also consume
|
||||||
|
backend-owned array-buffer, static-upload, vertex-attribute, primitive-mode,
|
||||||
|
and blend-state tokens.
|
||||||
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
||||||
for the current headless component matrix; see DEBT-0007 for remaining app
|
for the current headless component matrix; see DEBT-0007 for remaining app
|
||||||
and platform triplet migration.
|
and platform triplet migration.
|
||||||
|
|||||||
@@ -441,6 +441,9 @@ target and blend-state tokens to `pp_renderer_gl`.
|
|||||||
`NodeImage` drawing and remote-image texture creation now delegate mipmapped
|
`NodeImage` drawing and remote-image texture creation now delegate mipmapped
|
||||||
sampler filters, blend-state tokens, and RGBA8/RGBA texture format mapping to
|
sampler filters, blend-state tokens, and RGBA8/RGBA texture format mapping to
|
||||||
`pp_renderer_gl`.
|
`pp_renderer_gl`.
|
||||||
|
`NodeColorWheel` triangle-buffer setup and draw-state handling now delegate
|
||||||
|
array-buffer, static-upload, vertex-attribute, primitive-mode, and blend-state
|
||||||
|
tokens to `pp_renderer_gl`.
|
||||||
The existing renderer classes are not yet fully
|
The existing renderer classes are not yet fully
|
||||||
behind the renderer interfaces.
|
behind the renderer interfaces.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "node_colorwheel.h"
|
#include "node_colorwheel.h"
|
||||||
|
#include "renderer_gl/opengl_capabilities.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
@@ -29,43 +30,67 @@ void NodeColorWheel::init_controls()
|
|||||||
|
|
||||||
void NodeColorWheel::loaded()
|
void NodeColorWheel::loaded()
|
||||||
{
|
{
|
||||||
m_circle.create<64>(.5, .4, Circle::kUVMapping::Tube);
|
m_circle.create<64>(.5f, .4f, Circle::kUVMapping::Tube);
|
||||||
m_cur_hue.create<16>(.05, 0.04);
|
m_cur_hue.create<16>(.05f, 0.04f);
|
||||||
m_cur_quad.create<16>(.04, 0.03, Circle::kUVMapping::Tube);
|
m_cur_quad.create<16>(.04f, 0.03f, Circle::kUVMapping::Tube);
|
||||||
|
|
||||||
float quad_scale = glm::sin(glm::radians(45.f)) * 0.8f;
|
float quad_scale = glm::sin(glm::radians(45.f)) * 0.8f;
|
||||||
m_quad.create<1>(quad_scale, quad_scale);
|
m_quad.create<1>(quad_scale, quad_scale);
|
||||||
|
|
||||||
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; glm::vec4 col; };
|
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; glm::vec4 col; };
|
||||||
std::vector<vertex_t> vertices;
|
std::vector<vertex_t> vertices;
|
||||||
float l = 0.4;
|
float l = 0.4f;
|
||||||
vertices.push_back({{glm::cos(4.f/3.f*glm::pi<float>())*l,glm::sin(4.f/3.f*glm::pi<float>())*l,0,1},{1,-1},{1,1,1,1}});
|
vertices.push_back({{glm::cos(4.f/3.f*glm::pi<float>())*l,glm::sin(4.f/3.f*glm::pi<float>())*l,0,1},{1,-1},{1,1,1,1}});
|
||||||
vertices.push_back({{glm::cos(2.f/3.f*glm::pi<float>())*l,glm::sin(2.f/3.f*glm::pi<float>())*l,0,1},{0,0},{0,0,0,1}});
|
vertices.push_back({{glm::cos(2.f/3.f*glm::pi<float>())*l,glm::sin(2.f/3.f*glm::pi<float>())*l,0,1},{0,0},{0,0,0,1}});
|
||||||
vertices.push_back({{l,0,0,1},{1,1},{1,0,0,1}});
|
vertices.push_back({{l,0,0,1},{1,1},{1,0,0,1}});
|
||||||
|
|
||||||
App::I->render_task([&]
|
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());
|
||||||
|
|
||||||
glGenBuffers(1, &buffers);
|
glGenBuffers(1, &buffers);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffers);
|
glBindBuffer(buffer_target, buffers);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(vertex_t), vertices.data(), GL_STATIC_DRAW);
|
glBufferData(buffer_target, vertices.size() * sizeof(vertex_t), vertices.data(), upload_usage);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(buffer_target, 0);
|
||||||
|
|
||||||
glGenVertexArrays(1, &arrays);
|
glGenVertexArrays(1, &arrays);
|
||||||
glBindVertexArray(arrays);
|
glBindVertexArray(arrays);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
glEnableVertexAttribArray(2);
|
glEnableVertexAttribArray(2);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffers);
|
glBindBuffer(buffer_target, buffers);
|
||||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
|
glVertexAttribPointer(
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
|
0,
|
||||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, col));
|
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);
|
glBindVertexArray(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeColorWheel::draw()
|
void NodeColorWheel::draw()
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(pp::renderer::gl::blend_state());
|
||||||
ShaderManager::use(kShader::ColorHue);
|
ShaderManager::use(kShader::ColorHue);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::eulerAngleZ(glm::radians(-90.f)));
|
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::eulerAngleZ(glm::radians(-90.f)));
|
||||||
ShaderManager::u_int(kShaderUniform::Direction, 0); // set horizontal
|
ShaderManager::u_int(kShaderUniform::Direction, 0); // set horizontal
|
||||||
@@ -74,9 +99,8 @@ void NodeColorWheel::draw()
|
|||||||
// ShaderManager::use(kShader::ColorTri);
|
// ShaderManager::use(kShader::ColorTri);
|
||||||
// ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp);
|
// ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp);
|
||||||
// ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(m_hsv, 0.f));
|
// ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(m_hsv, 0.f));
|
||||||
// GLenum type = GL_TRIANGLES;
|
|
||||||
// glBindVertexArray(arrays);
|
// glBindVertexArray(arrays);
|
||||||
// glDrawArrays(type, 0, 3);
|
// glDrawArrays(pp::renderer::gl::primitive_mode_for_fill_count(3U), 0, 3);
|
||||||
// glBindVertexArray(0);
|
// glBindVertexArray(0);
|
||||||
|
|
||||||
ShaderManager::use(kShader::Color);
|
ShaderManager::use(kShader::Color);
|
||||||
@@ -144,8 +168,8 @@ kEventResult NodeColorWheel::handle_event(Event* e)
|
|||||||
else if (l >= 0.4f && l <= 0.5f)
|
else if (l >= 0.4f && l <= 0.5f)
|
||||||
{
|
{
|
||||||
mode = 1;
|
mode = 1;
|
||||||
auto pos = glm::normalize(me->m_pos - m_pos - GetSize() * 0.5f);
|
auto normalized_pos = glm::normalize(me->m_pos - m_pos - GetSize() * 0.5f);
|
||||||
m_hsv.x = (glm::atan(pos.y, -pos.x) + glm::pi<float>()) / glm::two_pi<float>();
|
m_hsv.x = (glm::atan(normalized_pos.y, -normalized_pos.x) + glm::pi<float>()) / glm::two_pi<float>();
|
||||||
handle_color_change();
|
handle_color_change();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user