diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index a9fc6a9..d5c731f 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -174,6 +174,9 @@ Known local toolchain state: `NodeImage` drawing and remote-image texture creation also consume backend-owned mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA 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 for the current headless component matrix; see DEBT-0007 for remaining app and platform triplet migration. diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index d9b09e4..bae568f 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -441,6 +441,9 @@ target and blend-state tokens to `pp_renderer_gl`. `NodeImage` drawing and remote-image texture creation now delegate mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA texture format mapping to `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 behind the renderer interfaces. diff --git a/src/node_colorwheel.cpp b/src/node_colorwheel.cpp index dbc7f28..def3bc1 100644 --- a/src/node_colorwheel.cpp +++ b/src/node_colorwheel.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "node_colorwheel.h" +#include "renderer_gl/opengl_capabilities.h" #include "shader.h" #include "log.h" #include "app.h" @@ -29,43 +30,67 @@ void NodeColorWheel::init_controls() void NodeColorWheel::loaded() { - m_circle.create<64>(.5, .4, Circle::kUVMapping::Tube); - m_cur_hue.create<16>(.05, 0.04); - m_cur_quad.create<16>(.04, 0.03, Circle::kUVMapping::Tube); + m_circle.create<64>(.5f, .4f, Circle::kUVMapping::Tube); + m_cur_hue.create<16>(.05f, 0.04f); + m_cur_quad.create<16>(.04f, 0.03f, Circle::kUVMapping::Tube); float quad_scale = glm::sin(glm::radians(45.f)) * 0.8f; m_quad.create<1>(quad_scale, quad_scale); struct vertex_t { glm::vec4 pos; glm::vec2 uvs; glm::vec4 col; }; std::vector vertices; - float l = 0.4; + float l = 0.4f; vertices.push_back({{glm::cos(4.f/3.f*glm::pi())*l,glm::sin(4.f/3.f*glm::pi())*l,0,1},{1,-1},{1,1,1,1}}); vertices.push_back({{glm::cos(2.f/3.f*glm::pi())*l,glm::sin(2.f/3.f*glm::pi())*l,0,1},{0,0},{0,0,0,1}}); vertices.push_back({{l,0,0,1},{1,1},{1,0,0,1}}); 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(pp::renderer::gl::vertex_attribute_not_normalized()); + glGenBuffers(1, &buffers); - glBindBuffer(GL_ARRAY_BUFFER, buffers); - glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(vertex_t), vertices.data(), GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); + 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(GL_ARRAY_BUFFER, buffers); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs)); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, col)); + 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); }); } void NodeColorWheel::draw() { - glDisable(GL_BLEND); + glDisable(pp::renderer::gl::blend_state()); ShaderManager::use(kShader::ColorHue); ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::eulerAngleZ(glm::radians(-90.f))); ShaderManager::u_int(kShaderUniform::Direction, 0); // set horizontal @@ -74,9 +99,8 @@ void NodeColorWheel::draw() // ShaderManager::use(kShader::ColorTri); // ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp); // ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(m_hsv, 0.f)); -// GLenum type = GL_TRIANGLES; // glBindVertexArray(arrays); -// glDrawArrays(type, 0, 3); +// glDrawArrays(pp::renderer::gl::primitive_mode_for_fill_count(3U), 0, 3); // glBindVertexArray(0); ShaderManager::use(kShader::Color); @@ -144,8 +168,8 @@ kEventResult NodeColorWheel::handle_event(Event* e) else if (l >= 0.4f && l <= 0.5f) { mode = 1; - auto pos = glm::normalize(me->m_pos - m_pos - GetSize() * 0.5f); - m_hsv.x = (glm::atan(pos.y, -pos.x) + glm::pi()) / glm::two_pi(); + auto normalized_pos = glm::normalize(me->m_pos - m_pos - GetSize() * 0.5f); + m_hsv.x = (glm::atan(normalized_pos.y, -normalized_pos.x) + glm::pi()) / glm::two_pi(); handle_color_change(); } else