Skip to content

Commit 15dccd5

Browse files
[Editor] Minor fixes to ImGuiProxy;
1 parent 2dfc1e1 commit 15dccd5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ DefaultResources
1818
dist
1919
Test Project/Game.csproj
2020
Test Project/Sandbox.sln
21+
.idea

Engine/Editor/ImGuiProxy.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ public bool Initialize()
8686
unsafe
8787
{
8888
byte *data = null;
89-
int fontWidth = 0;
90-
int fontHeight = 0;
89+
var fontWidth = 0;
90+
var fontHeight = 0;
9191

9292
io.Fonts.GetTexDataAsRGBA32(&data, ref fontWidth, ref fontHeight);
9393

94-
byte[] fontData = new byte[fontWidth * fontHeight * 4];
94+
if (data == null)
95+
{
96+
Log.Error("Failed to load font");
97+
98+
return false;
99+
}
100+
101+
var fontData = new byte[fontWidth * fontHeight * 4];
95102

96-
for(int i = 0; i < fontData.Length; i++)
103+
for(var i = 0; i < fontData.Length; i++)
97104
{
98105
fontData[i] = data[i];
99106
}
@@ -315,7 +322,7 @@ private void Render(ImDrawDataPtr drawData)
315322
var clipPos = drawData.DisplayPos;
316323
var clipScale = drawData.FramebufferScale;
317324

318-
for (int i = 0; i < drawData.CmdListsCount; i++)
325+
for (var i = 0; i < drawData.CmdListsCount; i++)
319326
{
320327
bgfx.TransientVertexBuffer tvb;
321328
bgfx.TransientIndexBuffer tib;
@@ -409,7 +416,7 @@ public static ImTextureID GetImGuiTexture(Texture texture)
409416
return ImTextureID.Null;
410417
}
411418

412-
return new ImTextureID(texture.handle.idx);
419+
return new ImTextureID((ulong)texture.handle.idx);
413420
}
414421

415422
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)