PDA

View Full Version : Special mouse cursor implementation problem



01-22-2003, 06:33 AM
Hi,
I'm working on a special system that requiert to manipulate my own mouse
cursor. There is no way to use the regular displayed cursor. So, I do just
need to receive mouse events and display my own pointer. To resume what my
code does by now it's:
- Display an image bitmap on the screen...
- ...and on an mouse motion event:
- display background cursor pixels (with glDrawPixels)
- update mouse position
- read background pixel (with glReadPixels)
- display the mouse cursor

Because the only way to access the output buffer is with the glReadPixels
and glDrawPixels, I had no choice to initialize my window like that to
simultate pixels:
in the OnSize event handler:
glViewport(0, 0, cx, cy)

and before read and draw operations:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, m_oWndRect.right-1.0f, 0.0f,
m_oWndRect.bottom-1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);

Now the glReadPixels work but not the glDrawPixels. Depending on the mouse
position, sometime it still destroy the original bitmap like if the raster
operation have a rounding point problem. I say sometime because if the
cursor is at the left-bottom of my window, it works. But, if I move it to
the right-top, it begin to destroy my image from the center of the window.
That's why it seems to be a rounded problem in the raster module.

Thus anybody know about this problem and how I can fix it? I spent many
times on that stupid problem and my only way out it's to make it work. My
OpenGL program is developed with VC6 on Windows XP.


Tired to lose time,

Richard