Jump to content
  • Advertisement
Sign in to follow this  
reixons

OpenGL OpenGL to change mouse cursor image!

This topic is 3677 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!