summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/imgui
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/imgui')
-rw-r--r--3rdparty/bgfx/examples/common/imgui/imgui.cpp7
-rw-r--r--3rdparty/bgfx/examples/common/imgui/imgui.h24
-rw-r--r--3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp10
3 files changed, 29 insertions, 12 deletions
diff --git a/3rdparty/bgfx/examples/common/imgui/imgui.cpp b/3rdparty/bgfx/examples/common/imgui/imgui.cpp
index 2655e6ce0a1..4cdc5f30fe5 100644
--- a/3rdparty/bgfx/examples/common/imgui/imgui.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/imgui.cpp
@@ -3572,3 +3572,10 @@ bool imguiMouseOverArea()
{
return s_imgui.m_insideArea;
}
+
+bgfx::ProgramHandle imguiGetImageProgram(uint8_t _mip)
+{
+ const float lodEnabled[4] = { float(_mip), 1.0f, 0.0f, 0.0f };
+ bgfx::setUniform(s_imgui.u_imageLodEnabled, lodEnabled);
+ return s_imgui.m_imageProgram;
+}
diff --git a/3rdparty/bgfx/examples/common/imgui/imgui.h b/3rdparty/bgfx/examples/common/imgui/imgui.h
index 75269500c85..0ab18cb9f8a 100644
--- a/3rdparty/bgfx/examples/common/imgui/imgui.h
+++ b/3rdparty/bgfx/examples/common/imgui/imgui.h
@@ -208,12 +208,13 @@ bool imguiMouseOverArea();
namespace ImGui
{
-#define IMGUI_FLAGS_NONE UINT16_C(0x0000)
-#define IMGUI_FLAGS_ALPHA_BLEND UINT16_C(0x0001)
+#define IMGUI_FLAGS_NONE UINT8_C(0x00)
+#define IMGUI_FLAGS_ALPHA_BLEND UINT8_C(0x01)
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
inline void Image(bgfx::TextureHandle _handle
- , uint16_t _flags
+ , uint8_t _flags
+ , uint8_t _mip
, const ImVec2& _size
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
@@ -221,9 +222,10 @@ namespace ImGui
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
)
{
- union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
- texture.s.flags = _flags;
+ union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
texture.s.handle = _handle;
+ texture.s.flags = _flags;
+ texture.s.mip = _mip;
Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol);
}
@@ -236,12 +238,13 @@ namespace ImGui
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
)
{
- Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _tintCol, _borderCol);
+ Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _tintCol, _borderCol);
}
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
inline bool ImageButton(bgfx::TextureHandle _handle
- , uint16_t _flags
+ , uint8_t _flags
+ , uint8_t _mip
, const ImVec2& _size
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
@@ -250,9 +253,10 @@ namespace ImGui
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
)
{
- union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
- texture.s.flags = _flags;
+ union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
texture.s.handle = _handle;
+ texture.s.flags = _flags;
+ texture.s.mip = _mip;
return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
}
@@ -266,7 +270,7 @@ namespace ImGui
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
)
{
- return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
+ return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
}
} // namespace ImGui
diff --git a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
index 4545bb998a0..f6f0a4e2bdd 100644
--- a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
@@ -305,15 +305,21 @@ struct OcornutImguiContext
;
bgfx::TextureHandle th = m_texture;
+ bgfx::ProgramHandle program = m_program;
if (NULL != cmd->TextureId)
{
- union { ImTextureID ptr; struct { uint16_t flags; bgfx::TextureHandle handle; } s; } texture = { cmd->TextureId };
+ union { ImTextureID ptr; struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; } texture = { cmd->TextureId };
state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s.flags)
? BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
: BGFX_STATE_NONE
;
th = texture.s.handle;
+ if (0 != texture.s.mip)
+ {
+ extern bgfx::ProgramHandle imguiGetImageProgram(uint8_t _mip);
+ program = imguiGetImageProgram(texture.s.mip);
+ }
}
else
{
@@ -331,7 +337,7 @@ struct OcornutImguiContext
bgfx::setTexture(0, s_tex, th);
bgfx::setVertexBuffer(&tvb, 0, numVertices);
bgfx::setIndexBuffer(&tib, offset, cmd->ElemCount);
- bgfx::submit(cmd->ViewId, m_program);
+ bgfx::submit(cmd->ViewId, program);
}
offset += cmd->ElemCount;