[Pyrex] Function Pointer

Marco Bubke marco at bubke.de
Fri Mar 5 03:31:39 CET 2004


On Friday 05 March 2004 02:47, Greg Ewing wrote:
> Ok, the prototype is tesselator_vertex(void* vertex, void* tesselator)
> but I thought that it shloud be possible to pass python objects.
>
> It should be, but it's a bit tricky casting between Python
> objects and other pointer types, since it's not always
> obvious what Pyrex will do with the refcounts.

Oh, I don't need ref counting. There will be allways a ref to the object. 

> > Its not called. If the pointer is NULL there will be no call
> > too. Maybe thats the problem. If I look at the C-Code the pointer cast
> > looks like (void((*) ())).
>
> It looks right. The C compiler would be complaining if it
> weren't, anyway.

Ok.

> Whatever the problem is, I think it's outside of the code
> you posted. Maybe there's something about the way you're
> calling GLU that's preventing the callbacks being called.
> I'm not familiar with GLU in particular, but I know there
> are various places in OpenGL where you have to turn on
> certain options before other calls will have an effect.

Thats right for GL but GLU is different in this sense. There is 
gluEnable/gluDisable.
So far I can sure that I call gluTessVertex and Ther is a non NULL pointer to 
gluTessCallvbak it should be working. 

Ok. Maybe this is wrong:
C:
typedef struct GLUtesselator;

In Pyrex I have done:
cdef extern from "GL/glu.h":
  cdef struct GLUtesselator_
  ctypedef GLUtesselator_ GLUtesselator

Its right?

> Can you write a pure C program that does the equivalent
> things and make it call a callback?

The code is a one to one version of my C++ Project before. Its working without 
problems in C++.




More information about the Pyrex mailing list