From 812b2234410aa2ad6ae32a4b7a65e9363eaf3abe Mon Sep 17 00:00:00 2001 From: FergusL Date: Mon, 17 Mar 2025 01:39:14 +0100 Subject: [PATCH] Add update() to NanoImage --- dgl/NanoVG.hpp | 1 + dgl/src/NanoVG.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/dgl/NanoVG.hpp b/dgl/NanoVG.hpp index a1fab235..a8efefd1 100644 --- a/dgl/NanoVG.hpp +++ b/dgl/NanoVG.hpp @@ -107,6 +107,7 @@ public: */ Size getSize() const noexcept; + void update(const unsigned char* data); /** Get the OpenGL texture handle. */ diff --git a/dgl/src/NanoVG.cpp b/dgl/src/NanoVG.cpp index 80e3f349..4eec2a4b 100644 --- a/dgl/src/NanoVG.cpp +++ b/dgl/src/NanoVG.cpp @@ -272,6 +272,14 @@ Size NanoImage::getSize() const noexcept return fSize; } +void NanoImage::update(const unsigned char* data) +{ + int w, h; + void * uptr = nvgInternalParams(fHandle.context)->userPtr; + glnvg__renderGetTextureSize(uptr, getTextureHandle(), &w, &h); + glnvg__renderUpdateTexture(uptr, getTextureHandle(), 0, 0, w, h, data); +} + GLuint NanoImage::getTextureHandle() const { DISTRHO_SAFE_ASSERT_RETURN(fHandle.context != nullptr && fHandle.imageId != 0, 0);