954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Drawing Text in OpenGL

Alright, so im making falling numbers and i need to display points while its running. in the code its keeping track, but i have no way of displaying it. in regular C++ i would just do cout<

bballmitch
Newbie Poster
10 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

can someone please help me out. i need to know how to make a variable number show up.

at the bare minimum, can someone please tell me how to convert an int into a string so that i can make the points show up in the title of the window. help would be appreciated.

bballmitch
Newbie Poster
10 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Use a tool called GLFont under ortho view you can output text like

glFontBegin(&font);
glScalef(8.0, 8.0, 8.0);
glTranslatef(30, 30, 0);
glFontTextOut("Test", 5, 5, 0);
glFontEnd();
glFlush();

you can find it here http://students.cs.byu.edu/~bfish/glfontdl.php

i remember there is function under opengl who can put text on screen too.
Check this:
http://www.opengl.org/resources/features/fontsurvey/

for int --> string, you can use

int num = 234;
	string data;
	stringstream ss;
	ss << num;
	data=ss.str();

can someone please help me out. i need to know how to make a variable number show up.

at the bare minimum, can someone please tell me how to convert an int into a string so that i can make the points show up in the title of the window. help would be appreciated.

alone2005
Newbie Poster
23 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Thanks!
I'm also trying to make moving text and this worked!

t3ch|\/|4n
Newbie Poster
6 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

hey can any1 help me how 2 draw text at variable locations in openGL???

ashwini_rt
Newbie Poster
7 posts since Mar 2010
Reputation Points: 6
Solved Threads: 0
 

You can use the printw function. Check out this post .

Usage is as simple as calling printf:

printf(         "char: %c, decimal: %d, float: %f, string: %s", 'X', 1618, 1.618, "text");
printw(x, y, z, "char: %c, decimal: %d, float: %f, string: %s", 'X', 1618, 1.618, "text");
alibad
Newbie Poster
2 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

thanks for your reply..

ashwini_rt
Newbie Poster
7 posts since Mar 2010
Reputation Points: 6
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You