View Full Version : how to switch textures using vertex arrays?
07-13-2004, 10:02 PM
I want to render a terrain with many different textures. I want to put them into a vertex array. I read that you can use an array of texture coordinates but I am not seeing a way to switch between different texture objects. The only way I can see to do this is put the vertex arrays in a display list. Select one texture and draw the polygons that use that texture using vertex arrays, then select another texture and use vertex arrays to draw the polygons that use that texture.
This seems like a limiting way to use vertex arrays because when you are rendering a scene you are going to most likely use many textures, not just one.
you cannot switch textures in a drawelements call. as you said, you have to draw all polygons that match a specific state (textures, blending and so on).
including render states into vertex arrays would lead to specific scene description format that must be handled by opengl which is not the intention of a low level render api. drivers would have to interprete that format and seperate it into different render batches (the way you dont like it).
display lists are the only way to do what you want in opengl.
07-14-2004, 03:57 AM
If the different textures are overlapping in the scene, you could use multitexturing.
glMultiTexcoord... (or texcoordpointers on different texture units)
If not, you could group your vertices per texture.
Originally posted by jabe:
you cannot switch textures in a drawelements call. as you said, you have to draw all polygons that match a specific state (textures, blending and so on).True.
My suggestion is to take a stab at 3D textures. They're pretty well supported right now. The problem is that you must have a POTD depth, but it does not look too much like a problem.
That way, changing texture really means changing a texture coordinate.
Much more problematic is to put this suggestion in practice. I tried to implement it in my engine as but I realized it would have complicated a lot of things so, I actually didn't do it. Read as: this could be possible in theory but I'm not sure it's a viable solution in practice.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.