Help those suffering in the Horn of Africa

VSFontLib Requirements

Prev: Source Next: In Action
 

VSFontLib aims at providing users with the ability to render bitmapped text in an OpenGL application using the core profile.

As usual, in OpenGL core versions we need shaders to render the fonts. These can be pretty ordinary shaders, the only requirement is texture support.

For this lib to work properly, the math lib must be properly initialized. Considering the shaders below, we need to set the semantics of the uniforms projMatrix and viewModelMatrix. This can be achieved with the following code:

VSMathLib *vsml;
...
vsml = VSMathLib::getInstance();
vsml->setUniformBlockName("Matrices");
vsml->setUniformName(VSMathLib::PROJECTION, "projMatrix");
vsml->setUniformName(VSMathLib::VIEW_MODEL, "viewModelMatrix");

As an example, here is a pair of vertex and fragment shaders that can do the job perfectly.

Vertex shader:

#version 330

layout (std140) uniform Matrices {

	mat4 projMatrix;
	mat4 viewModelMatrix;
};

in vec3 position;
in vec2 texCoord;

out vec4 vertexPos;
out vec2 TexCoord;

void main()
{
	TexCoord = vec2(texCoord);
	gl_Position = projMatrix * viewModelMatrix* vec4(position,1.0);
}

And here goes the fragment shader:

#version 330

uniform	sampler2D texUnit;

in vec2 TexCoord;
out vec4 output;

void main()
{
	output = texture2D(texUnit, TexCoord)
}

 

Prev: Source Next: In Action
 

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2012 Lighthouse3d.com Suffusion theme by Sayontan Sinha