Skip to main content
GameDev.net gamedev.net
🔒 Locked

VBO texture coords

Started by Raloth Sep 1, 2003 at 4:44 PM 6 replies 15.3k views
Original Post
Raloth
Raloth
Is there anyway I can store texture coordinates in a VBO? I can''t get them to work just using a vertex array with my other VBOs. There is no token ''GL_TEXTURE_COORD_ARRAY_BUFFER_ARB'' so how am I supposed to do it?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
benjamin bunny
benjamin bunny
Texture coords are part of the vertex data, same as normals, colours and position. If you know how to use vertex arrays, VBO is not much different. Just make sure you allocate enough video memory to store all the vertex data, and then get buffer offsets within that memory block and use them in place of texcoord, normal, colour and position pointers.
Raloth
Raloth
You mean there is no way to put them in separate buffers? That would be best for me since my vertex data is dynamic but my texture coordinates are going to be static.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Raloth
Raloth
I''m afraid I don''t understand . I know you can have two buffers mapped at once but I don''t know how to point the texture coordinates to it. Do I just set the texture unit, bind the buffer that has my coordinates, and then call glTexCoordPointer?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Jallen
Jallen
Just do this to create the buffers:

glGenBuffersARB(1, &vertex_buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, vertices, GL_STATIC_DRAW_ARB);

glGenBuffersARB(1, &texcoord_buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, texcoord_buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, texcoords, GL_STATIC_DRAW_ARB);

then this when you want to use the buffers:

glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, texcoord_buffer);
glTexCoordPointer(3, GL_FLOAT, 0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
---I write code.DelphiGL (http://delphigl.cfxweb.net)
Raloth
Raloth
Thanks, it works now . I noticed that the performance is actually less though than when I was just using a normal vertex array for the texture coordinates. I guess maybe I should stick them in with the vertex data after all...
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.