Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: mouse function

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    10

    mouse function

    Greetings,

    In my program, i've coded the mouse function, but it works after a while. I've coded that the left mouse button zoom in the screen, but it wait the redisplay to zoom in. Thats not what i want to do, i want that as soon as the user click the left button it zooms in.

    In the idle function i read a matrix on a socket but need the socket to be non-blocking, so i loop in there until i get a valid matrix on the socket. but it waits until i get a valid matrix to zoom in.

    so what do i have to do to make sure it performs the mouse function as soon as the user clicks the mouse button?

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2004
    Posts
    322

    Re: mouse function

    I've coded that the left mouse button zoom in the screen, but it wait the redisplay to zoom in. Thats not what i want to do, i want that as soon as the user click the left button it zooms in.
    Either you're not triggering a redisplay when the mouse button is clicked, or you're waiting for the mouse button release and want to start zooming as soon as the button is pressed.
    I can't say anything more, since your description is not very clear. Are you using GLUT? Windows? X-Windows?

    In the idle function i read a matrix on a socket but need the socket to be non-blocking, so i loop in there until i get a valid matrix on the socket. but it waits until i get a valid matrix to zoom in.
    I have no idea what socket communications have to do with mouse input. But if you want communications to be asynchronous with the user interface and possibly other logic, you could always use a separate thread, that can block to its heart's delight.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    10

    Re: mouse function

    i am using Glut.

    i am not waiting the button to be released.

    to make things clearer:
    in my idle function:
    i loop until the matrix i receive on a socket is valid. so it seems it blocks there.

    in this loop is there a GL call i can use to check if there was a mouse or a keyboard entry?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    664

    Re: mouse function

    i don't think so.

    but you could set flags (global variables) in your mouse/keyboard functions and check them in your idle func.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    10

    Re: mouse function

    Originally posted by RigidBody:
    i don't think so.

    but you could set flags (global variables) in your mouse/keyboard functions and check them in your idle func.
    i've tried that, doesn't seem to work

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    664

    Re: mouse function

    where do you clear the flag?

    for example, you should set a flag to show that mouse button one is pressed in the button func and clear the flag in your idle func. if you clear the flag in a separate button release func, it may be unnoticed by the idle func.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: mouse function

    maybe like that:

    have a matrix M (representing the default view).
    make your view regarding M, always.
    look periodically (with glutTimerFunc) if you got a new matrix threw your socket, if so affect it to M.
    idle function can do the calculations, essentially for the zoom and the animation.

    Your socket must be non-blocking I guess because glut doesn't know parallelism.

    Hope this helps.

  8. #8
    Junior Member Newbie
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    10

    Re: mouse function

    Thanks, the glutTimerFunc is really helpful!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •