PDA

View Full Version : Display text and menus in OpenGL



Andriyev
12-07-2008, 03:55 PM
Hi,

I have a couple of questions on OpenGL-

1. Related to menus - Can I somehow rename a menu item in OpenGL ? For e.g. - I have a menu item which says 'Start Game' and when the game is on it would change to 'Restart game'.
Else, is there a way to disable a menu item ?

2. How to display text in OpenGL ?
I tried the following function but the font size it shows is huge as I guess glutStrokeCharacter displays fixed font sizes-

void output(char *ptr, float x, float y, float w)
{
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(w);
glTranslatef(x,y,Z); //Z is fixed

while(*ptr){
glutStrokeCharacter(GLUT_STROKE_ROMAN,*ptr);
ptr++;
}
}

I even thought of using glutBitmapCharacter(), but even that has a fixed sized fonts, the maximum being 24 points.

Is there any means by which my font size can vary as I resize my window ?


Thanks.

zeoverlord
12-07-2008, 05:32 PM
1. if your talking about windows gui menus, then id advice against it, instead make your own system, then you would have absolute control.

2. you could always scale it using glScale, but id advice that you use something like this (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17).

_NK47
12-08-2008, 04:35 AM
1. menus suck in fullscreen applications, better go different way from the start. simplest way where you draw a string "start game" which you then raname into "restart game".
2. better use some font libs like FTGL for that because they cache font chars in textures which you can rotate, translate and so on, they also faster.

zeoverlord: "instead make your own system"
i really doubt a GUI system is for beginners.