Results 1 to 6 of 6

Thread: Wrong function prototype in gluTessCallback

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    7

    Wrong function prototype in gluTessCallback

    Hi guys, I am trying to compile the red book's
    example of tessellation but I keep getting errors like with this code

    Code :
    gluTessCallback(tobj, GLU_TESS_BEGIN, glBegin);

    Code :
    error: invalid conversion from ‘void (*)(GLenum)’ to ‘void (*)()’

    Doesn't glBegin have the exact function prototype that gluTessCallback is supposed to accept when we use GLU_TESS_BEGIN ?

  2. #2
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Wrong function prototype in gluTessCallback

    Quote Originally Posted by Felipe R.
    Doesn't glBegin have the exact function prototype that gluTessCallback is supposed to accept when we use GLU_TESS_BEGIN ?
    I don't think so... I think you have to define those fuctions...

    Code :
    void CALLBACK beginCallback(GLenum which)
    {
       glBegin(which);
    }

    Code :
    gluTessCallback(tobj, GLU_TESS_BEGIN, (void(__stdcall*)())beginCallback);

    I think this way it will work...
    "If you can't be a good example, you'll have to serve as a good warning..."

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    7

    Re: Wrong function prototype in gluTessCallback

    It did! (sort of...)

    I'm using linux so I had to define CALLBACK and change
    (void(__stdcall*)()) to (void(CALLBACK*)()) it occurred to me because I saw somewhere that windows define CALLBACK as __stdcall but to be honest with you I'm not certain why I have to cast the function argument, (that is a casting right?).

    Edit:
    In fact it seems that the casting is the problem because this code compiles:

    Code :
    gluTessCallback(tobj, GLU_TESS_BEGIN, (void(*)())glBegin);

    I didn't say I was using a g++ because I thought any C code compiled under a C++ compiler but I just checked and if I use gcc it works without casting.

  4. #4
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Wrong function prototype in gluTessCallback

    I thought that you had to define the callback function because of the parameter... But it seems you don't have to xD

    Well, glad I could "help" (sort of)

    And yes, that's casting ^^
    "If you can't be a good example, you'll have to serve as a good warning..."

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    7

    Re: Wrong function prototype in gluTessCallback

    You REALY helped. thanks.
    but do you know why the casting is necessary in C++ and not in C?
    I hate when something works but I don't know why it works.

  6. #6
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Wrong function prototype in gluTessCallback

    I'm not sure but when I had the same problem as you were having I remember that I read somewhere that these callbacks had to be "casted" only in C++ because of some compatibility problem that C++ has with these callbacks...

    But I'm not sure if what I'm saying is correct...

    Anyway, if you google it and search for a while, maybe you'll be able to find the answer... If I had time to do that, I would, but I don't have xD

    So, if you search and find something, please let me know
    "If you can't be a good example, you'll have to serve as a good warning..."

Similar Threads

  1. What's wrong with glut function?
    By Debugger in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-21-2007, 05:54 PM
  2. gluTessCallback function
    By pifaf in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2005, 08:46 AM
  3. what's wrong in this function ? (keyboard)
    By airseb in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-03-2002, 10:08 AM
  4. The problem of callback function gluTessCallback
    By Andyxia in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-01-2002, 07:33 PM
  5. how to use gluTessCallback function in c++?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-04-2000, 05:14 PM

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