Thanks that's really helpful :) I've been trying to get matices working for ages.
On Fri, Oct 19, 2012 at 4:55 AM, Adam Griffiths <[email protected] > wrote: > FYI, I also create my own Matrices. > You can find all my code here: > > https://github.com/adamlwgriffiths/PyGLy > > The matrix code can be found here: > https://github.com/adamlwgriffiths/Pyrr > https://github.com/adamlwgriffiths/Pyrr/blob/master/pyrr/matrix.py > https://github.com/adamlwgriffiths/Pyrr/blob/master/pyrr/matrix33.py > https://github.com/adamlwgriffiths/Pyrr/blob/master/pyrr/matrix44.py > > Examples of their usage (for OpenGL 2.1) can be found here: > > https://github.com/adamlwgriffiths/PyGLy/blob/master/pygly/examples/legacy/simple/main.py > > And the actual opengl calls here: > > https://github.com/adamlwgriffiths/PyGLy/blob/master/pygly/gl/legacy/__init__.py > > Cheers, > Adam > > On Friday, October 19, 2012 2:52:09 AM UTC+11, Adam Griffiths wrote: >> >> You can convert to the appropriate data type by using this convension >> >> >>> from pyglet.gl import * >> >> # single values >> >>> a = (GLfloat)(1.0) >> >>> a >> c_float(1.0) >> >> # arrays >> >>> data = [1.0, 2.0, 3.0] >> >>> a = (GLfloat * len(data))(*data) >> >>> a >> <__main__.c_float_Array_3 object at 0x106078e60> >> >> # numpy (nicer than arrays >> >>> import numpy >> >>> data = numpy.array([1.0, 2.0, 3.0]) >> >>> a = (GLfloat * data.size)(*data) >> >>> a >> <__main__.c_float_Array_3 object at 0x108931b90> >> >>> for val in a: print val >> ... >> 1.0 >> 2.0 >> 3.0 >> >> >> Be aware that using len(list) will only get you the first dimension. >> This is why I prefer numpy, as you can simply use 'data.size' to get the >> entire size of the array. >> >> Eg. >> >>> a = [[1,2,3],[4,5,6]] >> >>> len(a) >> 2 >> >>> a = numpy.array( a ) >> >>> len(a) >> 2 >> >>> a.size >> 6 >> >> This also applies for textures. >> I've seen a lot of code converting numpy arrays to strings and then >> passing that to the image.set_data functions. >> Don't do this! >> Just pass a data array in the proper format. >> >> >> >> Hope this helps =) >> >> Cheers, >> Adam >> >> >> On Thursday, October 11, 2012 9:10:05 AM UTC+11, Wallace Davidson wrote: >>> >>> Thanks :) >>> >>> On Thu, Oct 11, 2012 at 11:07 AM, Adam Bark <[email protected]> wrote: >>> >>>> On 10/10/12 22:44, Wallace Davidson wrote: >>>> >>>> That sounds good then :) It can be used with pyglet can't it? >>>> >>>> On Thu, Oct 11, 2012 at 10:38 AM, Adam Bark <[email protected]> wrote: >>>> >>>>> On 10/10/12 22:11, Wallace Davidson wrote: >>>>> >>>>> I heard it was slower :/ would it be much different? >>>>> >>>>> On Thu, Oct 11, 2012 at 10:09 AM, Adam Bark <[email protected]>wrote: >>>>> >>>>>> On 10/10/12 21:59, Wallace Davidson wrote: >>>>>> >>>>>>> Thanks that does help :) Would you know how I can get a python >>>>>>> matrix usable in opengl? :/ It just says "expected LP_c_float instance >>>>>>> instead of matrix" when I try use a numpy one :( >>>>>>> >>>>>>> If you want to use numpy matrices and opengl then get pyopengl, >>>>>> it's a nicer library anyway as you don't have to mess around with ctypes. >>>>>> >>>>>> >>>>>> If you're using core opengl it shouldn't make much difference as >>>>> you won't need to make many calls, immediate mode is where you might find >>>>> some slowdown. I use it personally and haven't had any performance issues >>>>> that weren't related to either poor programming on my part or my >>>>> incredibly >>>>> old graphics card (NVidia 7950GT). >>>>> -- >>>>> >>>> Yes, that's what I'm using. Just post if you need any pointers. >>>> -- >>>> 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. >>>> >>> >>> -- > You received this message because you are subscribed to the Google Groups > "pyglet-users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/pyglet-users/-/ChaQTArGS38J. > > 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. > -- 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.
