How to make 2 different fonts?
In my program, I want two different texts to appear, each a different font. How can I do this? I''m pretty new to openGL Thanks!
You can make bitmap fonts in OpenGL using glBitmap().
You can load a font into display lists. With glGenLists(Number_of_letters) allocate enough free display list indices, the function returns the first of them. Then set up the letters into display lists:
glNewList(list_nr,GL_COMPILE)
glBitmap(width,height,0,0,width,0,pointer_to_bitmap_data);
glEndList();
For list_nr you should take the return value of glGenLists() + the ASCII code of the letter. The bitmap is a real bitmap, I mean every bit represents one pixel.
This was the initialization, if you want to write use glRasterPos2i(x,y) to set the ''cursor'' to the right position, then:
glListBase(listbase);
glCallLists(str_length,GL_UNSIGNED_BYTE,pointer_to_str);
If you want to use two different fonts, make the initializasion a second time for the second font, then you can choose with glListBase() which font you want.
Visit our homepage: www.rarebyte.de.st
GA
You can load a font into display lists. With glGenLists(Number_of_letters) allocate enough free display list indices, the function returns the first of them. Then set up the letters into display lists:
glNewList(list_nr,GL_COMPILE)
glBitmap(width,height,0,0,width,0,pointer_to_bitmap_data);
glEndList();
For list_nr you should take the return value of glGenLists() + the ASCII code of the letter. The bitmap is a real bitmap, I mean every bit represents one pixel.
This was the initialization, if you want to write use glRasterPos2i(x,y) to set the ''cursor'' to the right position, then:
glListBase(listbase);
glCallLists(str_length,GL_UNSIGNED_BYTE,pointer_to_str);
If you want to use two different fonts, make the initializasion a second time for the second font, then you can choose with glListBase() which font you want.
Visit our homepage: www.rarebyte.de.st
GA
Visit our homepage: www.rarebyte.de.stGA
Create the two fonts with CreateFont(), call wglUseFontOutlines() two times but before you call it the 2nd time select the second font object, then call it with a different base.
Then you have the possibility to choose between the two fonts with glListBase()
Visit our homepage: www.rarebyte.de.st
GA
Then you have the possibility to choose between the two fonts with glListBase()
Visit our homepage: www.rarebyte.de.st
GA
Visit our homepage: www.rarebyte.de.stGA
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement