Draw a mouse cursor!

Hi I am trying to draw a mouse cursor in opengl and was just woderning how to do.
Hope someone can help me.

Many Thanks
Pran

It depends on your operating system, if your using glut etc. The simplest method I can think of is this:
Somehow (either through the operating system or another api, such as glut) get the window coordinates of your mouse. Transform them to world coordinates with gluUnProject(look it up in google and in the red book, there’s an online version I believe) with a depth of z = 0.0. That should give you the world coordinates of the position of the mouse in the front clipping plane. After you have these, just create a function where you draw whatever you want (triangle, quad, texture quad) where the mouse coordinates are. I think this should do the trick. If you want more, try to give details of the operating system you’re using, any other api’s (glut, directx, win32 code etc.)

You can use a texture quad to create your second mouse cursor or could do both cursor’s with textured quads.

What you would do is create you cursors in a paint type program, then load them as textures. See nehe.gamedev.net for a tutor on textured quads.

Also if you have sent me an e-mail, I will not be able to respond to later since I am at work now.

Originally posted by pran1:
[b]Hi I am trying to draw a mouse cursor in opengl and was just woderning how to do.
Hope someone can help me.

Many Thanks
Pran[/b]

Originally posted by moucard:
…get the window coordinates of your mouse. Transform them to world coordinates with gluUnProject … with a depth of z = 0.0. That should give you the world coordinates of the position of the mouse in the front clipping plane. After you have these, just create a function where you draw whatever you want (triangle, quad, texture quad) where the mouse coordinates are. I think this should do the trick.

Uhm, this seems somewhat utterly overcomplicated to me. The Embedded User Interface in my technology does nothing of this.

I agree with NexusOne, using textured quads is probably the best way to get it running in short time. Since the topic is pretty simple, I won’t point you to a tutorial.
The way I use to draw the cursor, is to simply send 4 vertices to GPU with a texture on it. The cursor is drawn last (so it can be transparent - wow and the MVP is a ortho projection so position is actually very easy to compute. Actual Z position is always 0 for me.