Bon je viens vous voir parceque je comprend vraiment rien au vbo je crois XD
Je dois etre vraiment bidon ... Bref j'ai monté mon petit moteur 3D et j'utilise pour mes mesh des Vertex Array classique jusqu'a présent et tout marche parfaitement alors la je me dis maintenant on vas essayer d'éviter les transferts inutiles entre CPU et GPU on vas donc passer en mode VBO....
Je ressors tous mes tutos sur le vbo ça a pas l'air bien compliqué.. je met le code en place ... j'essaye d'afficher mon terrain avec... tout nikel !!! je rajoute un model 3d dessus plein d'espoir... je vois toujours mon terrain .. youpiii j'arrive sur mon Model 3D il s'affiche (je le vois) et paf plantage et la je pleure 'mais pourquoiiii :'("
Bon pour redevenir un peu plus sérieu je comprend vraiment pas le probleme ...
Voila mon code si jamais vous voyez pourquoi ca marche pas...
Dans la methode draw de ma mesh :
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
23
24 void Mesh::draw() const { glPushMatrix(); glTranslatef( _pos.x(), _pos.y(), _pos.z() ); _rot.applyGlRotation(); glScalef( _scl.x(), _scl.y(), _scl.z() ); glColor3ub(255,255,255); _vertex.bindVertex(); // bind les sommets for( uint32 i=0; i<_materialList.size(); i++ ) { _indices[i].draw(); } _vertex.unbindVertex(); // dessinne les suivant for( uint32 i=0; i<_meshList.size(); i++ ) _meshList[i]->draw( out, indent + 1 ); // libere glPopMatrix(); }
Et avec ce meme code d'affichage j'utilise d'une part la methode suivante en VA :
Et celle ci en 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
17
18
19
20
21
22
23 void VertexBuffer::bindVertex() const { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer( 3, GL_FLOAT, 0, _pVertices ); } void VertexBuffer::unbindVertex() const { glDisableClientState(GL_VERTEX_ARRAY); } /** * Methode d'affichage */ void IndexBuffer::draw() const { glEnableClientState( GL_INDEX_ARRAY ); if( _polyType == INDEX_QUAD ) glDrawElements( GL_QUADS, _nbIndices, GL_UNSIGNED_INT, _pIndices ); else glDrawElements( GL_TRIANGLES, _nbIndices, GL_UNSIGNED_INT, _pIndices ); glDisableClientState( GL_INDEX_ARRAY ); }
Voila merci d'avance a ceux qui auraient une piste parceque c'est vraiment frustrant ...
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 void VertexBuffer::bindVertex() const { if( _vboId == 0 ) { DDD::glGenBuffersARB( 1, &_vboId); DDD::glBindBufferARB( GL_ARRAY_BUFFER_ARB, _vboId); DDD::glBufferDataARB( GL_ARRAY_BUFFER_ARB, _sizeOfBuffer, _pVertices, GL_STREAM_DRAW_ARB ); } else { DDD::glBindBufferARB( GL_ARRAY_BUFFER_ARB, _vboId); } glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer( 3, GL_FLOAT, 0, BUFFER_OFFSET(0) ); LOG_INFORMATION("VertexBuffer",S("Bind du buffer de vertex ") << _vboId ); } void VertexBuffer::unbindVertex() const { glDisableClientState(GL_VERTEX_ARRAY); } /** * Methode d'affichage */ void IndexBuffer::draw() const { if( _vboId == 0 ) { DDD::glGenBuffersARB( 1, (GLuint*)&_vboId); DDD::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, _vboId); DDD::glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, _sizeOfBuffer, _pIndices, GL_STREAM_DRAW_ARB ); } else { DDD::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, _vboId); } glEnableClientState( GL_INDEX_ARRAY ); glIndexPointer( GL_INT, 0, BUFFER_OFFSET(0) ); LOG_INFORMATION("IndexBuffer",S("Bind du buffer d'indices ") << _vboId << " de taille " << _nbIndices << " (tailles GL " << sizeof(uint32) << " <=> uint32 " << sizeof(uint32) ); if( _polyType == INDEX_QUAD ) glDrawElements( GL_QUADS, _nbIndices, GL_UNSIGNED_INT, 0 ); else glDrawElements( GL_TRIANGLES, _nbIndices, GL_UNSIGNED_INT, 0 ); glDisableClientState( GL_INDEX_ARRAY ); }
Cordialement,
Seb
Partager