Browse Source

Add NanoVG::createImageFromTextureHandle

pull/6/head
falkTX 10 years ago
parent
commit
7bd8b4c563
2 changed files with 22 additions and 2 deletions
  1. +8
    -2
      dgl/NanoVG.hpp
  2. +14
    -0
      dgl/src/NanoVG.cpp

+ 8
- 2
dgl/NanoVG.hpp View File

@@ -196,8 +196,7 @@ public:
IMAGE_REPEAT_X = 1 << 1, // Repeat image in X direction. IMAGE_REPEAT_X = 1 << 1, // Repeat image in X direction.
IMAGE_REPEAT_Y = 1 << 2, // Repeat image in Y direction. IMAGE_REPEAT_Y = 1 << 2, // Repeat image in Y direction.
IMAGE_FLIP_Y = 1 << 3, // Flips (inverses) image in Y direction when rendered. IMAGE_FLIP_Y = 1 << 3, // Flips (inverses) image in Y direction when rendered.
IMAGE_PREMULTIPLIED = 1 << 4, // Image data has premultiplied alpha.
IMAGE_NODELETE = 1 << 16,// Do not delete GL texture handle.
IMAGE_PREMULTIPLIED = 1 << 4 // Image data has premultiplied alpha.
}; };


enum Align { enum Align {
@@ -538,6 +537,13 @@ public:


// TODO overloaded? // TODO overloaded?


/**
Creates image from an OpenGL texture handle.
*/
NanoImage* createImageFromTextureHandle(GLuint textureId, uint w, uint h, int imageFlags, bool deleteTexture = false);

// TODO overloaded?

/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
* Paints */ * Paints */




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

@@ -522,6 +522,20 @@ NanoImage* NanoVG::createImageRGBA(uint w, uint h, const uchar* data, int imageF
return nullptr; return nullptr;
} }


NanoImage* NanoVG::createImageFromTextureHandle(GLuint textureId, uint w, uint h, int imageFlags, bool deleteTexture)
{
if (fContext == nullptr) return nullptr;
DISTRHO_SAFE_ASSERT_RETURN(textureId != 0, nullptr);

if (! deleteTexture)
imageFlags |= NVG_IMAGE_NODELETE;

if (const int imageId = nvglCreateImageFromHandle(fContext, textureId, static_cast<int>(w), static_cast<int>(h), imageFlags))
return new NanoImage(fContext, imageId);

return nullptr;
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Paints // Paints




Loading…
Cancel
Save