Results 1 to 3 of 3

Thread: Problems with the simplest code with opengl

  1. #1
    Member Contributor
    Join Date
    Apr 2007

    Problems with the simplest code with opengl


    with the code below, that i copy from the first chapter of an openGL tutorial, i recieve this error message:

    error C2664: 'glutDisplayFunc': cannot convert parameter 1 from 'void (void)' to 'void(__cdecl *)(void)'

    #include <GL/glut.h>
    #define ANCHO 640
    #define ALTO 400

    void CALLBACK display_cb (void)
    glClear (GL_COLOR_BUFFER_BIT);

    void inicializacion (void)
    glClearColor (1.0, 1.0, 1.0, 0.0);
    glShadeModel (GL_FLAT);

    main (int argc, char** argv) {
    glutInit (&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (ANCHO, ALTO);
    glutCreateWindow ("Primer programa OpenGL");
    glutDisplayFunc (display_cb);


    return 0;

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    munich, germany

    Re: Problems with the simplest code with opengl

    maybe you should change

    void CALLBACK display_cb (void)


    void display_cb (void)

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006

    Re: Problems with the simplest code with opengl

    Just look for glutDisplayFunc in glut.h - you will find that it takes void(*)(void).
    Your compiler uses __cdecl by default so it added it when compiling glut.h, but you have bypassed this default setting in your function by using CALLBACK.

Similar Threads

  1. simplest but modular program made in OpenGl 2.0
    By dawudmaxx in forum OpenGL: Windows
    Replies: 2
    Last Post: 01-09-2014, 12:19 PM
  2. Replies: 4
    Last Post: 12-14-2005, 09:35 AM
  3. the simplest problem ever
    By completelyuniquename in forum OpenGL: User Software
    Replies: 1
    Last Post: 10-04-2004, 02:46 PM
  4. simplest shadows?
    By c_olin in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-25-2003, 12:12 AM
  5. Why I can't get through the simplest code??
    By job in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-10-2002, 10:22 AM

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