Hello everybody,
I have a problem with vbo, all work.
Except textures:
Only in some places, the texture is not correct.
This is all the same places so it’s not a problem of memory.
I am a screen of the same character with and without vbo.
Here, I give you my code as:
if (vbo.ContainsKey(mesh.material))
{
// Utilisation des données des buffers
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, vbo[mesh.material][0]);
Gl.glVertexPointer(3, Gl.GL_FLOAT, 32, new IntPtr(0));
Gl.glTexCoordPointer(2, Gl.GL_FLOAT, 32, new IntPtr(12));
Gl.glNormalPointer(Gl.GL_FLOAT, 32, new IntPtr(20));
Gl.glBindBuffer(Gl.GL_ELEMENT_ARRAY_BUFFER, vbo[mesh.material][1]);
// Activation d'utilisation des tableaux
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
// Rendu de notre géométrie
Gl.glDrawElements(Gl.GL_TRIANGLES, mesh.IndexArray.Length, Gl.GL_UNSIGNED_INT, new IntPtr(0));
Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY);
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
}
else
{
uint[] tableau = new uint[2];
// Génération des buffers
Gl.glGenBuffers(2, tableau);
// Buffer d'informations de vertex
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, tableau[0]);
Gl.glBufferData(Gl.GL_ARRAY_BUFFER,new IntPtr(mesh.FloatArray.Length*4), mesh.FloatArray, Gl.GL_STATIC_DRAW);
// Buffer d'indices
Gl.glBindBuffer(Gl.GL_ELEMENT_ARRAY_BUFFER, tableau[1]);
Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER, new IntPtr(mesh.IndexArray.Length*4), mesh.IndexArray, Gl.GL_STATIC_DRAW);
vbo.Add(mesh.material, tableau);
// Utilisation des données des buffers
}
Thank you and goodbye,