Jump to content
  • Advertisement
Sign in to follow this  
reixons

OpenGL OpenGL to change mouse cursor image!

This topic is 3618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I want to change the mouse cursor image using OPENGL. Somebody told me to draw a quadric object (a plane) that will always remain in front of the camara, and load a texture on it. Does anyone know how to do it, or anywhere where I can get the proper information to do it? Thank you!

Share this post


Link to post
Share on other sites
Advertisement
The easiest way to do this, would be to switch your projection to orthographic projection ( http://en.wikipedia.org/wiki/Orthographic_projection ).

This allows you to translate objects in window co-ordinates (X,Y), which simplifies things a whole lot.

Switching to ortho projection is pretty straight forward in OpenGL:

//Set up an ortho projection with surface size width, height
void switchToOrtho(int width, int height)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, width, height, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}




Switching back is just a matter of rewinding the stack:

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();




So. To draw the cursor, simply call switchToOrtho() with the window size as arguments, then draw a quad with position equal to the cursor position. Remember to restore your projection mode afterwards. ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!