From 078666d3731c6a95cf938a4c5c0d233f418ff912 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Fri, 25 Jun 2021 22:29:51 +0200 Subject: [PATCH] Allow to create a nvg texture from a BGFX texture. (#2548) --- examples/common/nanovg/nanovg_bgfx.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index 0853bed8a..c93869584 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -1324,3 +1324,19 @@ void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer* _framebuffe bgfx::setViewFrameBuffer(_viewId, _framebuffer->handle); bgfx::setViewMode(_viewId, bgfx::ViewMode::Sequential); } + +int nvgCreateBgfxTexture(struct NVGcontext *_ctx, + bgfx::TextureHandle _id, + int _width, + int _height, + int _flags) { + struct NVGparams *params = nvgInternalParams(_ctx); + struct GLNVGcontext *gl = (struct GLNVGcontext *)params->userPtr; + struct GLNVGtexture *tex = glnvg__allocTexture(gl); + tex->id = _id; + tex->width = _width; + tex->height = _height; + tex->flags = _flags; + tex->type = NVG_TEXTURE_RGBA; + return tex->id.idx; +}