Tessellation problem

In my code,I need to draw some complex polygons. I tried for tessellation. While compiling ,I got the following error. This is the first time I’m trying for tessellation. Pls guide me…

error C2664: ‘gluTessCallback’ : cannot convert parameter 3 from ‘void (__cdecl *)(void)’ to ‘void (__stdcall *)(void)’
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Hi !

The callback function must be a C function (use a .c file or extern “C” { code }).

Just make sure your callback is correct and then you may need to typecast it to void function with void arguments, this is because the gluTessCallback function must handle callback functions with different arguments so they made it void in the declaration.

Mikael

example:


#ifndef CALLBACK
#define CALLBACK
#endif
 
void CALLBACK begin(GLenum type)
{
    // do something useful
}
 
 
// later in some function
gluTessCallback(tess, GLU_TESS_BEGIN, (void(CALLBACK*)(void))begin );  
 

the trick is to cast all your functions with (void(CALLBACK*)(void)).

or, if you prefer readability:

#ifndef CALLBACK
#define CALLBACK
#endif
 
typedef void(CALLBACK *TessCallbackType)(void);
 
void CALLBACK begin(GLenum type)
{
    // do something useful
}
 
// later in some function
gluTessCallback(tess, GLU_TESS_BEGIN, (TessCallbackType)begin ); 
 

Originally posted by <stubs>:
[b]or, if you prefer readability:

#ifndef CALLBACK
#define CALLBACK
#endif
 
typedef void(CALLBACK *TessCallbackType)(void);
 
void CALLBACK begin(GLenum type)
{
    // do something useful
}
 
// later in some function
gluTessCallback(tess, GLU_TESS_BEGIN, (TessCallbackType)begin ); 
 

[/b]

Thank u so… much for ur reply. I got it!!

Originally posted by <stubs>:
[b]or, if you prefer readability:

#ifndef CALLBACK
#define CALLBACK
#endif
 
typedef void(CALLBACK *TessCallbackType)(void);
 
void CALLBACK begin(GLenum type)
{
    // do something useful
}
 
// later in some function
gluTessCallback(tess, GLU_TESS_BEGIN, (TessCallbackType)begin ); 
 

[/b]