On Jan 14, 2008 9:53 PM, jimknopf <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am currently playing with PyGlet in combination with Box2d (physics
> engine). I want to parse SVG like pathes (polygons) for both, Box2D
> and game graphics. My problem is, that Box2D only accepts convex
> polygons, which is why I need some kind of simple polygon
> decomposition / triangulation algorithm.
>
> As far as I have undestood, GLU offers triangulation using the
> tesselator module. And PyGlet offers GLU bindings.
>
> What I tryed:
>
> points = ([0.0,0.0,0.0],[10.0,0.0,0.0],[0.0,10.0,0.0],)
> tess = gluNewTess()
> gluTessBeginPolygon(tess, None)
> gluTessBeginContour(tess)
> for point in points:
>     gluTessVertex(tess, point, point)
> gluTessEndContour()
> gluTessEndPolygon()
>
> What Python thinks about my code:
>
> "[...]
> Traceback (most recent call last):
>   File "Bezier.py", line 123, in <module>
>     space.main_loop()
>   File "Bezier.py", line 101, in main_loop
>     gluTessVertex(tess, point, point)
> ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>:
> expected LP_c_double instance instead of list"
>
> To be honest, I have not worked with OpenGL before, which is why I do
> not know, whether this is a PyGlet problem or something else (maybe I
> simply misundestood the whole Tesselator thingy). But it sounds like a
> problem with the GLU bindings.

You'll need to construct ctypes arrays to pass to these functions.
See the ctypes documentation for a good tutorial.  For now, this
should get you started:

import ctypes
points = ([0.0,0.0,0.0],[10.0,0.0,0.0],[0.0,10.0,0.0],)
points = [(ctypes.c_double * len(v))(*v) for v in points]

Alex.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to