Vertex buffers
Say, i have 3 spaceships that i want to render, and they will all move at the same time per loop.
should i use 3 vertexbuffers and change/call the setstreamsource/drawprimitive 3 times and every frame?.
or is there a better way?.
Why do you have to change the vertex data at all? does the shape of the spaceship change over time? Do all spaceship at a certain time always look the same?
I''m no expert but rather use a single vertex buffer, but simply keep track of where a particular space ships'' vertices start and end. This way you only have to lock/unlock/setstreamsource/drawprimitive once every frame.
but how can i then move the 3 spaceships in different directions if i only have 1 vertexbuffer for them 3?
That''s what SetTransform is for. It allows you to set an orientation/translation matrix for the Draw(Indexed)Primitive calls that follow it.
so it will go something like this?
setstreamsource
int renderloop() {
copy-verticeship1-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
copy-verticeship2-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
copy-verticeship3-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
return 0;
}
correct?
setstreamsource
int renderloop() {
copy-verticeship1-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
copy-verticeship2-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
copy-verticeship3-into-vertexbuffer0
d3dmatrix operation
settransform
drawprimitive
return 0;
}
correct?
No, more like:
copy all vertices into vertex buffer, during load time, not run time, unless you want dynamic models
int renderloop() {
setstreamsource
d3dmatrix operation
settransform(space_ship1_matrix)
drawprimitive(space_ship1_start,space_ship1_number_of_prims);
d3dmatrix operation
settransform(space_ship2_matrix)
drawprimitiv(space_ship2_start,space_ship1_number_of_prims);
d3dmatrix operation
settransform(space_ship3_matrix)
drawprimitiv(space_ship2_start,space_ship1_number_of_prims);
return 0;
}
copy all vertices into vertex buffer, during load time, not run time, unless you want dynamic models
int renderloop() {
setstreamsource
d3dmatrix operation
settransform(space_ship1_matrix)
drawprimitive(space_ship1_start,space_ship1_number_of_prims);
d3dmatrix operation
settransform(space_ship2_matrix)
drawprimitiv(space_ship2_start,space_ship1_number_of_prims);
d3dmatrix operation
settransform(space_ship3_matrix)
drawprimitiv(space_ship2_start,space_ship1_number_of_prims);
return 0;
}
Ahaaaa.
so u use only 1 vertexbuffer regardless of how many objects there is on the screen?.
So drawprimitive keeps the object apart with the startvertice and stop vertice?.
[edited by - Funkodysse on October 18, 2002 9:15:50 AM]
so u use only 1 vertexbuffer regardless of how many objects there is on the screen?.
So drawprimitive keeps the object apart with the startvertice and stop vertice?.
[edited by - Funkodysse on October 18, 2002 9:15:50 AM]
If you have alot of vertices, you should proabably use more vertex buffers. And if you use indexed primitives you can only index 65536 vertices per vertex buffer. For more information try nVidia''s papers. developer.nvidia.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement