🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Turning off mouse pointer in linux GLX examples

Started by
3 comments, last by GameDev.net 17 years, 12 months ago
I've asked this a few places but don't seem to be able to get an answer, can anyone tell me how to turn off the mouse pointer when the GLX examples go full screen. Thanks
Advertisement
You can use this :

void setVisible(bool visible){	if(!visible)	{		char data[] = {0};		Cursor cursor;		Pixmap blank;		XColor dummy;		blank = XCreateBitmapFromData(dpy, win, data, 1, 1);		cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);		XDefineCursor(dpy, win, cursor);		XFreePixmap(dpy, blank);		XFreeCursor(dpy, cursor);	}	else		XUndefineCursor(dpy, win);}
Thanks for that bannanajoe but I've got a few problems I hope you could explain.

I've made a few changes so it works with the nehe exaples ie put the screen stuff in a structure (GLWin) so I have

if(!visible)
{
char data[] = {0};
Cursor cursor;
Pixmap blank;
XColor dummy;
blank = XCreateBitmapFromData(GLWin.dpy, GLWin.win, data, 1, 1);
cursor = XCreatePixmapCursor(GLWin.dpy, blank, blank, &dummy, &dummy, 0, 0);
XDefineCursor(GLWin.dpy, GLWin.win, cursor);
XFreePixmap(GLWin.dpy, blank);
XFreeCursor(GLWin.dpy, cursor);
}

else
XUndefineCursor(GLWin.dpy, GLWin.win);

When I compile then run I get bad window. If I comment out the else bit it will run. However when I call the function the pointer is still there and the window locks, the mouse can still be used but I can't get out of screen (even kill won't work).

I think it may be due to my understanding of where to call the function. I call it directly
after createGLWindow(.. fucntion using 1 or 0 dont help
Strange...
Your modified code should work. I downloaded lesson 10, added your code
void setVisible(Bool visible){	if(!visible)	{		char data[] = {0};		Cursor cursor;		Pixmap blank;		XColor dummy;		blank = XCreateBitmapFromData(GLWin.dpy, GLWin.win, data, 1, 1);		cursor = XCreatePixmapCursor(GLWin.dpy, blank, blank, &dummy, &dummy, 0, 0);		XDefineCursor(GLWin.dpy, GLWin.win, cursor);		XFreePixmap(GLWin.dpy, blank);		XFreeCursor(GLWin.dpy, cursor);	}	else		XUndefineCursor(GLWin.dpy, GLWin.win);}

and I call "setVisible(False);" after "createGLWindow(...)" in the main function. Works fine with my SUSE 10 and Ubuntu 6.06 .
Thanks, it work, I had a bit of test code left from when I'd been getting it to work before. Sorry about that

This topic is closed to new replies.

Advertisement