How to correctly submit data with stride parameter
-
31-07-2022 - |
Question
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?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow