PDA

View Full Version : Dawing Strings



Misbah
01-21-2006, 05:18 AM
Hi
is there any method available for drawing string at some postion x y directly in Open GL.

jide
01-21-2006, 06:10 AM
Originally posted by Misbah:
Hi
is there any method available for drawing string at some postion x y directly in Open GL.What do you mean, drawing guitar strings, violin strings ?

No, opengl does not provide anything for rendering text. You have several possibilities however: use textures (generally along with display lists), or use window manager's specific tools for that (that might use in inside textures thought).

lud2k
01-21-2006, 07:06 AM
Hello,

Not totaly true...
OpenGL lib doesn't provide any way to draw strings that's true, but the GLUT lib does ^^
Search for glutStrokeCharacter().

void Write(long x, long y, const char *fmt, ...)
{
float length=0;
char text[256];
va_list ap;

va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,1,-1);

y = 480 - y;
glTranslated(x,y,0);
glColor3d(1,1,1);
glBindTexture(GL_TEXTURE_2D, 0);
glScaled(height/10.0, height/10.0, height/110.0);
for (int i=0; text[i]!=0; i++) {
glutStrokeCharacter(GLUT_STROKE_ROMAN, text[i]);
glTranslated(Espacement,0,0);
}

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

}

jide
01-22-2006, 07:31 AM
Originally posted by lud2k:
Hello,

Not totaly true...
OpenGL lib doesn't provide any way to draw strings that's true, but the GLUT lib does ^^
glut is not GL.