Set define for USE_ENTRY.

This commit is contained in:
Бранимир Караџић 2024-07-09 07:28:59 -07:00
parent 500e03ffcb
commit e41cbebf16
2 changed files with 14 additions and 7 deletions

View File

@ -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
@ -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);
@ -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 };
@ -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)
{

View File

@ -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"),