I am writing a simple android program using OpenGL to display simple per-vertex colored shapes and a counter displaying the framerate.
I found out that displaying the framerate is tricky due to the lack of built-in text rendering in OpenGL ... I searched a long time to find a simple code that would do that with OpenGL ES 2.0, and I found this code on Github. For that purpose, it uses a dedicated vertex and fragment shader. The following shows the fragment shader:
uniform sampler2D u_Texture;
precision mediump float;
uniform vec4 u_Color;
varying vec2 v_TexCoordinate;
void main()
{
gl_FragColor = texture2D(u_Texture, v_TexCoordinate).w * u_Color;
}
However, in order to render my per-vertex colored shapes, I use the following fragment shader:
precision mediump float;
varying vec4 v_Color;
void main()
{
gl_FragColor = v_Color;
}
I am a little confused by this...
Can my Android application use both shaders and switch between one and the other ? If yes, how ?
Or should I use one single shader doing both tasks ? In this case, what would the shader look like ?
Also, I would appreciate any hint on how to easily implement an FPS display in OpenGL ES 2.0 (by easily, I mean a few classes dedicated to FPS display, not general text rendering).