Skip to content

Commit

Permalink
Set define for USE_ENTRY.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Jul 9, 2024
1 parent 500e03f commit e41cbeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 10 additions & 7 deletions examples/common/imgui/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "imgui.h"
#include "../bgfx_utils.h"

//#define USE_ENTRY 1

#ifndef USE_ENTRY
# define USE_ENTRY 0
#endif // USE_ENTRY
Expand Down Expand Up @@ -66,10 +64,13 @@ struct OcornutImguiContext
void render(ImDrawData* _drawData)
{
// 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;
}

bgfx::setViewName(m_viewId, "ImGui");
bgfx::setViewMode(m_viewId, bgfx::ViewMode::Sequential);
Expand Down Expand Up @@ -137,11 +138,13 @@ struct OcornutImguiContext
if (NULL != 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)
{
const float lodEnabled[4] = { float(texture.s.mip), 1.0f, 0.0f, 0.0f };
Expand All @@ -161,8 +164,8 @@ struct OcornutImguiContext
clipRect.z = (cmd->ClipRect.z - clipPos.x) * clipScale.x;
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.w >= 0.0f)
{
Expand Down
4 changes: 4 additions & 0 deletions scripts/example-common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ project ("example-common")
path.join(BGFX_DIR, "examples/common/**.h"),
}

defines {
"USE_ENTRY=1",
}

using_bx()

if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"),
Expand Down

0 comments on commit e41cbeb

Please sign in to comment.