Anyone knows how to hide/show mouse pointer under linux using opengl?

Started by
6 comments, last by doutmost 19 years, 5 months ago
I want to hide mouse pointer in my code, it is under linux and I used opengl.
Advertisement
In windows it's done with a windows call, not a gl one. Shouldn't there be a x function call for that?
so anyone knows the function for that? it doesnot matter opengl or linux. I got one for windows. it is showcursor, but didnot find the function for linux.
What are you using?
GLUT - glutSetCursor(GLUT_CURSOR_NONE); <--- maybe, not sure
SDL - SDL_ShowCursor(false);
--------------------------------------------------------Life would be so much easier if we could just get the source code.
I just want to hide cursor when I run a little game, but I can move cursor to operate a paddle. I will try the function you gave here, thanks.
Well you're not going to be able to hide the cursor on a system-wide level... so it's just for your window. Since there's no show/hide functions for cursors in xlib (if that's what you're using) ... then I'd imagine you have to create a new cursor 0x0 and replace your current cursor with it, then swap them when you want your cursor to be visible again.
/* vars to make blank cursor */Pixmap blank;XColor dummy;char data[1] = {0};Cursor cursor;/* make a blank cursor */blank = XCreateBitmapFromData (dpy, win, data, 1, 1);if(blank == None) fprintf(stderr, "error: out of memory.\n");cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);XFreePixmap (dpy, blank);


this makes you the cursor. then set it using this function
XDefineCursor(Display *display, Window w, Cursor cursor);


after you do not need the cursor anymore use this function. it will undo the last change done by XDefineCursor (thus do only use ONCE XDefineCursor and then XUndefineCursor):
XUndefineCursor(Display *display, Window w);


hope this helps.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

thank all your guys. I will try your different ideas.

This topic is closed to new replies.

Advertisement