J'ai un VBO et un IBO dans OpenGL, mais je n'arrive pas à les dessiner correctement. Pourriez-vous s'il vous plaît laissez-moi savoir ce que je pourrais avoir oublié dans la fonction d'affichage de trame? - struct Point3D est une structure avec 3 flottants à l'intérieur (x, y, z). - nbVertex est le nombre de vertex dans le tableau glVertex. - nbVBOInd est la quantité d'indices dans le tableau VBOInd.Impossible d'afficher VBO dans OpenGL
glGenBuffers(1, &VertexVBOID);
glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glBufferData(GL_ARRAY_BUFFER, sizeof(struct Point3D)*nbVertex, glVertex, GL_STATIC_DRAW);
glGenBuffers(1, &IndexVBOID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexVBOID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*nbVBOInd, VBOInd, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(glVertex), BUFFER_OFFSET(0)); //The starting point of the VBO, for the vertices
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexVBOID);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0)); //The starting point of the IBO
Merci!
Quelle version OpenGL vous générez votre contexte? – datenwolf
Désolé pour la question stupide: Comment puis-je le savoir? –
@Laurent Cela dépend de votre plateforme. Utilisez-vous QGLViewer ou glut ou autre chose? Habituellement fournit quelques commutateurs pour créer un contexte avec une version spécifique. – pmr