Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Draw a mouse cursor!

  1. #1
    Intern Newbie
    Join Date
    Feb 2004
    Posts
    45

    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

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    368

    Re: Draw a mouse cursor!

    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.)

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: Draw a mouse cursor!

    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:
    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

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    628

    Re: Draw a mouse cursor!

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •