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 5 of 5

Thread: WHY???

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    7

    WHY???

    Hi programmer people!
    I excuse me first of all for my bad english my mother speech is italian....
    I want to know WHY can i not write the following commands ins a opengl c based source code:


    glutIdleFunc(CalledFunction(PassedValue));
    or
    the same with
    auxMouseFunction(MouseFunction(PassedValue));

    why can i not give values trough a callback of function for example as glutIdleFunction???
    I can only do that?:

    glutIdleFunction(CalledFunction);

    void CalledFunction(void);

    ???????
    The called function MUST be void???? ok thank to all and good evening opengl people!!!!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: WHY???

    You can pass something like :

    glutIdleFunction(CalledFunction);
    int CalledFunction(void);

    but the returned integer will be ignored.

    And you can pass that :
    glutIdleFunction(CalledFunction);
    void CalledFunction(int value);

    but it is meaningless because nobody/nothing will pass the argument 'value', and moreover may screw up the stack (but the stack may be safe on some compilers and/or processors).

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    7

    Re: WHY???

    Thank for the fast answer!!
    But my problem is how can i call with glutIdleFunction another Function and pass to that dunction a value? there is no way??
    Should i make the value global? is that the only way??thanks

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: WHY???

    i'm not sure why you'd want to pass anything to the idle func. if you need to access some data, just make the variable global. or if you don't like to use globals, wrap up the glut interface into a class, and make some static member variables to hold the data your idle func needs.

    b

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

    Re: WHY???

    Functions that are used to set callback functions like glutIdleFunction take in a function pointer. That function pointer needs to point to a function with a specific prototype.

    Some functions like the Win32 Threading functions allow you to pass extra information that will be passed to the callback function, but cases like that are still very specific to how it is used.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

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