{"action":"closed","issue":{"url":"https://api.github.com/repos/jdryg/vg-renderer/issues/7","repository_url":"https://api.github.com/repos/jdryg/vg-renderer","labels_url":"https://api.github.com/repos/jdryg/vg-renderer/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/jdryg/vg-renderer/issues/7/comments","events_url":"https://api.github.com/repos/jdryg/vg-renderer/issues/7/events","html_url":"https://github.com/jdryg/vg-renderer/issues/7","id":310037250,"number":7,"title":"Draw bgfx texture directly","user":{"login":"hugoam","id":9502098,"avatar_url":"https://avatars2.githubusercontent.com/u/9502098?v=4","gravatar_id":"","url":"https://api.github.com/users/hugoam","html_url":"https://github.com/hugoam","followers_url":"https://api.github.com/users/hugoam/followers","following_url":"https://api.github.com/users/hugoam/following{/other_user}","gists_url":"https://api.github.com/users/hugoam/gists{/gist_id}","starred_url":"https://api.github.com/users/hugoam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hugoam/subscriptions","organizations_url":"https://api.github.com/users/hugoam/orgs","repos_url":"https://api.github.com/users/hugoam/repos","events_url":"https://api.github.com/users/hugoam/events{/privacy}","received_events_url":"https://api.github.com/users/hugoam/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-30T10:49:42Z","updated_at":"2018-03-31T06:06:25Z","closed_at":"2018-03-31T06:06:25Z","author_association":"NONE","body":"I need the ability to send a draw command using a `bgfx::Texture` that I own (not one created by vg).\r\n\r\nThis is, as far as I know, the only way to draw multiple 3D viewports inside of UI widgets. (as in this video, for reference : https://twitter.com/hugoamnov/status/978444939959898112)\r\nIt's pretty nice as this way you send the draw commands of the viewports exactly in the same way you send the rest of the UI graphics.\r\n\r\nI implemented the change locally and it works fine. API changes are minor : it just needs a function to create an Image with a bgfx texture handle.\r\n\r\nNote : I opted for a uint16_t instead of directly a bgfx::TextureHandle : it is less explicit in term of the function signature, but it was the only way to not depend on bgfx in vg's header. In my opinion depending on bgfx in the header would be kind of *okay* since vg works **only** with bgfx anyway, but all this is up to you ;)\r\nAnother option would be to make the name explicit like : createBgfxImage or registerBgfxImage.\r\n\r\n```C++\r\nImageHandle createImage(Context* ctx, uint32_t flags, uint16_t bgfx_texture)\r\n{\r\n\tImageHandle handle = allocImage(ctx);\r\n\tif(!isValid(handle)) {\r\n\t\treturn VG_INVALID_HANDLE;\r\n\t}\r\n\r\n\tImage* tex = &ctx->m_Images[handle.idx];\r\n\r\n\tuint32_t bgfxFlags = BGFX_TEXTURE_NONE;\r\n\r\n#if BX_PLATFORM_EMSCRIPTEN\r\n\tif(!bx::isPowerOf2(w) || !bx::isPowerOf2(h)) {\r\n\t\tflags = ImageFlags::Filter_NearestUV | ImageFlags::Filter_NearestW;\r\n\t\tbgfxFlags |= BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_W_CLAMP;\r\n\t}\r\n#endif\r\n\r\n\tif(flags & ImageFlags::Filter_NearestUV) {\r\n\t\tbgfxFlags |= BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT;\r\n\t}\r\n\tif(flags & ImageFlags::Filter_NearestW) {\r\n\t\tbgfxFlags |= BGFX_TEXTURE_MIP_POINT;\r\n\t}\r\n\ttex->m_Flags = bgfxFlags;\r\n\r\n\ttex->m_bgfxHandle = { bgfx_texture };\r\n\r\n\treturn handle;\r\n}\r\n```"}}
{"actor":{"display_login":"jdryg"}}