PDA

View Full Version : how to write text below a point on the screen

saman_artorious
08-25-2013, 11:58 PM
My screen renders some pixels. I also want to render/write the x y coordinate of every point below it. Could anyone please tell me what function I shall use to accomplish this.

Decesive
08-26-2013, 04:17 AM
Rendering text is no easy task, unless you're working with some library that helps you out, if by chance you were using windows, then WinAPI could help you with that.
I'm pretty sure every OpenGL Wrapper Lib nowadays has some functions to get the position of a pixel, unless you wanted to render info regarding x,y coordinates of a vertex. Rendering such text would be exactly like rendering any other object, you'd specify the position (or more precisely, you'd specify positions of vertices, unless it was an image :P) at which you want to render specified image / function that prints a number.

The easiest and most idiotic way to do it, just to test things out, would be to go into any Paint-like program, and make a couple of images to output at desired points, a more advanced way to do it would be to get interested in fonts and try to make a system that would take a letter from a file and print it at a certain point. Unfortunately, I don't think any of those methods are easy to implement. You could also make a couple of funtions with hard-coded positioning of vertices to render text, something like this

void Print[Number](GLint x, GLint y, GLint z)
{
//specify the vertices, and just add x,y,z respectively
}

Although, this method is pretty stupid too :)

Carmine
08-26-2013, 10:02 AM
Usually the utility that opens a window for you (such as Glut) provides character and/or string routines. You simply call the routine with the (x,y) coordinates of the point in question and the string is drawn to the screen. If you want a string drawn below a point, you add small deltas to x and y. I actually use Glut string routines in my simulations even though I open my windows with another library.

saman_artorious
08-28-2013, 12:47 AM
Usually the utility that opens a window for you (such as Glut) provides character and/or string routines. You simply call the routine with the (x,y) coordinates of the point in question and the string is drawn to the screen. If you want a string drawn below a point, you add small deltas to x and y. I actually use Glut string routines in my simulations even though I open my windows with another library.

I do not understand how your method is implemented. However, I found this link for my problem. is this a good method? http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_01#Introduct ion

Decesive
08-28-2013, 03:44 AM
Did you just seriously put up a link to a file on your computer ? How in Seven Hells did you even get to programming ?

Anyways, find the actual page that file refers to and put the actual WWW link here.

saman_artorious
08-28-2013, 04:23 AM
Did you just seriously put up a link to a file on your computer ? How in Seven Hells did you even get to programming ?

Anyways, find the actual page that file refers to and put the actual WWW link here.

I was disconnected. That's why I sent the wrong link mistakenly. Can you please hold your horses. It happens sometimes.

Carmine
08-28-2013, 10:13 AM
I do not understand how your method is implemented. However, I found this link for my problem. is this a good method? http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_01#Introduct ion It's easier than what your link describes. For example, if you are using GLUT or FreeGlut, there's a routine(s) that display characters or strings. They provide a limited selection of sizes and font types. Here's a link ....