Skip to content

Commit 4981da9

Browse files
committed
fix - title text
1 parent 7536276 commit 4981da9

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

src/Box2D.NET.Samples/Graphics/Draw.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-FileCopyrightText: 2025 Ikpil Choi([email protected])
33
// SPDX-License-Identifier: MIT
44

5-
using ImGuiNET;
65
using Silk.NET.GLFW;
76
using Silk.NET.OpenGL;
87

@@ -13,7 +12,6 @@ public class Draw
1312
{
1413
public Glfw glfw;
1514
public GL gl;
16-
public Camera camera;
1715

1816
public Background background;
1917
public PointRender points;

src/Box2D.NET.Samples/Graphics/Draws.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public static class Draws
2323
public static Draw CreateDraw(SampleContext context)
2424
{
2525
var draw = new Draw();
26-
draw.camera = context.camera;
2726
draw.gl = context.gl;
2827

2928
draw.background = CreateBackground(context.gl);
@@ -129,16 +128,16 @@ public static void DrawPoint(Draw draw, B2Vec2 p, float size, B2HexColor color)
129128

130129

131130

132-
public static void FlushDraw(Draw draw)
131+
public static void FlushDraw(Draw draw, Camera camera)
133132
{
134133
// order matters
135-
FlushSolidCircles(draw.gl, ref draw.circles, draw.camera);
136-
FlushCapsules(draw.gl, ref draw.capsules, draw.camera);
137-
FlushPolygons(draw.gl, ref draw.polygons, draw.camera);
138-
FlushCircles(draw.gl, ref draw.hollowCircles, draw.camera);
139-
FlushLines(draw.gl, ref draw.lines, draw.camera);
140-
FlushPoints(draw.gl, ref draw.points, draw.camera);
141-
FlushText(draw.gl, ref draw.font, draw.camera);
134+
FlushSolidCircles(draw.gl, ref draw.circles, camera);
135+
FlushCapsules(draw.gl, ref draw.capsules, camera);
136+
FlushPolygons(draw.gl, ref draw.polygons, camera);
137+
FlushCircles(draw.gl, ref draw.hollowCircles, camera);
138+
FlushLines(draw.gl, ref draw.lines, camera);
139+
FlushPoints(draw.gl, ref draw.points, camera);
140+
FlushText(draw.gl, ref draw.font, camera);
142141
draw.gl.CheckOpenGL();
143142
}
144143
}

src/Box2D.NET.Samples/SampleApp.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,25 +354,22 @@ private void OnWindowRender(double dt)
354354
ImGui.Begin("Overlay", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar);
355355
ImGui.End();
356356

357-
if (_context.showUI)
358-
{
359-
var title = SampleFactory.Shared.GetTitle(_context.sampleIndex);
360-
s_sample.ResetText(title);
361-
}
357+
s_sample.ResetText();
358+
359+
var title = SampleFactory.Shared.GetTitle(_context.sampleIndex);
360+
s_sample.DrawColoredTextLine(B2HexColor.b2_colorYellow, title);
361+
362+
string buffer = $"{1000.0f * _frameTime:0.0} ms - step {s_sample.m_stepCount} - " +
363+
$"camera ({_context.camera.center.X:G}, {_context.camera.center.Y:G}, {_context.camera.zoom:G})";
364+
DrawScreenString(_context.draw, 5.0f, _context.camera.height - 18.0f, B2HexColor.b2_colorSeaGreen, buffer);
362365

363366
s_sample.Draw();
364-
FlushDraw(_context.draw);
367+
FlushDraw(_context.draw, _context.camera);
365368

366369
UpdateUI();
367370

368371
//ImGui.ShowDemoWindow();
369372

370-
if (_context.showUI)
371-
{
372-
string buffer = $"{1000.0f * _frameTime:0.0} ms - step {s_sample.m_stepCount} - " +
373-
$"camera ({_context.camera.center.X:G}, {_context.camera.center.Y:G}, {_context.camera.zoom:G})";
374-
DrawScreenString(_context.draw, 5.0f, _context.camera.height - 18.0f, B2HexColor.b2_colorSeaGreen, buffer);
375-
}
376373

377374
_imgui.Render();
378375
//ImGui_ImplOpenGL3_RenderDrawData(ImGui.GetDrawData());

src/Box2D.NET.Samples/SampleContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ public static SampleContext CreateFor(string sig, Glfw glfw)
146146
return context;
147147
}
148148

149-
public static void DrawBackground(Draw draw)
149+
public static void DrawBackground(Draw draw, Camera camera)
150150
{
151-
RenderBackground(draw.glfw, draw.gl, ref draw.background, draw.camera);
151+
RenderBackground(draw.glfw, draw.gl, ref draw.background, camera);
152152
}
153153

154154
public static void DrawPolygonFcn(ReadOnlySpan<B2Vec2> vertices, int vertexCount, B2HexColor color, object context)

src/Box2D.NET.Samples/Samples/Sample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private static void FinishTask(object taskPtr, object userContext)
248248
}
249249
}
250250

251-
public void ResetText(string title)
251+
public void ResetText()
252252
{
253253
m_textLine = m_textIncrement;
254254
}

0 commit comments

Comments
 (0)