Hi guys, I asked this question in the beginner forum some days ago, but I did'nt get any answer, and I'm a bit puzzled. Hope you can help me.

I'm trying to learn how to use vertex arrays, but I must have some error, or there must be something I'm not understanding, because for some reason my little test app is not working as expected.
Just trying to draw one textured triangle using vertex arrays. If I call glBindTexture() before calling glDrawArrays() or glDrawElements() no texture is shown, but if I omit the texture binding everything works 'right'. Tell me if you see the problem in this implementation:

Last straw:
Your function does return m_Id if it succeeds, right?
You've omitted that part.

Anonymous Coward

05-06-2003, 12:00 PM

Yep, that's right. Anyway, the first code I posted, with the coords, indices and all the Vertex Array stuff is supposed to be right?
Thats what I have understand from the Red Book, but it doesn't include an example that uses vertex array + texturing.
Thanks!

dorbie

05-07-2003, 08:15 AM

If removing the bind operation works then is may indicate a problem with the binding of your texture in the image load function but it doesn't seem like it from your code.

You don't need to obtain the handle any specific way, you can use any number, just pick a positive integer. Wrapping your own gen function just confuses the issue further(why people write obfuscating code like this I don't know), just pick a number for the test. You are allowed to do this in OpenGL, the utilities to generate handles are just to help code play together. Pick any number and use it.

There just isn't enough OpenGL in your posted example to show a consistent working code path. Important stuff is hidden so we're left guessing.

I still don't see a glEnable call for texture, perhaps you have a heuristic somewhere that is switching it off based on rendering path and we can't see it. Go find the glEnable(GL_TEXTURE_2D) call in your code & make sure it's in the right place.

[This message has been edited by dorbie (edited 05-07-2003).]

bivasb

05-07-2003, 10:55 AM

As errors are not apparent in the code you posted and it is difficult to debug without the complete src. , I will just post the way I do it and hope it helps:

//Step 5: Recycle AGP Memory, use the fences instead of flushing. Fences had a finer
//control last time I checked !(Beware!, some GEForces don't support it.)
// glFinishFenceNV(fence);
g_pWndMainGL->glFlushVertexArrayRangeNV();

And then a snippet from the draw function
glEnable(GL_TEXTURE_2D);
m_vpLightMapLib[lightMapIdx]->BindTexture();
glDrawElements(GL_TRIANGLES,3*m_NumTriangles,GL_UN SIGNED_INT,pVertexIndices);
// glSetFenceNV(fence,GL_ALL_COMPLETED_NV);

The trick is to group all the triangles according to the texture they are bound to.
And use the vertex array for each group.
hope this helps.