14
14
#include " imgui.h"
15
15
#include " ../bgfx_utils.h"
16
16
17
- // #define USE_ENTRY 1
18
-
19
17
#ifndef USE_ENTRY
20
18
# define USE_ENTRY 0
21
19
#endif // USE_ENTRY
@@ -66,10 +64,13 @@ struct OcornutImguiContext
66
64
void render (ImDrawData* _drawData)
67
65
{
68
66
// 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
+ {
72
72
return ;
73
+ }
73
74
74
75
bgfx::setViewName (m_viewId, " ImGui" );
75
76
bgfx::setViewMode (m_viewId, bgfx::ViewMode::Sequential);
@@ -137,11 +138,13 @@ struct OcornutImguiContext
137
138
if (NULL != cmd->TextureId )
138
139
{
139
140
union { ImTextureID ptr; struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; } texture = { cmd->TextureId };
141
+
140
142
state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s .flags )
141
143
? BGFX_STATE_BLEND_FUNC (BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
142
144
: BGFX_STATE_NONE
143
145
;
144
146
th = texture.s .handle ;
147
+
145
148
if (0 != texture.s .mip )
146
149
{
147
150
const float lodEnabled[4 ] = { float (texture.s .mip ), 1 .0f , 0 .0f , 0 .0f };
@@ -161,8 +164,8 @@ struct OcornutImguiContext
161
164
clipRect.z = (cmd->ClipRect .z - clipPos.x ) * clipScale.x ;
162
165
clipRect.w = (cmd->ClipRect .w - clipPos.y ) * clipScale.y ;
163
166
164
- if (clipRect.x < fb_width
165
- && clipRect.y < fb_height
167
+ if (clipRect.x < dispWidth
168
+ && clipRect.y < dispHeight
166
169
&& clipRect.z >= 0 .0f
167
170
&& clipRect.w >= 0 .0f )
168
171
{
0 commit comments