From 2a4698e9f6fdae96d4db9fe2d518bb93b428379c Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 4 Jun 2026 23:20:06 +0200 Subject: [PATCH] Route retained readbacks through GL backend --- docs/modernization/build-inventory.md | 20 +++++--- docs/modernization/debt.md | 2 +- docs/modernization/roadmap.md | 14 ++++-- src/canvas_modes.cpp | 72 ++++++++++++++++++++++++--- src/node_panel_grid.cpp | 14 +----- 5 files changed, 88 insertions(+), 34 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index dc8342b..04c03b7 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -376,11 +376,13 @@ Known local toolchain state: `NodePanelGrid` heightmap preview and lightmap baking also consume backend-owned texture readback formats, sampler filters, depth/blend state, depth clears, viewport queries, color-mask booleans, active texture units, - and float render-target formats; CPU lightmap row dispatch now uses shared - `parallel_for` instead of platform-specific worker APIs. Its live heightmap - draw and bake paths now execute depth/blend state changes, depth clears, - color-write-mask toggles, active texture selection, and bake viewport changes - through tested `pp_renderer_gl` dispatch adapters. + and float render-target formats; its desktop texture-resize readback now + reuses `Texture2D::get_image()` and the tested framebuffer-backed texture + readback dispatch instead of direct `glGetTexImage`; CPU lightmap row dispatch + now uses shared `parallel_for` instead of platform-specific worker APIs. Its + live heightmap draw and bake paths now execute depth/blend state changes, + depth clears, color-write-mask toggles, active texture selection, and bake + viewport changes through tested `pp_renderer_gl` dispatch adapters. Legacy `util.cpp` OpenGL error naming and `gl_state` save/restore also consume backend-owned error codes, state queries, framebuffer targets, texture binding targets, and active texture units. @@ -434,8 +436,9 @@ Known local toolchain state: Canvas mode overlay, mask, and transform paths also consume backend-owned blend/depth state execution, active texture unit dispatch, transform/cut viewport execution, 2D texture copy targets, and RGBA8 readback format tokens; - the retained canvas-tip pick readback remains direct legacy OpenGL until the - readback boundary is finished under DEBT-0036. + canvas-tip pick readback now routes through tested framebuffer readback + dispatch using the active read framebuffer, with only a local OpenGL adapter + endpoint retained in `src/canvas_modes.cpp`. `NodeCanvas` panorama UI rendering also consumes backend-owned sampler defaults, tested viewport/clear-color query dispatch, blend/depth/scissor state, color-buffer clear dispatch, clear-color restore, active texture @@ -664,7 +667,8 @@ Known local toolchain state: consumed by retained `Canvas`, `CanvasLayer`, `NodeCanvas`, and `NodeStrokePreview` draw-state paths, tested color-write-mask dispatch consumed by retained `NodePanelGrid` - transparent heightmap rendering, + transparent heightmap rendering, tested texture readback dispatch consumed by + `NodePanelGrid` texture-resize preservation, tested pixel-buffer allocation/readback/map/unmap/delete dispatch consumed by retained `PBO` recording readbacks, tested framebuffer-to-texture copy dispatch consumed by retained canvas/UI paint paths and CanvasLayer diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 1ee72f7..639a348 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -53,7 +53,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0033 | Open | Modernization | Tools menu planning and direct command execution dispatch now consume pure `pp_app_core` through `App::init_menu_tools`, `pano_cli plan-tools-menu`, `pano_cli plan-tools-panel`, and the `ToolsMenuServices` boundary, and direct command execution is centralized in `src/legacy_app_shell_services.*`; SonarPen availability/startup now routes through `PlatformServices`, but live adapters still construct legacy `NodePanelFloating` panels, mutate legacy panel nodes, clear `CanvasModeGrid`, reset `NodeCanvas` camera state, open legacy shortcuts UI, and rely on the legacy platform adapter for the retained iOS SonarPen bridge | Preserve current Tools menu behavior while UI shell actions move toward app/UI/platform services | `pp_app_core_tools_menu_tests`; `pp_platform_api_tests`; `pano_cli plan-tools-menu --command shortcuts`; `pano_cli plan-tools-panel --panel layers`; `pano_cli plan-tools-panel --panel animation --already-visible`; `ctest --preset desktop-fast --build-config Debug` | Tools panel creation, submenu routing, grid clear, camera reset, shortcuts dialog, and SonarPen dispatch are owned by injected app/UI/platform services with `App::init_menu_tools` acting only as a UI adapter and no legacy Tools adapter | | DEBT-0034 | Open | Modernization | About menu command planning and execution dispatch now consume pure `pp_app_core` through `App::init_menu_about`, `pano_cli plan-about-menu`, and the `AboutMenuServices` boundary, and live execution is centralized in `src/legacy_app_shell_services.*`, but the bridge still opens legacy About/manual/what's-new dialogs, invokes the injected crash hook, and runs the legacy Canvas stroke performance test directly | Preserve About menu behavior while dialogs and diagnostics move toward app/UI/platform services | `pp_app_core_about_menu_tests`; `pano_cli plan-about-menu --command news --version-major 2 --version-minor 5 --version-fix 7`; `pano_cli plan-about-menu --command performance --no-canvas`; `ctest --preset desktop-fast --build-config Debug` | About/manual/what's-new dialog dispatch, crash-test dispatch, and performance-test execution are owned by injected app/UI/platform services with `App::init_menu_about` acting only as a UI adapter and no legacy About adapter | | DEBT-0035 | Open | Modernization | Main toolbar/status command planning and execution dispatch now consume pure `pp_app_core` through `App::init_toolbar_main`, `pano_cli plan-main-toolbar`, and the `MainToolbarServices` boundary, history/canvas commands now hand off through `HistoryUiServices` and `DocumentCanvasClearServices`, and live execution is centralized in `src/legacy_app_shell_services.*`, but the bridge still opens legacy open/save/settings/message-box dialogs and delegates to legacy history/canvas adapters | Preserve reachable toolbar/status behavior while app shell commands move toward app/document/UI services | `pp_app_core_main_toolbar_tests`; `pano_cli plan-main-toolbar --command undo --undo-count 2`; `pano_cli plan-main-toolbar --command clear-canvas --no-canvas`; `ctest --preset desktop-fast --build-config Debug` | Open/save/settings/message-box routing, undo/redo/clear-history execution, and canvas-clear execution are owned by injected app/document/UI services with `App::init_toolbar_main` acting only as a UI adapter and no legacy toolbar adapter | -| DEBT-0036 | Open | Modernization | `pp_renderer_api`, `pp_paint_renderer`, `pano_cli plan-paint-feedback`, and `pano_cli plan-stroke-composite` can choose backend-neutral complex paint feedback strategies for fixed-function blending, framebuffer-fetch-capable renderers, or ping-pong render targets. OpenGL extension detection now stores `pp::renderer::RenderDeviceFeatures` through `ShaderManager`, using `pp_renderer_gl::query_opengl_capability_detection`, `detect_opengl_feature_state`, and `render_device_features` as the backend conversion point; that feature snapshot now includes float32-linear filtering, so canvas stroke texture format selection, renderer diagnostics, grid lightmap render planning, and grid bake target selection no longer read `ShaderManager::ext_*` flags directly. `pp_paint_renderer::plan_canvas_blend_gate` owns the compatibility mapping from persisted layer/brush blend indices to the extracted stroke-composite planner, and live `Canvas::draw_merge` plus `NodeCanvas` panorama rendering both call it with the stored renderer-neutral feature set for their existing shader-blend gates and destination-copy versus framebuffer-fetch decisions. `pp_paint_renderer::plan_canvas_stroke_feedback` also owns the current destination-feedback decision, and live `Canvas::stroke_draw`, thumbnail layer blending, and `NodeStrokePreview` brush-preview rendering use it for framebuffer-fetch versus destination-copy decisions. The retained `copy_framebuffer_to_texture_2d` utility bridge now routes 2D framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch, retained `RTT::create`/`RTT::destroy` render-target texture parameter setup, optional depth renderbuffer allocation, framebuffer allocation/attachment/status checks, binding restore, and resource deletion now route through tested `pp_renderer_gl` dispatch, retained RTT clear, masked clear with color-write-mask restore, and texture bind/unbind now route through tested `pp_renderer_gl` dispatch, retained Canvas, NodeCanvas, and NodeStrokePreview texture-unit switches now route through tested active-texture dispatch, retained Canvas, NodeCanvas, NodeStrokePreview, and desktop HMD viewport/scissor/capability execution now route through tested `pp_renderer_gl` dispatch adapters, CanvasLayer cube/equirect generation plus frame clears now route blend state, active texture units, viewport execution, color clears, and cube-face framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch adapters, `NodePanelGrid` live heightmap draw and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, and bake viewport execution through tested `pp_renderer_gl` dispatch adapters, retained CanvasMode overlay/mask/transform paths now route active texture, depth/blend state, and transform/cut viewport execution through tested `pp_renderer_gl` dispatch adapters while the retained canvas-tip pick readback remains direct legacy OpenGL, retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clears, and clear-color restore, retained `NodeCanvas` plus `NodeStrokePreview` draw-state paths now route viewport query, clear-color query, color-buffer clear, and clear-color restore through tested `pp_renderer_gl` dispatch helpers, and retained `Canvas` plus `CanvasLayer` stroke/object/thumbnail/frame-clear draw-state paths now route saved viewport or clear-color query and restore through the same tested helpers, but actual live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, and the retained `ShaderManager::ext_*` compatibility fields still use legacy OpenGL canvas/UI execution | Preserve current painting behavior while the renderer boundary matures for OpenGL parity and later Vulkan/Metal experiments | `pp_renderer_api_tests`; `pp_renderer_gl_capabilities_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli plan-paint-feedback --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-paint-feedback --texture-copy`; `pano_cli plan-stroke-composite --stroke-blend 10 --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-stroke-composite --layer-blend 4 --dual-blend --texture-copy`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Live stroke/layer compositing chooses its feedback path through `pp_paint_renderer` and renderer services, with OpenGL golden parity and Vulkan/Metal lab tests covering framebuffer-fetch and ping-pong behavior | +| DEBT-0036 | Open | Modernization | `pp_renderer_api`, `pp_paint_renderer`, `pano_cli plan-paint-feedback`, and `pano_cli plan-stroke-composite` can choose backend-neutral complex paint feedback strategies for fixed-function blending, framebuffer-fetch-capable renderers, or ping-pong render targets. OpenGL extension detection now stores `pp::renderer::RenderDeviceFeatures` through `ShaderManager`, using `pp_renderer_gl::query_opengl_capability_detection`, `detect_opengl_feature_state`, and `render_device_features` as the backend conversion point; that feature snapshot now includes float32-linear filtering, so canvas stroke texture format selection, renderer diagnostics, grid lightmap render planning, and grid bake target selection no longer read `ShaderManager::ext_*` flags directly. `pp_paint_renderer::plan_canvas_blend_gate` owns the compatibility mapping from persisted layer/brush blend indices to the extracted stroke-composite planner, and live `Canvas::draw_merge` plus `NodeCanvas` panorama rendering both call it with the stored renderer-neutral feature set for their existing shader-blend gates and destination-copy versus framebuffer-fetch decisions. `pp_paint_renderer::plan_canvas_stroke_feedback` also owns the current destination-feedback decision, and live `Canvas::stroke_draw`, thumbnail layer blending, and `NodeStrokePreview` brush-preview rendering use it for framebuffer-fetch versus destination-copy decisions. The retained `copy_framebuffer_to_texture_2d` utility bridge now routes 2D framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch, retained `RTT::create`/`RTT::destroy` render-target texture parameter setup, optional depth renderbuffer allocation, framebuffer allocation/attachment/status checks, binding restore, and resource deletion now route through tested `pp_renderer_gl` dispatch, retained RTT clear, masked clear with color-write-mask restore, and texture bind/unbind now route through tested `pp_renderer_gl` dispatch, retained Canvas, NodeCanvas, and NodeStrokePreview texture-unit switches now route through tested active-texture dispatch, retained Canvas, NodeCanvas, NodeStrokePreview, and desktop HMD viewport/scissor/capability execution now route through tested `pp_renderer_gl` dispatch adapters, CanvasLayer cube/equirect generation plus frame clears now route blend state, active texture units, viewport execution, color clears, and cube-face framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch adapters, `NodePanelGrid` live heightmap draw and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, bake viewport execution, and desktop texture-resize readback through tested `pp_renderer_gl` dispatch adapters, retained CanvasMode overlay/mask/transform paths now route active texture, depth/blend state, transform/cut viewport execution, and canvas-tip pick framebuffer readback through tested `pp_renderer_gl` dispatch adapters, retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clears, and clear-color restore, retained `NodeCanvas` plus `NodeStrokePreview` draw-state paths now route viewport query, clear-color query, color-buffer clear, and clear-color restore through tested `pp_renderer_gl` dispatch helpers, and retained `Canvas` plus `CanvasLayer` stroke/object/thumbnail/frame-clear draw-state paths now route saved viewport or clear-color query and restore through the same tested helpers, but actual live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, and the retained `ShaderManager::ext_*` compatibility fields still use legacy OpenGL canvas/UI execution | Preserve current painting behavior while the renderer boundary matures for OpenGL parity and later Vulkan/Metal experiments | `pp_renderer_api_tests`; `pp_renderer_gl_capabilities_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli plan-paint-feedback --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-paint-feedback --texture-copy`; `pano_cli plan-stroke-composite --stroke-blend 10 --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-stroke-composite --layer-blend 4 --dual-blend --texture-copy`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Live stroke/layer compositing chooses its feedback path through `pp_paint_renderer` and renderer services, with OpenGL golden parity and Vulkan/Metal lab tests covering framebuffer-fetch and ping-pong behavior | | DEBT-0037 | Open | Modernization | Recording lifecycle/export planning and execution dispatch now consume pure `pp_app_core` through `App::rec_start`, `App::rec_stop`, `App::rec_clear`, `App::rec_export`, `pano_cli plan-recording-session`, and the `RecordingServices` boundary; live execution is centralized in `src/legacy_recording_services.*`, and retained `PBO` allocation/readback/map/unmap/delete operations now route through tested `pp_renderer_gl` dispatch, but the bridge still owns legacy recording thread startup/shutdown, platform recorded-file cleanup, progress UI, retained `App::rec_loop` readback call sites, and `MP4Encoder::write_mp4` execution | Preserve current timelapse/MP4 behavior while recording moves toward app/document/renderer/video services | `pp_app_core_document_recording_tests`; `pp_renderer_gl_capabilities_tests`; `pano_cli plan-recording-session --running --frame-count 12`; `pano_cli plan-recording-session --platform-clears-files`; `ctest --preset desktop-fast --build-config Debug` | Recording thread lifecycle, frame readback scheduling, platform cleanup, progress reporting, and MP4 writing are owned by injected app/renderer/video services with `App` methods acting only as adapters | | DEBT-0038 | Open | Modernization | Cloud upload/browse/bulk planning and execution dispatch now consume pure `pp_app_core` through `App::cloud_upload`, `App::cloud_upload_all`, `App::cloud_browse`, `pano_cli plan-cloud-upload`, `pano_cli plan-cloud-upload-all`, `pano_cli plan-cloud-browse`, and the `CloudServices` boundary; live execution is centralized in `src/legacy_cloud_services.*`, the app-owned `upload`/`download`/license curl helpers now ask `PlatformServices` for the Android TLS-verification bypass policy, and retained `Asset::open_url`, `LogRemote::net_init`, and `NodeDialogCloud::load_thumbs_thread` curl sites consume the `pp_platform_api` default TLS policy helper instead of spelling Android branches locally, but the bridge still uses legacy save-before-upload, app-owned curl helpers instead of an injected network service, progress/message UI, OpenGL context guarding, `NodeDialogCloud`, `Canvas` project open, layer refresh, and `ActionManager` reset | Preserve current cloud behavior while cloud/network/document import flows move toward app/document/platform services | `pp_app_core_document_cloud_tests`; `pp_platform_api_tests`; `pano_cli plan-cloud-upload --new-document --unsaved`; `pano_cli plan-cloud-browse --selected-file demo.ppi`; `pano_cli plan-cloud-upload-all --file-count 3`; `ctest --preset desktop-fast --build-config Debug` | Cloud upload/download, TLS policy, save-before-upload, progress reporting, cloud browse dialog, downloaded project opening, layer refresh, OpenGL context ownership, and action-history reset are owned by injected app/document/network/platform/renderer services with `App` methods acting only as adapters | | DEBT-0039 | Open | Modernization | Document-open planning and execution dispatch now consume pure `pp_app_core` through `App::open_document`, `pano_cli plan-open-route`, `DocumentOpenServices`, and `src/legacy_document_open_services.*`, but the bridge still opens ABR/PPBR import prompts before delegating import execution to `src/legacy_brush_package_import_services.*`, applies unsaved-project discard prompts, calls legacy project-open execution, refreshes layer UI, updates the app title, and clears legacy history directly | Preserve current file-open/import behavior while document loading and brush import move toward app/document/asset/UI services | `pp_app_core_document_route_tests`; `pp_app_core_document_session_tests`; `pano_cli plan-open-route --path D:/Paint/Scenes/demo.ppi --unsaved`; `pano_cli plan-open-route --path D:/Paint/Brushes/clouds.ABR --unsaved`; `ctest --preset desktop-fast --build-config Debug` | Brush import prompting, project-open execution, unsaved-project discard prompting, layer refresh, title updates, and history clearing are owned by injected app/document/asset/UI services with `App::open_document` acting only as an adapter | diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 540731c..f034d2f 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -1105,7 +1105,10 @@ formats to `pp_renderer_gl`, and its CPU lightmap row dispatch now uses the shared legacy `parallel_for` helper rather than platform-specific worker APIs. Its live heightmap draw and bake paths now execute depth/blend state changes, depth clears, color-write-mask toggles, active texture selection, and bake -viewport changes through tested `pp_renderer_gl` dispatch adapters. +viewport changes through tested `pp_renderer_gl` dispatch adapters. Its desktop +texture-resize path now reuses `Texture2D::get_image()`, so grid texture +readback also goes through the tested framebuffer-backed texture readback +dispatch instead of direct `glGetTexImage`. Legacy `util.cpp` OpenGL error naming and `gl_state` save/restore now delegate error codes, state queries, framebuffer targets, texture binding targets, and active texture units to `pp_renderer_gl`. @@ -2029,8 +2032,9 @@ Results: blend/depth state execution, active texture unit switches, transform/cut viewport execution, 2D framebuffer-to-texture copy dispatch, RGBA8 readback formats, and RTT-backed transform history region readbacks through the - renderer GL backend mapping. The retained canvas-tip pick readback remains - direct legacy OpenGL until the readback boundary is finished under DEBT-0036. + renderer GL backend mapping. Canvas-tip pick readback now routes through the + tested framebuffer readback dispatch using the active read framebuffer, with + only a local OpenGL adapter endpoint retained in `src/canvas_modes.cpp`. - `NodeCanvas` panorama UI rendering now routes sampler defaults, saved viewport/clear/blend/depth/scissor state, tested viewport and clear-color query dispatch, color clears, clear-color restore, active texture units, @@ -2066,7 +2070,9 @@ Results: - `NodePanelGrid` live heightmap drawing and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, and bake viewport execution through tested renderer GL backend dispatch - contracts. + contracts. Its desktop texture-resize readback now uses the retained + `Texture2D::get_image()` helper, so it consumes the same tested + framebuffer-backed texture readback dispatch instead of `glGetTexImage`. - Retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clear, and clear-color restore. This covers diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp index a58c0ff..69573c5 100644 --- a/src/canvas_modes.cpp +++ b/src/canvas_modes.cpp @@ -36,6 +36,36 @@ void set_opengl_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std glViewport(static_cast(x), static_cast(y), static_cast(width), static_cast(height)); } +void get_opengl_integer(std::uint32_t name, std::int32_t* values) noexcept +{ + static_assert(sizeof(GLint) == sizeof(std::int32_t)); + glGetIntegerv(static_cast(name), reinterpret_cast(values)); +} + +void read_opengl_pixels( + std::int32_t x, + std::int32_t y, + std::int32_t width, + std::int32_t height, + std::uint32_t pixel_format, + std::uint32_t component_type, + void* pixels) noexcept +{ + glReadPixels( + static_cast(x), + static_cast(y), + static_cast(width), + static_cast(height), + static_cast(pixel_format), + static_cast(component_type), + pixels); +} + +void bind_opengl_framebuffer(std::uint32_t target, std::uint32_t framebuffer) noexcept +{ + glBindFramebuffer(static_cast(target), static_cast(framebuffer)); +} + void set_canvas_mode_active_texture_unit(std::uint32_t unit_index) { const auto status = pp::renderer::gl::activate_opengl_texture_unit( @@ -76,6 +106,34 @@ void apply_canvas_mode_viewport(std::int32_t x, std::int32_t y, std::int32_t wid LOG("Canvas mode viewport dispatch failed because: %s", status.message); } +std::uint32_t query_canvas_mode_read_framebuffer() +{ + std::int32_t read_framebuffer = 0; + get_opengl_integer(pp::renderer::gl::read_framebuffer_binding_query(), &read_framebuffer); + return static_cast(read_framebuffer); +} + +void read_canvas_mode_pixel(std::int32_t x, std::int32_t y, glm::u8vec4& pixel) +{ + const auto status = pp::renderer::gl::readback_opengl_framebuffer( + pp::renderer::gl::OpenGlFramebufferReadback { + .framebuffer = query_canvas_mode_read_framebuffer(), + .x = x, + .y = y, + .width = 1, + .height = 1, + .format = pp::renderer::gl::rgba8_readback_format(), + .pixels = &pixel, + }, + pp::renderer::gl::OpenGlFramebufferReadbackDispatch { + .get_integer = get_opengl_integer, + .bind_framebuffer = bind_opengl_framebuffer, + .read_pixels = read_opengl_pixels, + }); + if (!status.ok()) + LOG("Canvas mode pixel readback dispatch failed because: %s", status.message); +} + } void CanvasModeBasicCamera::on_MouseEvent(MouseEvent* me, glm::vec2& loc) @@ -343,19 +401,17 @@ void CanvasModePen::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const } } glm::u8vec4 pixel; - GLint fb_width = App::I->width; - GLint fb_height = App::I->height; + std::int32_t fb_width = static_cast(App::I->width); + std::int32_t fb_height = static_cast(App::I->height); if (node->m_density != 1.f) { fb_width = node->m_rtt.getWidth(); fb_height = node->m_rtt.getHeight(); } - glReadPixels((pos.x / App::I->width) * fb_width, - ((App::I->height - pos.y - 1) / App::I->height) * fb_height, - 1, 1, - pp::renderer::gl::rgba_pixel_format(), - pp::renderer::gl::unsigned_byte_component_type(), - &pixel); + read_canvas_mode_pixel( + static_cast((pos.x / App::I->width) * fb_width), + static_cast(((App::I->height - pos.y - 1) / App::I->height) * fb_height), + pixel); bool outline = glm::min(tip_scale.x, tip_scale.y) < 20 || m_resizing ? false : m_draw_outline; ShaderManager::u_int(kShaderUniform::DrawOutline, outline); ShaderManager::u_vec4(kShaderUniform::Col, outline ? glm::vec4(1.f - glm::vec3(pixel) / 255.f, 1.f) : tip_color); diff --git a/src/node_panel_grid.cpp b/src/node_panel_grid.cpp index 6d30517..4c10c33 100644 --- a/src/node_panel_grid.cpp +++ b/src/node_panel_grid.cpp @@ -231,19 +231,7 @@ void NodePanelGrid::init_controls() m_texture.create_mipmaps(); #else // get the texture data and resize it - Image img; - img.create(m_texture.size().x, m_texture.size().y); - App::I->render_task([&] - { - m_texture.bind(); - glGetTexImage( - pp::renderer::gl::texture_2d_target(), - 0, - pp::renderer::gl::rgba_pixel_format(), - pp::renderer::gl::unsigned_byte_component_type(), - img.m_data.get()); - m_texture.unbind(); - }); + Image img = m_texture.get_image(); Image resized = img.resize(texres, texres); m_texture.create(resized); m_texture.create_mipmaps();