Skip to content

Commit e41cbeb

Browse files
committed
Set define for USE_ENTRY.
1 parent 500e03f commit e41cbeb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

examples/common/imgui/imgui.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include "imgui.h"
1515
#include "../bgfx_utils.h"
1616

17-
//#define USE_ENTRY 1
18-
1917
#ifndef USE_ENTRY
2018
# define USE_ENTRY 0
2119
#endif // USE_ENTRY
@@ -66,10 +64,13 @@ struct OcornutImguiContext
6664
void render(ImDrawData* _drawData)
6765
{
6866
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
69-
int fb_width = (int)(_drawData->DisplaySize.x * _drawData->FramebufferScale.x);
70-
int fb_height = (int)(_drawData->DisplaySize.y * _drawData->FramebufferScale.y);
71-
if (fb_width <= 0 || fb_height <= 0)
67+
int32_t dispWidth = _drawData->DisplaySize.x * _drawData->FramebufferScale.x;
68+
int32_t dispHeight = _drawData->DisplaySize.y * _drawData->FramebufferScale.y;
69+
if (dispWidth <= 0
70+
|| dispHeight <= 0)
71+
{
7272
return;
73+
}
7374

7475
bgfx::setViewName(m_viewId, "ImGui");
7576
bgfx::setViewMode(m_viewId, bgfx::ViewMode::Sequential);
@@ -137,11 +138,13 @@ struct OcornutImguiContext
137138
if (NULL != cmd->TextureId)
138139
{
139140
union { ImTextureID ptr; struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; } texture = { cmd->TextureId };
141+
140142
state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s.flags)
141143
? BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
142144
: BGFX_STATE_NONE
143145
;
144146
th = texture.s.handle;
147+
145148
if (0 != texture.s.mip)
146149
{
147150
const float lodEnabled[4] = { float(texture.s.mip), 1.0f, 0.0f, 0.0f };
@@ -161,8 +164,8 @@ struct OcornutImguiContext
161164
clipRect.z = (cmd->ClipRect.z - clipPos.x) * clipScale.x;
162165
clipRect.w = (cmd->ClipRect.w - clipPos.y) * clipScale.y;
163166

164-
if (clipRect.x < fb_width
165-
&& clipRect.y < fb_height
167+
if (clipRect.x < dispWidth
168+
&& clipRect.y < dispHeight
166169
&& clipRect.z >= 0.0f
167170
&& clipRect.w >= 0.0f)
168171
{

scripts/example-common.lua

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ project ("example-common")
3838
path.join(BGFX_DIR, "examples/common/**.h"),
3939
}
4040

41+
defines {
42+
"USE_ENTRY=1",
43+
}
44+
4145
using_bx()
4246

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

0 commit comments

Comments
 (0)