Bonjour @ tous,

Développant actuellement un projet en cours, je souhaite utiliser un VBO + IBO.

J'ai analyser plusieurs fois mon code et je ne vois pas l'erreur.
Aucune erreur OpengL, et aucune erreur de compilation, mais le résultat est un bel écran noir!

Création VBO
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
float longueur = 10.f;
 
        Vector3 Vertices[nb_point_par_ligne*nb_point_par_ligne];
        for(float ii=0,i=-longueur/2; i<longueur/2; i+=(longueur/nb_point_par_ligne), ii++)
            for(float jj=0,j=-longueur/2; j<longueur/2; j+=(longueur/nb_point_par_ligne), jj++)
                Vertices[(int)(ii*nb_point_par_ligne+jj)]=Vector3(i,j,0.f);
float tmp[nb_point_par_ligne*nb_point_par_ligne*3];
            for(int i=0;i<nb_point_par_ligne*nb_point_par_ligne ;i++)
        for(int j=0;j<3;j++)
            {
            tmp[i*3+j]=Vertices[i][j];
        }
    glGenBuffers(1, &VBO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(tmp), tmp, GL_STATIC_DRAW);
Création IBO
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
unsigned int Indices[3*(nb_point_par_ligne-1)*(nb_point_par_ligne-1)*2];
        int cpt=0;
        for(int i=0; i<nb_point_par_ligne-1; i++)
            for(int j=0; j<nb_point_par_ligne-1; j++)
                {
                int ind = i*nb_point_par_ligne+j;
                Indices[cpt]= ind;
                Indices[cpt+1]= ind + nb_point_par_ligne;
                Indices[cpt+2]= ind + 1;
                Indices[cpt+3]= ind + nb_point_par_ligne;
                Indices[cpt+4]= ind + nb_point_par_ligne+1;
                Indices[cpt+5]= ind + 1;
                cpt+=6;
 
            }
 
 
 
    glGenBuffers(1, &IBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);
Rendu
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
glEnableVertexAttribArray(0);
            glBindBuffer(GL_ARRAY_BUFFER, VBO);
 
            glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
 
 
            glDrawElements(GL_TRIANGLES, 3*(nb_point_par_ligne-1)*(nb_point_par_ligne-1)*2, GL_UNSIGNED_INT, 0);
 
 
            glDisableVertexAttribArray(0);
J'ai surement oublier une option, mais je ne vois pas laquelle, j'ai regarder le tutoriel disponible sur ce site mais je n'ai rien décelé.

Je vous remercie par avance

Some0ne