Reputation: 21
I want to Draw the 3D text in OpenGL viewport.
I have applied following method but it shows text at 2D positions.
void renderBitmapString(float x, float y, float z,void *font,const char *string){
const char * c;
//glRasterPos2f(x, y);
// glutBitmapCharacter(font, string);
glRasterPos3f(x, y ,z);
//glRasterPos3i(x, y ,z);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);
}
}
Upvotes: 2
Views: 4843
Reputation: 28892
OpenGL does not render text. It is not part of the standard. What it does render is textures or bitmap images. So the way to render text is to use some sort of 2D rendering library like Cairo. This should help you create a bitmap with text in it. Once you have a bitmap, you can then render the bitmap as a texture. Just be careful though, Cairo uses BGRA format for its bitmaps so you might need to swizzle the red and blue components to get things working.
Upvotes: 4
Reputation: 52083
Switch to glutStrokeCharacter()
.
Or render your glutBitmapCharacter()
s to a texture via FBO.
Upvotes: 0