Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: mouse input in Linux

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    Goleta, CA, USA
    Posts
    3

    mouse input in Linux

    Ok, I got the problem. I have a while loop in my display function. So all the mouse events are being buffered and my mouse() handling callback routine is called only when I get out of the while() loop.

    Is there any way that one can interrupt the display() routine and process mouse events ?

    THanks.

    Hi all,

    I am trying to capture mouse events in my OpenGL program but haven't been able to do so. I am running on Linux....following is how I am doing it.

    // In main()

    glutMouseFunc(mouse);

    // Mouse handling function

    void mouse(int button, int status, int x, int y)
    {
    //
    }

    Its as simple as that but I don't know why mouse clicks are not captured. Does this involve anything apart from what I am doing - e.g. setting the viewport(which I have done as well) etc.

    Please let me know if you know the reason..

    Thanks.

    [This message has been edited by blitz (edited 07-20-2003).]

  2. #2
    Member Newbie
    Join Date
    Aug 2003
    Location
    asda
    Posts
    47

    Re: mouse input in Linux

    Do other people codes like the one below works? http://www.lighthouse3d.com/opengl/glut/index.php3?9
    asd

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: mouse input in Linux

    Works fine for me in linux (Redhat 9.0), are you wanting to capture mouse clicks outside the window that you opened?

    Can you show us more of the code in your mouse(....) routine?


    Originally posted by blitz:
    Hi all,

    I am trying to capture mouse events in my OpenGL program but haven't been able to do so. I am running on Linux....following is how I am doing it.

    // In main()

    glutMouseFunc(mouse);

    // Mouse handling function

    void mouse(int button, int status, int x, int y)
    {
    //
    }

    Its as simple as that but I don't know why mouse clicks are not captured. Does this involve anything apart from what I am doing - e.g. setting the viewport(which I have done as well) etc.

    Please let me know if you know the reason..

    Thanks.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: mouse input in Linux

    Have not tryed his example, but I did not see any problem with the example.

    Originally posted by Some guy:
    Do other people codes like the one below works? http://www.lighthouse3d.com/opengl/glut/index.php3?9

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    Goleta, CA, USA
    Posts
    3

    Re: mouse input in Linux

    There isnt much in the mouse() handling function. I am just trying to write something to stdout to check whether I am able to capture mouse events. Since I am not checking for any conditions such as left button click etc, I am not even restricting it to certain events only. So whatever is there inside the mouse processing function should work. I am also not trying to capture clicks outside my display window. Don't know why its not working

    Originally posted by blitz:
    Hi all,

    I am trying to capture mouse events in my OpenGL program but haven't been able to do so. I am running on Linux....following is how I am doing it.

    // In main()

    glutMouseFunc(mouse);

    // Mouse handling function

    void mouse(int button, int status, int x, int y)
    {
    //
    }

    Its as simple as that but I don't know why mouse clicks are not captured. Does this involve anything apart from what I am doing - e.g. setting the viewport(which I have done as well) etc.

    Please let me know if you know the reason..

    Thanks.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: mouse input in Linux

    Don't you think that the function would work better if you had some code inside of it????

    From seeing your code you do nothing inside the mouse routine.

    Try this:

    void mouse(int button, int status, int x, int y)
    {
    //
    printf("mouse button = %d, status = %d, x = %d, y = %d /n", button, status, x, y);

    }

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    Goleta, CA, USA
    Posts
    3

    Re: mouse input in Linux

    Ok, I got the problem. I have a while loop in my display function. So all the mouse events are being buffered and my mouse() handling callback routine is called only when I get out of the while() loop.

    Is there any way that one can interrupt the display() routine and process mouse events ?

    THanks.


    Originally posted by blitz:
    Ok, I got the problem. I have a while loop in my display function. So all the mouse events are being buffered and my mouse() handling callback routine is called only when I get out of the while() loop.

    Is there any way that one can interrupt the display() routine and process mouse events ?

    THanks.

    Hi all,

    I am trying to capture mouse events in my OpenGL program but haven't been able to do so. I am running on Linux....following is how I am doing it.

    // In main()

    glutMouseFunc(mouse);

    // Mouse handling function

    void mouse(int button, int status, int x, int y)
    {
    //
    }

    Its as simple as that but I don't know why mouse clicks are not captured. Does this involve anything apart from what I am doing - e.g. setting the viewport(which I have done as well) etc.

    Please let me know if you know the reason..

    Thanks.

    [This message has been edited by blitz (edited 07-20-2003).]

  8. #8

    Re: mouse input in Linux

    What does the while loop do in the display function? Is it required for rendering or r u trying to block for input(which is very unlikely) ?

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: mouse input in Linux

    Using an endless loop in the display function isn't a very good practice. I'm assuming by saying you have a while() loop, you mean that it's endless, anyway.

    If you are trying to do animation, you should be using either a timer function or the idle function to post a new display message.

    VB 6, had a function called DoEvents that you could use to force processing of events if you absolutely HAD to have an endless loop, or a loop that took a lot of time somewhere. In the Win32 API, you could use the PeekMessage stuff to process messages within your while loop. Not sure what the equivalent is in Linux.
    Deiussum
    Software Engineer and OpenGL enthusiast

  10. #10
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: mouse input in Linux

    You don't want to be interrupting the display routine!

    The only thing that should be in your display routine is the drawing of the 3D scene. Any control functions should be done outside of the display routine.

    Can you explain more about what you are trying to do? This would help us give you a pointer on how it should be done.

    From what I see you don't have a mouse problem but a problem in how you are trying to write the program.

    Now also could be what you are trying to do can not be done using the GLUT library and you maybe will need to switch to another library for mouse input like SDL or use x-windows functions.


    Originally posted by blitz:
    Ok, I got the problem. I have a while loop in my display function. So all the mouse events are being buffered and my mouse() handling callback routine is called only when I get out of the while() loop.

    Is there any way that one can interrupt the display() routine and process mouse events ?

    THanks.



Page 1 of 2 12 LastLast

Similar Threads

  1. more than one mouse input
    By Unition in forum OpenGL: Windows
    Replies: 5
    Last Post: 04-09-2005, 02:18 AM
  2. mouse speed between sampled mouse input points
    By sunnymonk in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-06-2005, 09:43 AM
  3. Mouse Input
    By Alex Derby in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-24-2002, 12:37 PM
  4. Mouse Motion input
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-18-2002, 09:33 AM
  5. Do 3D input with the mouse?
    By Peter in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 07-09-2000, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean