How to batch one square in one glVertexPointer

I read that to optimize drawing it is possible to draw a set of numbers using the same texture in one pass.
But how do I join my singles square together to form one shape to send to glVertexPointer.

(read in PowerVR MBX.3D Application Development Guidelines .1.0.67a - page 5)

+1


a source to share


2 answers


I take it you are thinking about the "software conversion" step. I am assuming that you have some kind of vertex array for ONE-square and would like to combine several different instances of that array into one big array containing all the vertices for your squares, and then finally draw a large array.

In this case, the large array will contain the pre-transformed vertex data, which is then sent to the GPU in a single callback. Since you know how many squares you are going to draw, say N of them. This array should contain N * 4 * 3 elements (assuming you are working in 3d and therefore have 3 coordinates per vertex).

The programmatic transform step then iterates over all the squares and adds the transformed data to a large array, which in turn can be drawn by calling glVertexPointer () .

However, I am a little skeptical about the software conversion phase. This means that you take care of all these transformations yourself, which means that you are not using the power of the GPU. That is, you will be using the CPU power, not the GPU power, to get the transformed coordinates. Personally, I started by creating a texture atlas and then generated all texture coordinates for each individual square. This is only needed once, as the texture coordinates will not change. Then you can use the texture coordinates by calling glTextureCoordPointer () before you start drawing the squares (hit matrix i, draw quad, pop matrix, etc.)



Edit:

yes, that's what I want. Are you sure it's slower on the processor? from which they say that the overhead several times glVertexPointer and glDrawArrays will be slower.

I'm bringing back my skepticism! :) Why don't you take some action, just for that? The tradeoff should at least be that you have to shuffle a lot more data. Therefore, if the GPU cannot store all of this data, normal transformations may not be necessary.

Oh, one more thing. Once the butterfly moves, its data must be manually retransmitted, this is not required when you let the GPU transform the data for you. So you have to specify some kind of state for each instance when it's dirty and you need to do the relay before making the paint call.

+1


a source


Sounds like you want to use indices? See GlDrawElements.



0


a source







All Articles