Re: [PyOpenGL-Users] constructing a VBO containing mixture of floats, ubytes, etc
Brought to you by:
mcfletch
|
From: Nicolas R. <Nic...@in...> - 2011-02-03 18:23:09
|
Yes you can (see numpy record arrays)
Z = numpy.zeros(100,
dtype = [('position','f4',3)), ('normal','f4',3), ('color','uint8',4)] )
(see example posted previously).
Nicolas
On Feb 3, 2011, at 6:49 PM, Stephen Hopkins wrote:
> I dont think its possible to have 2 different data types in the same array. IF you've been using Numpy, each array has a type like float32,
>
> zeros(3 * numVertices + 4 * numVertices , dtype=float32)
>
> you could make 2 vbos and bind 2 vertexAttribPointers
>
> colorVBO = zeros(4 * numVertices, dtype="whatever is unsigned byte")
> vertexVBO = zeros(3*numVertices, dtype="float32")
>
> On Thu, Feb 3, 2011 at 3:49 AM, Jonathan Hartley <ta...@ta...> wrote:
> Hey,
>
> I am using vbo.VBO, constructed using a single array of (position,
> color, normal) - all floats. This looks like:
>
> self.vbo = vbo.VBO( array( list(
> list(chain(v, c, n))
> for v, c, n in zip(verts, colors, normals)
> ),
> 'f'
> ),
> usage='GL_STATIC_DRAW'
> )
>
> where verts, colors, normals are each generator expressions containing
> named tuples of (x, y, z) or (r, g, b), etc.
>
> My problem is that I want to try out converting the colors to unsigned
> bytes instead of floats. When I was using vertex arrays instead of VBOs,
> using unsigned bytes gave me something like 25% better framerates on my
> hardware (2004 era laptop with ATI), purely from increased rendering speeds.
>
> Does it sound likely that I'll see this sort of improvement on other
> hardware too? Or should I just stick with using colors as floats throughout?
>
> If I do go ahead, I'm not certain how to construct the vbo containing
> mixed types like this. Is there anything in OpenGL.arrays that might
> help, or do I need to brush up on my ctypes-fu to construct an array of
> structs manually?
>
> I'm happy that I do understand how to assign the vertex attribute
> pointers once the vbo is constructed.
>
> Jonathan
>
> --
> Jonathan Hartley Made of meat. http://tartley.com
> ta...@ta... +44 7737 062 225 twitter/skype: tartley
>
>
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> PyOpenGL Homepage
> http://pyopengl.sourceforge.net
> _______________________________________________
> PyOpenGL-Users mailing list
> PyO...@li...
> https://lists.sourceforge.net/lists/listinfo/pyopengl-users
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d_______________________________________________
> PyOpenGL Homepage
> http://pyopengl.sourceforge.net
> _______________________________________________
> PyOpenGL-Users mailing list
> PyO...@li...
> https://lists.sourceforge.net/lists/listinfo/pyopengl-users
|