sheam wrote:
> The following works, to draw a square:
> float a[] = {
> -1, 1, 0,
> 1, 1, 0,
> -1,-1, 0,
> 1,1,0,
> -1,-1,0,
> 1,-1,0,
> };
> glVertexPointer( 3, GL_FLOAT, 0, a );
> glDrawArrays( GL_TRIANGLES, 0, 6 );
>
> The following code has the same logic, but I have inserted an extra
> float between each vertex. I tell opengl by setting the stride to be
> sizeof(float). But the following make square scrambled.
> float a[] = {
> -1, 1, 0,
> 99,
> 1, 1, 0,
> 99,
> -1,-1, 0,
> 99,
> 1,1,0,
> 99,
> -1,-1,0,
> 99,
> 1,-1,0,
> 99,
> };
> glVertexPointer( 3, GL_FLOAT, sizeof(float), a );
> glDrawArrays( GL_TRIANGLES, 0, 6 );
>
> Thanks,
> ~S
Ok, I figure it out. stride is described in man page as bytes between.
But it is actually the number of bytes from start to start of next.
i.e., sizeof(float)*4 worked.
~S


|