[C++-sig] C++ float[4][4] in Python

Hans Meine hans_meine at gmx.net
Mon May 22 11:15:13 CEST 2006


On Saturday 20 May 2006 17:48, Mike Wyatt wrote:
> float[4][4] array, which I need to make available to my PyOpenGL calls
> (glLoadMatrix and glMultMatrix, specifically):
>
>     [snip]
>
> *I see two solutions to my problem:
> *
> 1) Find a way for Python to understand a float[4][4].
This will not work with PyOpenGL AFAICS.

> 2) Instead of allocating five tuples everytime the matrix changes, can I
> create my tuples in the class constructor, then simply set the values
> when necessary?
No, because Python tuples are immutable by definition.  (Actually, there is a 
hackish way to do so IIRC, but that's not the way to go, and PyOpenGL would 
still have to unpack the tuples.)

You will get best performance by exporting your own functions calling 
glMultMatrix with the data from your matrix directly.  It's perfectly fine to 
mix PyOpenGL with your own OpenGL calls (since OpenGL maintains just some big 
state machines).  You just have to link to the library and that's it.

Ciao, /  /                                                    .o.
     /--/                                                     ..o
    /  / ANS                                                  ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060522/063e5eb5/attachment.pgp>


More information about the Cplusplus-sig mailing list