PDA

View Full Version : vertexAttribPointer + stride + offest?



Sergejack
03-02-2012, 07:59 AM
vertexAttribPointer(uint index, int size, enum type,bool normalized, long stride, long offset)

Hello.

I'm trying figuring out what goes wrong when I try to call this method with a stride or offset <> 0.
Could it be that webGL doesn't allow us to use those 2 parameters?

Could anybody provide a short working code sample where stride and offset are set? (if the code is long you could put it on http://pastebin.com)

debinair
05-07-2012, 11:43 PM
Hi,
Please find the attached code.
static GLfloat vertices1[]={-0.8f,-0.8f, -0.8f,-0.2f, -0.8f,-0.2f, -0.2f,-0.8f, -0.2f,-0.8f, -0.2f,-0.2f,-0.2f,-0.8f, -0.8f,-0.2f , -0.2f,-0.2f, 0.0f,0.6f,-0.8f,-0.2f,0.0f,0.0f};

GLubyte buf[20],buf1[20];


glClearColor(0.0, 0.0, 1.0, 1.0); // R,G,B,A
glClear(GL_COLOR_BUFFER_BIT);


glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices1), vertices1,GL_STATIC_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer (2, GL_FLOAT, 4* sizeof(GLfloat), 0);

3rd argument is stride is mentioned in number of bytes.
PM me if you require any further help.