Text rendering is one of the hard topic to be understood for most new comers. and right now, i got stuck here. well i'd like to ask wheter my way is good idea to render text.. OpenGL does not have built-in functionality to render text to the screen, thats make me confused. after searching, that the text render is using bitmap.
Load and bind bitmap font texture -> Parse text and generate and bind vertices array, mapping texture with uv array,... -> Render it to screen
ok this may can solve how to render text, but i still stuck. (for example) what if i make timer based Text that change every millisecond (since i draw text just like : Minute:Second:Mili Second) this is not good idea right? since i must repeat that algorithm while i want to change the text. i guess if we keep using bitmap the machine would get slower.
well, seeing bitmap text rendering is so slow, i make some way to render text without bitmap perhaps it would be get better? that's why i ask here
here is how i draw character model with 3d Vertex + GLOrtho just take look at my vector font code (example) How to draw "L" character with Vector
const float MAX_HEIGHT = 18.0f; //set maximum height of character
const float MAX_WIDTH = 20.0f; //set maximum width of character
void drawL(GLfloat x,GLfloat y){
glPushMatrix();
//i've set before glOrtho(0, Window.width, Window.height, 0, 0, 1);
glTranslatef(x,y,0.0f);
glBegin(GL_QUADS);
glVertex3f(0.0f,0.0f,0.0f); //draw vertical quad
glVertex3f(3.0f,0.0f,0.0f);
glVertex3f(3.0f,MAX_HEIGHT,0.0f);
glVertex3f(0.0f,MAX_HEIGHT,0.0f);
glNormal3f(0.0f,MAX_HEIGHT,0.0f); //draw horizontal quad
glVertex3f(2.0f,MAX_HEIGHT,0.0f);
glVertex3f(MAX_WIDTH - 10.0f,MAX_HEIGHT,0.0f);
glVertex3f(MAX_WIDTH - 10.0f,MAX_HEIGHT - 3.0f,0.0f);
glVertex3f(2.0f,MAX_HEIGHT - 3.0f,0.0f);
glEnd();
glPopMatrix();
}
there are some advantages if we draw character with vector/GL_QUAD vertex if you would like to resize the font will not getting blur.
the question now will this getting slower if i make timer based text that change every Milisecond? with this way, repeat the algorithm is unnecessary if i'm gonna change the text. they are not even consume much resource because it's not bitmap, it just vector rendering.