Skip to content

Commit 96a4121

Browse files
committed
[upstream] Custom text renderer (erincatto/box2d#998)
Added font rendering code independent of imgui. Converted drawing code to C. `b2DebugDraw::DrawSegmentFcn` renamed to `b2DebugDraw::DrawLineFcn`.
1 parent dcd3843 commit 96a4121

File tree

194 files changed

+3518
-2633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+3518
-2633
lines changed

data/font.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-FileCopyrightText: 2025 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330 core
5+
6+
in vec4 color;
7+
in vec2 uv;
8+
9+
uniform sampler2D FontAtlas;
10+
11+
out vec4 fragColor;
12+
13+
void main()
14+
{
15+
fragColor = vec4(color.rgb, color.a * texture(FontAtlas, uv).r);
16+
}

data/font.vs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2025 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330 core
5+
6+
layout (location = 0) in vec2 aPosition;
7+
layout (location = 1) in vec2 aUV;
8+
layout (location = 2) in vec4 aColor;
9+
10+
out vec4 color;
11+
out vec2 uv;
12+
13+
uniform mat4 ProjectionMatrix;
14+
15+
void main()
16+
{
17+
gl_Position = ProjectionMatrix * vec4(aPosition, 0.0, 1.0);
18+
19+
color = aColor;
20+
uv = aUV;
21+
}

data/line.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2025 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330
5+
6+
in vec4 f_color;
7+
out vec4 color;
8+
9+
void main(void)
10+
{
11+
color = f_color;
12+
}

data/line.vs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-FileCopyrightText: 2024 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330
5+
6+
uniform mat4 projectionMatrix;
7+
layout(location = 0) in vec2 v_position;
8+
layout(location = 1) in vec4 v_color;
9+
10+
out vec4 f_color;
11+
12+
void main(void)
13+
{
14+
f_color = v_color;
15+
gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);
16+
}

data/point.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2025 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330
5+
6+
in vec4 f_color;
7+
out vec4 color;
8+
9+
void main(void)
10+
{
11+
color = f_color;
12+
}

data/point.vs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-FileCopyrightText: 2024 Erin Catto
2+
// SPDX-License-Identifier: MIT
3+
4+
#version 330
5+
6+
uniform mat4 projectionMatrix;
7+
layout(location = 0) in vec2 v_position;
8+
layout(location = 1) in float v_size;
9+
layout(location = 2) in vec4 v_color;
10+
11+
out vec4 f_color;
12+
13+
void main(void)
14+
{
15+
f_color = v_color;
16+
gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);
17+
gl_PointSize = v_size;
18+
}

src/Box2D.NET.Samples/Camera.cs

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)