Skip to content

Commit 584473e

Browse files
committed
updated to fix a few issues with shader lib when expected type was not float, now force set_colour in text to convert things to float
1 parent 363e09e commit 584473e

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#version 410 core
22
in vec2 v_uv;
33
uniform sampler2D textureID;
4-
uniform vec4 textColor;
4+
uniform vec4 textColour;
55
out vec4 fragColor;
66
void main()
77
{
88
float a = texture(textureID, v_uv).a;
9-
fragColor = vec4(textColor.rgb, textColor.a * a);
9+
fragColor = vec4(textColour.rgb, textColour.a * a);
1010
}

src/ncca/ngl/text.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,11 @@ def set_screen_size(self, w: int, h: int) -> None:
223223
"""
224224
ShaderLib.use(DefaultShader.TEXT)
225225
ShaderLib.set_uniform("textureID", 0)
226-
ShaderLib.set_uniform("screenSize", w, h)
226+
ShaderLib.set_uniform("screenSize", float(w), float(h))
227227
ShaderLib.set_uniform("fontSize", 1.0)
228-
ShaderLib.set_uniform("textColor", 1.0, 1.0, 1.0, 1.0)
228+
ShaderLib.set_uniform("textColour", 1.0, 1.0, 1.0, 1.0)
229229

230-
def render_text(
231-
self, font: str, x: int, y: int, text: str, colour: Vec3 = Vec3(1, 1, 1)
232-
) -> None:
230+
def render_text(self, font: str, x: int, y: int, text: str, colour: Vec3 = Vec3(1.0, 1.0, 1.0)) -> None:
233231
"""
234232
Renders a string of text to the screen.
235233
@@ -276,7 +274,7 @@ def render_text(
276274
gl.glActiveTexture(gl.GL_TEXTURE0)
277275
gl.glBindTexture(gl.GL_TEXTURE_2D, atlas.texture)
278276
ShaderLib.use(DefaultShader.TEXT)
279-
ShaderLib.set_uniform("textColor", colour.x, colour.y, colour.z, 1.0)
277+
ShaderLib.set_uniform("textColour", float(colour.x), float(colour.y), float(colour.z), 1.0)
280278
# We are drawing one point per character
281279
vao.set_num_indices(len(render_data) // 8)
282280
vao.draw()
@@ -288,9 +286,7 @@ def render_text(
288286
if polygon_mode != gl.GL_FILL:
289287
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, polygon_mode)
290288

291-
def _build_instances(
292-
self, font: str, text: str, start_x: int, start_y: int
293-
) -> List[float]:
289+
def _build_instances(self, font: str, text: str, start_x: int, start_y: int) -> List[float]:
294290
"""
295291
Generates vertex attribute data for each character in a string.
296292

0 commit comments

Comments
 (0)