AnsweredAssumed Answered

problem with glDrawArrays

Question asked by tonyo_au on Jan 29, 2012
Latest reply on Feb 9, 2012 by tonyo_au

Hi All,

I have posted this on the beginners forum in OpenGl but thought it might be better here


I have a problem I do not understand. The following code works in a simple test program on AMD - in a more complex program something is affecting glDrawArrays offset index.


The code works correctly in both programs on nVidia


glGenBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
glVertexAttribPointer(VERTEX_BINDINGS_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(C3D_VertexC), 0);
glVertexAttribPointer(VERTEX_BINDINGS_COLOUR, 4,GL_UNSIGNED_BYTE, GL_TRUE,sizeof(C3D_VertexC),(const void*)(sizeof(float)*3));     
  C3D_VertexC v[20];
  for (int i = 0; i < 5; i++)
    float x = (float)i;
    v[i].x = (x-10.0f)/10.0f;
    v[i].y = 0;
    v[i].z = 0;
    v[i].rgba = 255;
  glBufferData(GL_ARRAY_BUFFER, sizeof(C3D_VertexC)*20, NULL, GL_STATIC_DRAW);


// this draws the 5 points in  the correct location on the screen
// glBufferSubData(GL_ARRAY_BUFFER, sizeof(C3D_VertexC)*12, // sizeof(C3D_VertexC)*5, v);


// all verices drawn at 0,0,0 in black
  glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(C3D_VertexC)*5, v);


glDrawArrays(GL_POINTS, 0, 5);
glBindBuffer(GL_ARRAY_BUFFER, 0);


What can affect the first vertex used in glDrawArrays?