In this code snippet I will show how to draw a little mouse cursor in OpenGL. It will be the one you see here at the left. I will also show how to get the mouse position and to move the cursor accordingly. I will use the Win32 API but I think it should be possible to do the same in e.g. Linux or BeOS.
So lets directly go through the code. First we have to define a float-array. It will hold the current mouseposition.
Next we will create a function GetMouseInfo() that updates our array. This function will then be called every frame so that the mouse cursor is always at the right position.
Not much to say to this function.It calculates the new mouse position every frame. We will now come to the real code that draws the cursor. As the above function, it will be called every frame.
This function simply draws a lightgrey mousecursor at the current mouse position. The Z-Value will be ZOOM which is the depth of the whole screen. You could also use an orthogonal projection, but I prefer this method because you could now test if the cursor is inside an object.
Simply call these functions (GetMouseInfo() first) in your main loop and you will have a nice little cursor. Take a look at my little project Memory to see this cursor in action. Visit the message board if you have questions or simply mail me. Happy Coding!