Skip to main content
gamedev.net
🔒 Locked

Tooltip question

Started by fcoutel Nov 30, 2005 at 10:11 PM 2 replies 1.8k views
Original Post
fcoutel
fcoutel
Hi, In my OGL scene I have some objects and I know their name. What I would like to do is some kind of Tooltip i.e draw a rectangle with the object's name when I hover on it with the mouse. Would someone have some example source code for doing this? Many thanks!
Nairb
Nairb
Determining if you're hovering over the object is the trickiest part. You should be able to do it with "Picking", though. Check out nehe or the redbook - they both have examples of how to do this.

After you've done that, you can simply draw a quad with some text inside it above the object to show the tooltip.

Cheers,
--Brian
fcoutel
fcoutel
Ok but I need to draw the rectangle in orthographic proj I think? Would you have an example on how to do this?

Thanks!
Ademan555
Ademan555
just use glOrtho()

Note the part that says "typically the matrix mode is GL_PROJECTION", you probably already know that, but then again it probably didnt hurt to reiterate :-).

so to draw in orthographic mode you want something like:

glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho(0, 640, 0, 480, -1, 1);//this describes a matrix where the viewport covers a 640 x 480 rectangle//where the upper left hand corner is the point <0,0>//wheras glOrtho(0, 640, 480, 0, -1, 1);//would describle a matrix where the lower left hand corner is the point <0,0>//(note the -1, 1) this affects the depth buffer, i'll assume you know a bit about it//this means that things will be drawn from z=-1 to z=1, but since you're drawing//in 2d anyways chances are z will be 0//Drawing CodeglPopMatrix();


hope that helps
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.