Browse Source

Add update() to NanoImage

pull/493/head
FergusL 1 month ago
parent
commit
812b223441
2 changed files with 9 additions and 0 deletions
  1. +1
    -0
      dgl/NanoVG.hpp
  2. +8
    -0
      dgl/src/NanoVG.cpp

+ 1
- 0
dgl/NanoVG.hpp View File

@@ -107,6 +107,7 @@ public:
*/
Size<uint> getSize() const noexcept;

void update(const unsigned char* data);
/**
Get the OpenGL texture handle.
*/


+ 8
- 0
dgl/src/NanoVG.cpp View File

@@ -272,6 +272,14 @@ Size<uint> 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);


Loading…
Cancel
Save