kurlyak at February 29th, 2012 03:58 — #1
Suppose I have code Dx9 and VC++ 2005:
pAttr[k].FaceCount ); //NumPrimitives
I don`t figure out what is VertexStart and VertexCount. For example I have:
Vert in IndxBuff
What is VertexStart? This is vert 40 from face 0 or min vert indx 20 which is in face 0 and face 1? That is VertexStart is min index of vert in index buffer or first index vert in indx buffer?
Furthemore what is VertexCount? This is value 12, that is we have 4 face by 3 vert each = 12. Or this value = 10 because vert 20 repeat twice in face 0 and face 1 and vert 24 repeat twice in face 0 and face3 ?
And how I understand FaceStart = 40 and FaceCount = 4.
Thanks in advance.
smile_ at February 29th, 2012 10:35 — #2
VertexStart = min(index),
VertexCount = max(index) - min(index) + 1.
Or you can simply set (dunno about performance though):
VertexStart = 0,
VertexCount = VertexTotal.
kurlyak at February 29th, 2012 13:20 — #3
Nothing understand... Sorry.
stainless at March 1st, 2012 04:37 — #4
Okay, say you have a mass of vertices in memory.
You have loaded in a 3d mesh that has 1000 vertices.
The first 100 you want to texture with a red texture.
The next 400 you want to texture with a blue texture
The last 500 you want to texture with a white texture.
You could sort each vertex by texture and store them in separate vertex buffers, but more commonly you store them in a single vertex buffer.
So when you want to render this object you need a mechanism to render the vertex buffer bit by bit.
bind red texture
render red triangles
bind blue texture
render blue triangles
bind white texture
render white polygons
To allow you to do things like this, all rendering libraries allow you to specify a start index and length with the rendering calls.
They normally also allow for combining meshes into a single vertex buffer for performance, so if you had a single triangle it's indices would obviously be 0,1,2 but if you had already added 100 verts to the buffer you need them to be 100,101,102.
That's all it is, it allows you to lump stuff together so you are not constantly sending vertex buffers across the bus into the graphics card