Jump to content

  • Log In with Google      Sign In   
  • Create Account


VBO texture coords


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Raloth   Members   -  Reputation: 379

Like
Likes
Like

Posted 01 September 2003 - 10:44 AM

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?

Sponsor:

#2 benjamin bunny   GDNet+   -  Reputation: 838

Like
Likes
Like

Posted 01 September 2003 - 11:08 AM

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.

#3 Raloth   Members   -  Reputation: 379

Like
Likes
Like

Posted 01 September 2003 - 11:24 AM

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.

#4 benjamin bunny   GDNet+   -  Reputation: 838

Like
Likes
Like

Posted 01 September 2003 - 11:31 AM

I didn''t say you can''t use separate buffers. Take a look at the last example in the spec.

#5 Raloth   Members   -  Reputation: 379

Like
Likes
Like

Posted 01 September 2003 - 11:51 AM

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?

#6 Jallen   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 September 2003 - 12:02 PM

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);


#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 01 September 2003 - 02:22 PM

It is not necessary to create that many VBOs. Remember that there is overhead associated with each VBO. Just bind the buffer and call BufferData on the vertex data then just call it again with the texcoord data:

glGenBuffersARB(1, &only_need_one_buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, only_need_one_buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, vertices, GL_STATIC_DRAW_ARB);
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, only_need_one_buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(3, GL_FLOAT, 0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

#8 Raloth   Members   -  Reputation: 379

Like
Likes
Like

Posted 01 September 2003 - 03:07 PM

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...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS