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

Thread: Glut callback functions & Wrappers

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    2

    Glut callback functions & Wrappers

    Hello everyone, i'm really disturbed with a issue that i'm working on since two or three days.
    Here is the context :

    Code :
    class MyClass {
      ...
    };
     
    MyClass::display(void) {
      ...
    }

    I'v a class MyClass, with a method display(). Then i'm declaring everything for my object that i call object. And what i want to do is some glutDisplayFunc(). So i'm using some wrappers to avoid errors of kind

    Code :
    void (*) () expected instead of void (MyClass::) ()

    .. here is a solution for people who were stucked there :

    Code :
    struct MyWrapper {
      static void display(void) {
         u->display();
      }
      static MyClass * u;
    };
     
    MyClass MyWrapper::u = 0;
     
    ...
     
    int main ( .. ) {
     
      ...
     
      MyWrapper::u = &object;
      glutDisplayFunc(MyWrapper::display);
     
      ...
     
    }

    Fortunately i'v passed this issue, but now what i want is implementing multiple MyClass objects in multiple windows..
    But modifying the structure by simply trying to make arrays of object or something like that will stuck because of we need a reference to the concerned object. (here is this version)

    I'v thought of functions pointers but i'v telled that it will not work.

    Thank you for your help.

    For the moment i'm using a limited amount of object wich should work until the amount of objects is not dynamically set ..
    Last edited by malikcpp; 06-13-2012 at 04:14 AM.

Tags for this Thread

Posting Permissions

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