how to use glMultMatrixd without asserts

70 views
Skip to first unread message

robert

unread,
Dec 28, 2012, 9:34:14 PM12/28/12
to pyglet...@googlegroups.com
I am trying to uses pyODE together with pyglet (for 3d graphics).
pyODE conveniently keeps track of the location and rotation of objects for me.
So when it comes to drawing them I'd like to do something like:

pos = body.getPosition()
rot = body.getRotation()
matrix = [rot[0], rot[3], rot[6], 0.0,
             rot[1], rot[4], rot[7], 0.0,
             rot[2], rot[5], rot[8], 0.0,
             pos[0], pos[1], pos[2], 1.0]
   
glMultMatrixd(matrix)

When  I try this, I get the following error:
  glMultMatrixd(matrix)
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: expected LP_c_double instance instead of list

what is the right way to construct a matrix to be passed to   glMultMatrixd?

Cheers,
Robert

Tristam MacDonald

unread,
Dec 28, 2012, 10:08:07 PM12/28/12
to pyglet-users
You need to construct a ctypes array, rather than just a basic python array. Something like this:

ctypesMatrix = (c_double*16)(*matrix)

--
Tristam MacDonald
Software Development Engineer, Amazon.com
Reply all
Reply to author
Forward
0 new messages