grady
06-08-2001, 08:45 PM
I've been trying to make a quake3-like control interface for my programs without using glut. I took the glx NEHE tutorial #10 (the one where you move around in the room that has the face texture all over the walls.) and modified it so that the mouse makes you rotate about the up axis.
The problem is that its choppy. I suspect its the method I'm using for getting the mouse events. all i added to the tutorial was:
case MotionNotify:
mouseAction(event.xmotion.x, event.xmotion.y);
break;
to this larger part in "int main()" which is this:
while (!done)
{
/* handle the events in the queue */
while (XPending(GLWin.dpy) > 0)
{
XNextEvent(GLWin.dpy, &event);
switch (event.type)
{
case Expose:
if (event.xexpose.count != 0)
break;
drawGLScene();
break;
case ConfigureNotify:
/* call resizeGLScene only if our window-size changed */
if ((event.xconfigure.width != GLWin.width) | |
(event.xconfigure.height != GLWin.height))
{
GLWin.width = event.xconfigure.width;
GLWin.height = event.xconfigure.height;
printf("Resize event\n");
resizeGLScene(event.xconfigure.width,
event.xconfigure.height);
}
break;
/* exit in case of a mouse button press */
case ButtonPress:
done = True;
break;
case MotionNotify:
mouseAction(event.xmotion.x, event.xmotion.y);
break;
case KeyPress:
keys[event.xkey.keycode] = True;
break;
case KeyRelease:
keys[event.xkey.keycode] = False;
break;
case ClientMessage:
if (*XGetAtomName(GLWin.dpy, event.xclient.message_type) ==
*"WM_PROTOCOLS")
{
printf("Exiting sanely...\n");
done = True;
}
break;
default:
break;
}
}
the mouseAction function is simple; the if() basically keeps it from doing a 100 degree rotation in one frame. The if() only makes a difference when you move the mouse fast. Performace is still choppy at low speeds with or without it:
void mouseAction(int x, int y)
{
if((x-300 > -7)| |(x-300<7))
rotY -= (x-300)/7.0;
else
rotY -=1.0;
XWarpPointer(GLWin.dpy, None, GLWin.win, 0, 0, 0, 0, 300, 300);
}
If you know of some better way to get mouse info for doing a rotation please tell me. thanks. if you want my complete modified version of the lesson10.c so you can compile it and see for yourself what i'm talking about, I'll post it.
[EDIT]: Let me explain what i mean by choppy. I've played around with the thing for a while now and i'm sure its not the angle i'm rotating through or anything like that. It's choppy as in it looks like its running at 10 fps. But its not that because i can press the arrow button and it rotates as smoothly as possible. Its as if I only get a pointer motion event every now and then, and not whenever the mouse moves.
------------------------------------------------------
One more thing how do i make the pointer disapear?
[This message has been edited by grady (edited 06-08-2001).]
[This message has been edited by grady (edited 06-08-2001).]
The problem is that its choppy. I suspect its the method I'm using for getting the mouse events. all i added to the tutorial was:
case MotionNotify:
mouseAction(event.xmotion.x, event.xmotion.y);
break;
to this larger part in "int main()" which is this:
while (!done)
{
/* handle the events in the queue */
while (XPending(GLWin.dpy) > 0)
{
XNextEvent(GLWin.dpy, &event);
switch (event.type)
{
case Expose:
if (event.xexpose.count != 0)
break;
drawGLScene();
break;
case ConfigureNotify:
/* call resizeGLScene only if our window-size changed */
if ((event.xconfigure.width != GLWin.width) | |
(event.xconfigure.height != GLWin.height))
{
GLWin.width = event.xconfigure.width;
GLWin.height = event.xconfigure.height;
printf("Resize event\n");
resizeGLScene(event.xconfigure.width,
event.xconfigure.height);
}
break;
/* exit in case of a mouse button press */
case ButtonPress:
done = True;
break;
case MotionNotify:
mouseAction(event.xmotion.x, event.xmotion.y);
break;
case KeyPress:
keys[event.xkey.keycode] = True;
break;
case KeyRelease:
keys[event.xkey.keycode] = False;
break;
case ClientMessage:
if (*XGetAtomName(GLWin.dpy, event.xclient.message_type) ==
*"WM_PROTOCOLS")
{
printf("Exiting sanely...\n");
done = True;
}
break;
default:
break;
}
}
the mouseAction function is simple; the if() basically keeps it from doing a 100 degree rotation in one frame. The if() only makes a difference when you move the mouse fast. Performace is still choppy at low speeds with or without it:
void mouseAction(int x, int y)
{
if((x-300 > -7)| |(x-300<7))
rotY -= (x-300)/7.0;
else
rotY -=1.0;
XWarpPointer(GLWin.dpy, None, GLWin.win, 0, 0, 0, 0, 300, 300);
}
If you know of some better way to get mouse info for doing a rotation please tell me. thanks. if you want my complete modified version of the lesson10.c so you can compile it and see for yourself what i'm talking about, I'll post it.
[EDIT]: Let me explain what i mean by choppy. I've played around with the thing for a while now and i'm sure its not the angle i'm rotating through or anything like that. It's choppy as in it looks like its running at 10 fps. But its not that because i can press the arrow button and it rotates as smoothly as possible. Its as if I only get a pointer motion event every now and then, and not whenever the mouse moves.
------------------------------------------------------
One more thing how do i make the pointer disapear?
[This message has been edited by grady (edited 06-08-2001).]
[This message has been edited by grady (edited 06-08-2001).]