Jump to content
  • Advertisement
Sign in to follow this  

OpenGL VBOs and multiple textures

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First some background, I have terrain information that is loaded and unloaded in chunks depending on a player's position in the world.

Each chunk is loaded into one large VBO. (empty space in the VBO is all zeros)

According to my understanding of textures and VBOs, multiple textures have to be rendered as such:

glDrawArrays(GL_TRIANGLES, offset1,size1);


glDrawArrays(GL_TRIANGLES, offset2,size2);


This is an issue for me because the information has to be loaded into the VBO with its chunk group, and in order to fit the scheme above I would need to break apart each chunk and keep track of where all the individual triangles are for when the chunk needs to be unloaded.

To me that is extremely messy and I would probably kill myself if i actually had to code it.

Is there any other way to do VBOs with multiple textures? Or do all the triangles have to be ordered in the VBO by which texture they use like in the code snip?

Also if you have an answer please expand more than just saying "use texture arrays" or something like that. OpenGL has far too poor of documentation to just google that sort of thing.


Share this post

Link to post
Share on other sites
You can use index buffers to reference vertices inside a VBO in any order you like.

e.g. given two quads made out of 6 vertices, maybe you want all those triangles to be textured with Tex#1, except for the bottom left triangle, which should use Tex#2
[font=courier new,courier,monospace]1-2-5[/font]
[font=courier new,courier,monospace]|\|\|[/font]
[font=courier new,courier,monospace]4-3-6[/font]

You could create an IBO with a segment for each texture, where,
the indices for texture 1 are: 123,256,632
and the indices for texture 2 are: 341

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!