Thanks for all the responses, they are all extremely helpful.

It surprised me to hear that a single VBO can't hold different data types. SuperBible tentatively confirms what Steve says. Page 485 (5th ed.):
It is also possible to store several different attributes in a single buffer by interleaving them. To do this, call glVertexArrayPointer with the stride param set to the distance (in bytes) between attributes of the same type.
(Emphasis mine) All of the subsequent examples use VBOs filled exclusively with floats - although sometimes vec4s of float interleaved with vec3s of float. Is that a confirmation, or am I reading too much into it?

If I manage to try it out I'll report back how it goes, but I have more urgent fish to fry for today, because , as Ian suggested early on, it probably doesn't reap the performance gain I was hoping for, so I'll stick with colors as floats for now.

Thanks all round, especially to Nicolas whose code I'm greedily poring over.

    Jonathan


On 03/02/2011 18:23, Nicolas Rougier wrote:

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 <tartley@tartley.com> 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
tartley@tartley.com   +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
PyOpenGL-Users@lists.sourceforge.net
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
PyOpenGL-Users@lists.sourceforge.net
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 PyOpenGL-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyopengl-users

-- 
Jonathan Hartley      Made of meat.      http://tartley.com
tartley@tartley.com   +44 7737 062 225   twitter/skype: tartley