PDA

View Full Version : floating labels



fox
02-22-2001, 04:49 AM
How could I create flyby or floating labels for objects in my scene - so that if the mouse points this label pops up (very much like tooltips on toolbars)

cheers

chennes
02-22-2001, 05:13 AM
IMHO, GL's text capabilities are just too limited to make it worth the effort. It's really quite simple to draw a white-filled box. then a black-outlined box, then drop some text into that location on the screen, all using X, or whatever windowing system you're using.

To get it to popup, I start a timer when the mouse stops moving, and reset the timer when the mouse moves again. After X number of milliseconds have passed, I detect whatever the user has the mouse over and display the appropriate tip.

Chris

fox
02-22-2001, 05:31 AM
Do you have any code that I could possibly look at?

cheers

chennes
02-22-2001, 09:09 AM
the code that I use is for Xwindows and Gtk-- : if you'de like the pseudo code for that setup, I can get you that (I can't release the actual source http://www.opengl.org/discussion_boards/ubb/frown.gif sorry). Which part are you confused on... I'm not sure how Microsoft does things, but in Xwindows it's a pretty simple matter to draw a rectangle and some text onto the screen at an arbitary location.

Chris

Michael Steinberg
02-22-2001, 11:31 AM
But can your draw rects simply over an opengl view? I always see flickering etc, so I decided to program my own window system with capability for all that stuff. Quite complex but really easy to program. Nearly as simple as GTK, well at least far better than Win32 API.

fox
02-23-2001, 01:22 AM
Yes any pseudo-code /code or suggestion will be fine - I'm using VC++ 6 WITH mfc (I hope that simplifies things http://www.opengl.org/discussion_boards/ubb/eek.gif )

[This message has been edited by fox (edited 02-23-2001).]

[This message has been edited by fox (edited 02-23-2001).]

chennes
02-23-2001, 06:12 AM
Originally posted by Michael Steinberg:
But can your draw rects simply over an opengl view? I always see flickering etc, so

I haven't had any problems with flickering, since for me the image is static when the tooltip is popped up - I'm sure it would flicker if I had to do buffer swaps or whatever, but my image only rotates/translates when the user grabs it with the mouse, so no tooltip displays then.

As for pseudo code, I really can't give you anything better than the breif description above if you're using Windows - I program for Unix/Linux, and the code isn't very portable.

Chris