diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 069efb1..d25ee7d 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -179,6 +179,9 @@ Known local toolchain state: and blend-state tokens. Simple UI text, text-input, border, scroll, and animation timeline draw paths also consume backend-owned blend-state tokens. + Canvas layer cube/equirect generation, clear, restore, and snapshot paths + also consume backend-owned cube/2D texture targets, active texture units, + blend/clear state, and RGBA8 read/write pixel mapping. - `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 4dee7e7..5110830 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -446,6 +446,9 @@ array-buffer, static-upload, vertex-attribute, primitive-mode, and blend-state tokens to `pp_renderer_gl`. Simple UI text, text-input, border, scroll, and animation timeline draw paths now also delegate blend-state tokens to `pp_renderer_gl`. +Canvas layer cube/equirect generation, clear, restore, and snapshot paths now +also delegate cube/2D texture targets, active texture units, blend/clear state, +and RGBA8 read/write pixel mapping to `pp_renderer_gl`. The existing renderer classes are not yet fully behind the renderer interfaces. diff --git a/src/canvas_layer.cpp b/src/canvas_layer.cpp index 697a168..51d9543 100644 --- a/src/canvas_layer.cpp +++ b/src/canvas_layer.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "canvas_layer.h" #include "app.h" +#include "renderer_gl/opengl_capabilities.h" #include "rtt.h" uint32_t Layer::s_count = 0; @@ -44,7 +45,7 @@ TextureCube Layer::gen_cube() { ret.bind(); rtt(i).bindFramebuffer(); - glCopyTexSubImage2D(TextureCube::m_faces_map[i], 0, 0, 0, 0, 0, w, w); + glCopyTexSubImage2D(pp::renderer::gl::cube_face_texture_target(i), 0, 0, 0, 0, 0, w, w); rtt(i).unbindFramebuffer(); }); } @@ -70,7 +71,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/) latlong.create(size.x * 4, size.y * 2); ret.create(size.x * 4, size.y * 2); - glDisable(GL_BLEND); + glDisable(pp::renderer::gl::blend_state()); latlong.bindFramebuffer(); @@ -78,8 +79,8 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/) glViewport(0, 0, latlong.getWidth(), latlong.getHeight()); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_CUBE_MAP, cube.m_cubetex_id); + glActiveTexture(pp::renderer::gl::active_texture_unit(0U)); + glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id); ShaderManager::use(kShader::Equirect); ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); @@ -88,7 +89,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/) Canvas::I->m_plane.draw_fill(); ret.bind(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, latlong.getWidth(), latlong.getHeight()); + glCopyTexSubImage2D(pp::renderer::gl::texture_2d_target(), 0, 0, 0, 0, 0, latlong.getWidth(), latlong.getHeight()); latlong.unbindFramebuffer(); @@ -115,13 +116,13 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/) App::I->render_task([&] { - glDisable(GL_BLEND); + glDisable(pp::renderer::gl::blend_state()); latlong.bindFramebuffer(); glViewport(0, 0, latlong.getWidth(), latlong.getHeight()); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_CUBE_MAP, cube.m_cubetex_id); + glActiveTexture(pp::renderer::gl::active_texture_unit(0U)); + glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id); ShaderManager::use(kShader::Equirect); ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); @@ -458,7 +459,7 @@ void LayerFrame::clear(const glm::vec4& c) { // push clear color state GLfloat cc[4]; - glGetFloatv(GL_COLOR_CLEAR_VALUE, cc); + glGetFloatv(pp::renderer::gl::color_clear_value_query(), cc); glClearColor(c.r, c.g, c.b, c.a); bool erase = (c.a == 0.f); @@ -466,7 +467,7 @@ void LayerFrame::clear(const glm::vec4& c) for (int i = 0; i < 6; i++) { m_rtt[i].bindFramebuffer(); - glClear(GL_COLOR_BUFFER_BIT); + glClear(pp::renderer::gl::framebuffer_color_buffer_mask()); m_rtt[i].unbindFramebuffer(); if (erase) @@ -530,9 +531,11 @@ void LayerFrame::restore(const Snapshot& snap) m_rtt[i].bindTexture(); glm::vec2 box_sz = zw(m_dirty_box[i]) - xy(m_dirty_box[i]); - glTexSubImage2D(GL_TEXTURE_2D, 0, - m_dirty_box[i].x, m_dirty_box[i].y, - box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, + glTexSubImage2D(pp::renderer::gl::texture_2d_target(), 0, + static_cast(m_dirty_box[i].x), static_cast(m_dirty_box[i].y), + static_cast(box_sz.x), static_cast(box_sz.y), + pp::renderer::gl::rgba_pixel_format(), + pp::renderer::gl::unsigned_byte_component_type(), snap.image[i].get()); m_rtt[i].unbindTexture(); LOG("restore face %d - %d bytes (%dx%d)", i, @@ -560,8 +563,11 @@ LayerFrame::Snapshot LayerFrame::snapshot(std::array* dirty_box /* m_rtt[i].bindFramebuffer(); glm::vec2 box_sz = zw(snap.m_dirty_box[i]) - xy(snap.m_dirty_box[i]); - glReadPixels(snap.m_dirty_box[i].x, snap.m_dirty_box[i].y, - box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, snap.image[i].get()); + glReadPixels(static_cast(snap.m_dirty_box[i].x), static_cast(snap.m_dirty_box[i].y), + static_cast(box_sz.x), static_cast(box_sz.y), + pp::renderer::gl::rgba_pixel_format(), + pp::renderer::gl::unsigned_byte_component_type(), + snap.image[i].get()); m_rtt[i].unbindFramebuffer(); } });