View Full Version : textures with VBO's
when using vbo's we use
glDrawArrays to draw some polygons. However they all have the same texture.(The one that is bound)
glDrawArrays(draw 50 quads)
glDrawArrays(draw the remaining quads)
to draw my objects. Is there some other way to draw without having to use so many glDrawArrays calls?
Is my approach slow?
10-23-2007, 06:05 AM
I wouldn't consider two glDrawArrays calls to be excessive, but you certainly could use multiple texture units to get it down to one call.
In normal usage, you'd use glActiveTexture and glMultiTexCoord.
With VBOs, there is no glMultiTexCoordPointer function. However, similar to glActiveTexture, you can call glClientActiveTexture before each glTexCoordPointer call to have the same effect.
The answer to your real question, i think, is "no". You need to bind one texture, draw with it, bind the next and make the next draw-call. That's how it is done.
However, as Lindley mentioned, there are some ways to reduce the number of batches necessary, however that is only rarely used and often only possible when there are certain limits on how you use things.
Your approach is not slow and it is not excessive. What you should do, however, is sort your polygons by textures, so that you can render all polygons using texture A in one call and then all polygons using texture B in one call, etc. That's how it is done in professional software, too.
Is it possible to get the transformed vertex values back from the graphics card. for eg, get it to return only values multiplied by modelview matrix or projection, or mvp. or even the screen coords of all the vertices.(both the rendered and non-rendered)?
Because if I can get the transformed values back from the gfx card then I can off-load my cpu for collision and physics calcs because I won't have to transform them.
It is possible on DX10 class hardware (ie. Geforce 8) using the "transform feedback" extension.
On older hardware it is not really possible. With tricks you can do some things (using render-to-texture for example), but nothing that is, in my opinion, worth considering.
I am not sure, whether there are possibilities using Pixel Buffer Objects (PBOs), i have never used them. You might want to read the spec for that.
What you want to do is called "render to vertex-buffer", you can search for that on google. If there are other ways, that i do not know of, you will certainly find it there.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.