Why do i get these extra lines when loading objects ?
How are you drawing them (show code)?
void tris_indiced(float mesh[],int meshSize,unsigned int indices[],int indiceSize) {
glBufferData(GL_ARRAY_BUFFER, meshSize, mesh, GL_DYNAMIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indiceSize, indices, GL_DYNAMIC_DRAW);
glDrawElements(GL_TRIANGLES, indiceSize, GL_UNSIGNED_INT, NULL );
};
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
tris_indiced(sphere_vertices,sizeof(sphere_vertices),sphere_indices,sizeof(sphere_indices) );
This isn’t much code, but it’s enough to see one obvious mistake: indiceSize
cannot be the correct value for both glBufferData
and glDrawElements
. The former needs the size in bytes, the latter needs the number of indices.
Also:
Are sphere_vertices
and sphere_indices
arrays? You can’t use sizeof
on a pointer to a dynamically-allocated array as it will be equal to the size of the pointer. Maybe you’re aware of that, but it’s a pretty common mistake around here.
In any case, you shouldn’t be passing sizeof(sphere_indices)
to glDrawElements
as it needs the number of indices, not the size in bytes…
Problem Solved ! Thank You.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.