Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple figures (objects?)

Started by nedemon Oct 11, 2005 at 7:37 AM 1 replies 550+ views
Original Post
nedemon
nedemon
Greetings, gentlemen. I got a couple of style questions. 1. How do you usually render more than one logical figure (i.e. a sphere and a cube)? I mean using single Vbuffer or more. That question is somewhat related to the second one. 2. Is there a way to set different material options for different logical figures? I'm informed of creating multiple devices but i heard that resource management between them is a mess, so all that results in a performance loss. Thanx for help.
kovacsp
kovacsp
Quote:
Original post by nedemon
Greetings, gentlemen. I got a couple of style questions.
1. How do you usually render more than one logical figure (i.e. a sphere and a cube)? I mean using single Vbuffer or more. That question is somewhat related to the second one.


I have difficulties understanding your question.
So you want to render a single object twice to the same window, possibly to different places?
In this case, you just set upo a different World matrix, and call DrawSubset / DrawIndexedprimitive / whatever you use once more.
Or have a look at instancing, if you have some new hardware.

Quote:
Original post by nedemon
2. Is there a way to set different material options for different logical figures? I'm informed of creating multiple devices but i heard that resource management between them is a mess, so all that results in a performance loss.
Thanx for help.

Now if you want to use diffent materials as you say in your first sentence, then you can just change the material when you change the world matrix.

If you want to render to multiple render targets (like multiple, different windows), then you can either do multiple devices, which results in duplicating all your resources (as you they cannot use each other's resources), or you can use a new swap chain for the second window, which is a better solution.

have a look at this one in this case: Rendering to multiple windows

Hope this helps,
kp
------------------------------------------------------------Neo, the Matrix should be 16-byte aligned for better performance!
jollyjeffers
jollyjeffers
Quote:
Original post by nedemon
1. How do you usually render more than one logical figure (i.e. a sphere and a cube)? I mean using single Vbuffer or more. That question is somewhat related to the second one.

The trivial solution is just to make multiple render calls (IDirect3DDevice9::Draw**()). Within reason there is no limit on how many render calls you can make in a single frame.

A typical pattern is something like:
  1. Begin Frame
  2. For each figure/mesh/model
    1. Configure the device for this instance
      1. Set up the vertex buffer (SetStreamSource()) and index buffer (SetIndices)
      2. Configure any shaders (e.g. SetVertexShader())
      3. Set up any render states (SetRenderState())
      4. Set any materials (D3DMATERIAL9 objects)
      5. Configure any transformations (D3DXMATRIX's in SetTransform())
      6. Set any textures (SetTexture())
    2. Draw the object (e.g. DrawPrimitive() or ID3DXMesh::DrawSubset())
    3. Perform any tidying up (not always necessary) by setting render states back to what they were before you started this instance.
  3. End the Frame
  4. Present() it to the screen so the user can see it.


Optimal rendering tries to reduce the number of duplicate resources, or pack together common data types (e.g. if all the vertices are the same format put them in the same vertex buffer). If you're only getting started with this stuff, don't worry about it yet - you'll get to it soon enough [smile]

Quote:
Original post by nedemon
2. Is there a way to set different material options for different logical figures? I'm informed of creating multiple devices but i heard that resource management between them is a mess, so all that results in a performance loss.
Thanx for help.

You DONT want multiple devices - thats for other things entirely [wink] What you want is to create, somewhere in your program, a number of resources for each mesh/figure you want to display. There is no requirement to have only a single vertex buffer or single texture..

With reference to the above "typical loop" the various Set**() type calls you'll use while rendering affect anything that happens AFTER it's called, up until it's changed again (by another Set**() call). So for multiple objects you can just keep changing the materials/transforms/textures as you see fit.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.