#include "mesh.h" #include #include #include pMesh creerMesh (char *nomFich) { /*****************************/ /* A coder par les etudiants */ /*****************************/ } void afficheMesh (pMesh mesh) { /***********************************************************/ /* Les lignes commentees dans cette fonction sont a * * decommenter lorsque le calcul des normales est effectue */ /***********************************************************/ glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mesh->mat_ambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mesh->mat_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mesh->mat_specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mesh->mat_shininess); glBindBuffer(GL_ARRAY_BUFFER, mesh->idBufferSommets); glVertexPointer( 3, GL_FLOAT, 0, NULL); /* glBindBuffer(GL_ARRAY_BUFFER, mesh->idBufferNormales); */ /* glNormalPointer (GL_FLOAT, 0, NULL); */ glEnableClientState(GL_VERTEX_ARRAY); /* glEnableClientState(GL_NORMAL_ARRAY); */ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->idBufferIndex); glDrawRangeElementsEXT(GL_TRIANGLES, 0, mesh->nbSommets-1, mesh->nbIndex, GL_UNSIGNED_INT, NULL); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glDisableClientState(GL_VERTEX_ARRAY); /* glDisableClientState(GL_NORMAL_ARRAY); */ glPopMatrix(); } void creerMeshVBO (pMesh mesh) { /***********************************************************/ /* Les lignes commentees dans cette fonction sont a * * decommenter lorsque le calcul des normales est effectue */ /***********************************************************/ glGenBuffers(1, &(mesh->idBufferSommets)); /* glGenBuffers(1, &(mesh->idBufferNormales)); */ glGenBuffers(1, &(mesh->idBufferIndex)); glBindBuffer(GL_ARRAY_BUFFER, mesh->idBufferSommets); glBufferData(GL_ARRAY_BUFFER, mesh->nbSommets*3*sizeof(float), mesh->sommets, GL_STATIC_DRAW); /* glBindBuffer(GL_ARRAY_BUFFER, mesh->idBufferNormales); */ /* glBufferData(GL_ARRAY_BUFFER, mesh->nbSommets*3*sizeof(float), mesh->normales, GL_STATIC_DRAW); */ glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->idBufferIndex); glBufferData(GL_ELEMENT_ARRAY_BUFFER, mesh->nbIndex*sizeof(GLuint), mesh->index, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }