View Full Version : Own Shaders for Textures ??

04-20-2017, 06:06 AM

i'm a OpenGL beginner and i want render some text with FreeType.

Do i Need a own shader for Rendering textures ?? Or can i just extend the old shader:

#version 430

layout (location = 0) in vec3 v3_Vertex;
layout (location = 1) in vec4 v4_Color;

uniform mat4 mat4_ViewTransformation;
uniform mat4 mat4_ProjectionTransformation;
uniform mat4 mat4_ModelTransformation;

out vec4 RGBAColor;

void main()

gl_Position = mat4_ProjectionTransformation * mat4_ViewTransformation * mat4_ModelTransformation * vec4(v3_Vertex,1.0f);
//v4_Color = vec4(0.0, 1.0, 0.0, 1.0);
RGBAColor = v4_Color;

04-20-2017, 06:25 AM
As improvement, use a specific shader. Most of the time, for example, you won't use the modelview matrix. Also, positions can be send only with a Vec2.
But if your existing shader can handle this, then it's also possible to reuse it.

04-21-2017, 11:37 AM
Okay, so i have decided to use several different shaders.
Now i'm on the Point where i want to map the glyph Texture.

In my example the texture of the glyph is mapped to a quadrangle wich consists of two triangles.

So What is the reason mapping the glyph texture to two triangles, and not mapping it just to one quadrangle ??

04-21-2017, 12:36 PM
Quads have been deprecated in OpenGL 3.0. See this (https://www.khronos.org/opengl/wiki/Primitive#Quads).
The other reason is that quads generally have weaker performances than triangles. Most of the time they were simulated by the driver as 2 triangles.
There are other reasons like quads are not flat but they are out of concern here.

04-22-2017, 08:25 AM
Okay, so i can render a character now. I have used the two triangles too.
I have rendered the C:\\Windows\\Fonts\\times.ttf font. But i think this was not a good choice i think it is too "bold" anyhow...

I'm looking for a good font with good readable small numbers. I Want render Dates and Numbers for a coordinate System...