PDA

View Full Version : Texture with vbo some problems



Pierre
04-08-2010, 01:00 PM
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.

http://best-nk.fr/vbo.png

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,

Pierre
04-09-2010, 04:48 AM
Anyone could help me ?

Fugitive
04-10-2010, 11:26 AM
I cant say for sure since I havent had a detailed look at your code, but I would say that your pointers are messed up. Take another look at those. I have had quite a few headaches with those before.

Pierre
04-11-2010, 01:02 AM
What pointers ?

Because if you speak about my board, I already checked the content is good.

And I don't understand why some places are well positioned
and other aren't well positioned.

Do you have another proposition ?

Fugitive
04-11-2010, 02:07 PM
Im not talking about your content. In order to draw your content, you pass a pointer to your content to the GPU via something like Gl.glVertexPointer etc. In general, these kind of bugs are indicative of a pointer pointing to the wrong place. Even being off by a byte can be a pain in the rear to debug because it may just look 'almost' ok, except for a few places.

Pierre
04-11-2010, 03:12 PM
Ok and how can I fix this problem ?

Surprising because the textures are always drawn in the same place, even for textures misplaced.

Pierre
04-12-2010, 11:39 AM
:(

Jackis
04-14-2010, 04:18 AM
Pourriez vous me dire, quelles choses sont meme differentes (sauf VBO). Parce que votre code est regardee tout a fait raison. Peut etre, quelque autre shader quand VBO est active, ou autre chose.
Et ces bizzares couleurs, est ce qu'ils presentent dans la texture?

ZbuffeR
04-14-2010, 08:30 AM
Nice try Jackis, your post mostly makes sense :)

Jackis
04-19-2010, 05:28 AM
Well, I tried to help Pierre, but he has suddenly disappeared... May be, has been frightened of my french? :)
And yes, I liked that panda... Didn't you like it? ;)