From aa36d167b6774759c2fcb4dd0661a0f3e04bbe5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Mon, 22 Aug 2022 20:57:19 -0700 Subject: [PATCH] 47-pixelformats: Add supported/emulated info. --- examples/47-pixelformats/pixelformats.cpp | 45 +++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/examples/47-pixelformats/pixelformats.cpp b/examples/47-pixelformats/pixelformats.cpp index 458819adf..dcc54cfb6 100644 --- a/examples/47-pixelformats/pixelformats.cpp +++ b/examples/47-pixelformats/pixelformats.cpp @@ -319,6 +319,7 @@ public: label.append(bimg::getName(bimg::TextureFormat::Enum(format) ) ); imguiTextBoxUnformatted(ImVec2(cellWidth, 0.0f), label.c_str() ); imguiTexturePreview(ImVec2(cellWidth, m_previewSize), m_textures[i], ImVec2(m_previewSize, m_previewSize) ); + ImGui::EndGroup(); splitter.SetCurrentChannel(drawList, 0); @@ -344,20 +345,40 @@ public: ImGui::EndTable(); ImGui::End(); - ImGui::SetNextWindowPos(ImVec2(40.0f, 300.0f), ImGuiCond_FirstUseEver); - ImGui::Begin("Selected Format", NULL, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Text("Format: %s", bimg::getName(m_selectedFormat) ); - int32_t selectedTextureIndex = m_selectedFormat - 1 - (int32_t)bimg::TextureFormat::Unknown; - - bgfx::TextureHandle selectedTexture = BGFX_INVALID_HANDLE; - - if (m_selectedFormat != bimg::TextureFormat::Unknown) { - selectedTexture = m_textures[selectedTextureIndex]; - } + ImGui::SetNextWindowPos(ImVec2(40.0f, 300.0f), ImGuiCond_FirstUseEver); + ImGui::Begin("Selected Format", NULL, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Text("Format: %s", bimg::getName(m_selectedFormat) ); - imguiTexturePreview(ImVec2(kTextureSize, kTextureSize), selectedTexture); - ImGui::End(); + ImGui::PushEnabled(false); + + const bgfx::Caps* caps = bgfx::getCaps(); + + bool supported = caps->formats[m_selectedFormat] != BGFX_CAPS_FORMAT_TEXTURE_NONE; + ImGui::Checkbox("Supported", &supported); + ImGui::SameLine(); + + bool emulated = 0 != (caps->formats[m_selectedFormat] & (0 + | BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED + | BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED + | BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED + ) ); + ImGui::Checkbox("Emulated", &emulated); + + ImGui::PopEnabled(); + + int32_t selectedTextureIndex = m_selectedFormat - 1 - (int32_t)bimg::TextureFormat::Unknown; + + bgfx::TextureHandle selectedTexture = BGFX_INVALID_HANDLE; + + if (m_selectedFormat != bimg::TextureFormat::Unknown) + { + selectedTexture = m_textures[selectedTextureIndex]; + } + + imguiTexturePreview(ImVec2(kTextureSize, kTextureSize), selectedTexture); + ImGui::End(); + } imguiEndFrame();