Talk About Network

Google





Graphics > OpenGL 3D API > Re: glDrawArray...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 4754 of 5061
Post > Topic >>

Re: glDrawArrays, seems to ignore stride parameter?

by sheam <shea08@[EMAIL PROTECTED] > May 18, 2008 at 10:54 PM

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
 




 3 Posts in Topic:
glDrawArrays, seems to ignore stride parameter?
sheam <shea08@[EMAIL P  2008-05-18 22:52:14 
Re: glDrawArrays, seems to ignore stride parameter?
sheam <shea08@[EMAIL P  2008-05-18 22:54:40 
Re: glDrawArrays, seems to ignore stride parameter?
crjjrc <crjjrc@[EMAIL   2008-05-19 05:26:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 14:51:10 PST 2009.