dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: OpenGL glutDisplayFunc()

  1. #1
    Join Date
    Mar 2004
    Location
    Germany
    Posts
    35

    OpenGL glutDisplayFunc()

    Hi there,

    I want to set the OpenGL paint function by calling
    Code:
    glutDisplayFunc( paintGL() )
    paintGL(void) returns void and includes glBegin() & glEnd() etc...

    My compiler (VC++ 6) says:
    "cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)"

    This project should be independant of MFC and MS specific functions. Calling
    Code:
    glutDisplayFunc( &paintGL() )
    does not change anything.

    This function looks like followed:
    Code:
    void View::paintGL(void)
    {
     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
     glLoadIdentity();
     gluLookAt(0,0,5,0,0,0,0,1,0);
     
     glBegin(GL_LINES);
      glVertex3f(-0.5,-0.5,0.0);
      glVertex3f(0.5,0.0,0.0);
      glVertex3f(0.0,0.5,0.0);
     
       glutSwapBuffers(); 
     glEnd();
     glFlush();
    }
    Do you have a clue what could be wrong?
    Thank you alot in advance!!

    Holger

  2. #2
    Join Date
    Apr 1999
    Location
    Potsdam
    Posts
    110

    Re: OpenGL glutDisplayFunc()

    glutDisplayFunc() is a C function which does not accept member functions (C++ calling conventions). Try making it a global function for testing purposes. Maybe making it static could solve the problem, but I'm not sure about this.

  3. #3
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: OpenGL glutDisplayFunc()

    Try:
    Code:
    glutDisplayFunc( &View::paintGL )
    Regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  4. #4
    Join Date
    Mar 2004
    Location
    Germany
    Posts
    35

    Re: OpenGL glutDisplayFunc()

    Thanks guys,

    I now declared them as static. That helped!

    Thanks alot!



    Holger

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)