0

i'm trying to render some mesh with a single texture on it, and the result is weird maybe because the stride parameter of the UVs data are incorrects.

i have omitted glGenBuffers and binding calls.

i have data packed in this manner:

float (*vertices)[3];     //list of vertices
int   nvertices;
unsigned int (*indices)[3]; //one row define indices for a triangle
int   nindices;
float (*texuv)[6];          //one row defines 3 UVcoord for the 3 triangle vertices

i set up data:

  glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*nvertices, vertices, GL_STATIC_DRAW);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(float)*nindices*3, indices, GL_STATIC_DRAW);
  glBufferData(GL_ARRAY_BUFFER, sizeof(float)*nindices*6, texuv, GL_STATIC_DRAW);

i draw it:

glVertexAttribPointer(position_slot,3,GL_FLOAT,GL_FALSE,sizeof(float)*3,0);
glVertexAttribPointer(texcoord_slot,2,GL_FLOAT,GL_FALSE,sizeof(float)*6,0);

glDrawElements(GL_TRIANGLES,nindices*3,GL_UNSIGNED_INT,0);

but the result seems a bit strange at texture level...

would you suggest me how to submit my UVs data to the shader or how to reformat in in a more utilitaristic way?

freesoft
  • 57
  • 7
  • The stride should be 0 since these are not interleaved arrays (at least I think, I cannot tell what language this is written in, it looks a little like C). You should also be binding a separate VBO before each call to `glBufferData (...)` and `glVertexAttribPointer (...)`, unless you switch to interleaved arrays. In which case, you will have to send the entire buffer in one call or use `glBufferSubData (...)`. – Andon M. Coleman Nov 20 '13 at 02:50
  • Language is c++.IUSE a separate VBO, i have written only sensible lines. – freesoft Nov 20 '13 at 08:49

0 Answers0