mirror of https://github.com/adamdruppe/arsd.git
Merge pull request #244 from drug007/patch-1
Enable using existing OpenGL textures
This commit is contained in:
commit
8942f5a024
17
nanovega.d
17
nanovega.d
|
@ -14663,7 +14663,7 @@ error:
|
|||
return null;
|
||||
}
|
||||
|
||||
/// Create NanoVega OpenGL image from texture id.
|
||||
/// Using OpenGL texture id creates GLNVGtexture and return its id.
|
||||
/// Group: images
|
||||
public int glCreateImageFromHandleGL2 (NVGContext ctx, GLuint textureId, int w, int h, int imageFlags) nothrow @trusted @nogc {
|
||||
GLNVGcontext* gl = cast(GLNVGcontext*)ctx.internalParams().userPtr;
|
||||
|
@ -14680,6 +14680,21 @@ public int glCreateImageFromHandleGL2 (NVGContext ctx, GLuint textureId, int w,
|
|||
return tex.id;
|
||||
}
|
||||
|
||||
/// Create NVGImage from OpenGL texture id.
|
||||
/// Group: images
|
||||
public NVGImage glCreateImageFromOpenGLTexture(NVGContext ctx, GLuint textureId, int w, int h, int imageFlags) nothrow @trusted @nogc {
|
||||
auto id = glCreateImageFromHandleGL2(ctx, textureId, w, h, imageFlags);
|
||||
|
||||
NVGImage res;
|
||||
if (id > 0) {
|
||||
res.id = id;
|
||||
version(nanovega_debug_image_manager_rc) { import core.stdc.stdio; printf("createImageRGBA: img=%p; imgid=%d\n", &res, res.id); }
|
||||
res.ctx = ctx;
|
||||
ctx.nvg__imageIncRef(res.id, false); // don't increment driver refcount
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Returns OpenGL texture id for NanoVega image.
|
||||
/// Group: images
|
||||
public GLuint glImageHandleGL2 (NVGContext ctx, int image) nothrow @trusted @nogc {
|
||||
|
|
Loading…
Reference in New Issue