PDA

View Full Version : TexCoord



Jeffg
03-18-2010, 12:15 PM
I'm trying to convert a display list into a VBO.

I currently make a call like this...

glTexCoord4f(x, y, z, w );
glVertex2f( -1.0f, -1.0f );
glVertex2f( +1.0f, -1.0f );
glVertex2f( +1.0f, +1.0f );
glVertex2f( -1.0f, +1.0f );

I having trouble translating this into VBO. Help

glBindBuffer( GL_ARRAY_BUFFER, xyzw[0] );
glTexCoordPointer(4,GL_FLOAT,0,0);
glBindBuffer( GL_ARRAY_BUFFER, quad[0] );
glVertexPointer(2,GL_FLOAT,0,0);
gl.glDrawArrays(GL.GL_QUADS,0,0);

Oh.. I'm also not particular about the quad and would prefer a point sprite.. if that's easier and more efficient.

Rosario Leonardi
03-18-2010, 02:46 PM
you have first need to fill the buffer with your data.
You can use one buffer object for each attribute or a single buffer object for every attribute.
This tutorial should be ok.
http://www.songho.ca/opengl/gl_vbo.html

Then your code is almost ok.
Remember
A: All vertex attribute must have the same lenght, so if you have 4 vertex, you also need 4 vertex coordinate.
B: The last parameter of drawArrays is the number of item you want to draw, in this case one quad.