|
@@ -14,8 +14,6 @@
|
|
|
#include "imgui.h"
|
|
#include "imgui.h"
|
|
|
#include "../bgfx_utils.h"
|
|
#include "../bgfx_utils.h"
|
|
|
|
|
|
|
|
-//#define USE_ENTRY 1
|
|
|
|
|
-
|
|
|
|
|
#ifndef USE_ENTRY
|
|
#ifndef USE_ENTRY
|
|
|
# define USE_ENTRY 0
|
|
# define USE_ENTRY 0
|
|
|
#endif // USE_ENTRY
|
|
#endif // USE_ENTRY
|
|
@@ -66,10 +64,13 @@ struct OcornutImguiContext
|
|
|
void render(ImDrawData* _drawData)
|
|
void render(ImDrawData* _drawData)
|
|
|
{
|
|
{
|
|
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
|
|
- int fb_width = (int)(_drawData->DisplaySize.x * _drawData->FramebufferScale.x);
|
|
|
|
|
- int fb_height = (int)(_drawData->DisplaySize.y * _drawData->FramebufferScale.y);
|
|
|
|
|
- if (fb_width <= 0 || fb_height <= 0)
|
|
|
|
|
|
|
+ int32_t dispWidth = _drawData->DisplaySize.x * _drawData->FramebufferScale.x;
|
|
|
|
|
+ int32_t dispHeight = _drawData->DisplaySize.y * _drawData->FramebufferScale.y;
|
|
|
|
|
+ if (dispWidth <= 0
|
|
|
|
|
+ || dispHeight <= 0)
|
|
|
|
|
+ {
|
|
|
return;
|
|
return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
bgfx::setViewName(m_viewId, "ImGui");
|
|
bgfx::setViewName(m_viewId, "ImGui");
|
|
|
bgfx::setViewMode(m_viewId, bgfx::ViewMode::Sequential);
|
|
bgfx::setViewMode(m_viewId, bgfx::ViewMode::Sequential);
|
|
@@ -137,11 +138,13 @@ struct OcornutImguiContext
|
|
|
if (NULL != cmd->TextureId)
|
|
if (NULL != cmd->TextureId)
|
|
|
{
|
|
{
|
|
|
union { ImTextureID ptr; struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } 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)
|
|
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_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
|
|
: BGFX_STATE_NONE
|
|
: BGFX_STATE_NONE
|
|
|
;
|
|
;
|
|
|
th = texture.s.handle;
|
|
th = texture.s.handle;
|
|
|
|
|
+
|
|
|
if (0 != texture.s.mip)
|
|
if (0 != texture.s.mip)
|
|
|
{
|
|
{
|
|
|
const float lodEnabled[4] = { float(texture.s.mip), 1.0f, 0.0f, 0.0f };
|
|
const float lodEnabled[4] = { float(texture.s.mip), 1.0f, 0.0f, 0.0f };
|
|
@@ -161,8 +164,8 @@ struct OcornutImguiContext
|
|
|
clipRect.z = (cmd->ClipRect.z - clipPos.x) * clipScale.x;
|
|
clipRect.z = (cmd->ClipRect.z - clipPos.x) * clipScale.x;
|
|
|
clipRect.w = (cmd->ClipRect.w - clipPos.y) * clipScale.y;
|
|
clipRect.w = (cmd->ClipRect.w - clipPos.y) * clipScale.y;
|
|
|
|
|
|
|
|
- if (clipRect.x < fb_width
|
|
|
|
|
- && clipRect.y < fb_height
|
|
|
|
|
|
|
+ if (clipRect.x < dispWidth
|
|
|
|
|
+ && clipRect.y < dispHeight
|
|
|
&& clipRect.z >= 0.0f
|
|
&& clipRect.z >= 0.0f
|
|
|
&& clipRect.w >= 0.0f)
|
|
&& clipRect.w >= 0.0f)
|
|
|
{
|
|
{
|