Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / D3D: Multiple vertex streams without shaders? Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

March 28, 2005, 08:46 AM

Hi, let me explain:
I'm currently trying to do something that I thought was extremely simple- and without the need for vertex shaders...

I have a vertex stream containing vertex elements with position, normal, diffuse and texture coordinates.

I have another stream with vertex elements only containing position.

Simply put, I want to use the positions from the second vertex stream and the other data from that of the first when I render the first vertex buffer as primitives:

  3. struct fullVertex
  4. {
  5.    D3DXVECTOR3 position;
  6.    D3DXVECTOR3 normal;
  7.    D3DCOLOR    diffuse;
  8.    float       tu,tv;
  9. };
  11. struct positionVertex
  12. {
  13.    D3DXVECTOR3 position;
  14. };
  16. D3DVERTEXELEMENT9 newDecl[] =
  17. {
  18.   //stream positions from stream 1...
  21.   //stream other attributes from stream 0...
  26.   D3DDECL_END()
  27. }
  29. <<create and set the vertex declaration here...>>
  31. //set stream sources...
  32. //assume buffer streamBufferA contains relevant information...
  33. d3dDevice->SetStreamSource( 0, streamBufferA, 0, sizeof(fullVertex) );
  35. //assume buffer streamBufferB contains relevant information...
  36. d3dDevice->SetStreamSource( 1, streamBufferB, 0, sizeof(positionVertex) );
  38. //draw primitves...
  39. //assume data for 50 triangles are inside the VBs...
  40. d3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 50 );

I thought you could simply create the two streams, and use vertex declarations to achieve this, though when I tried to implement this I get nothing drawn :(

Anyone tell me where I'm going wrong? This would really help me...


John Dexter

March 31, 2005, 06:19 AM

Well apart from anything else, both your vertex declarations have a position. Don't you want one to just have position and the other to have everything else? Then it should work fine... Did the same set of attributes (normal, diffuse) work correctly when done in a single vertex with a single stream?


March 31, 2005, 09:04 AM

I can see why that might be confusing:

I have the original vertex buffer with all of the attributes (colour,normal,etc).

I then want to replace the position data with a new set, without locking the buffer, copying the data etc. I still want to use the colour and texture coords from the original buffer (dont worry about normals).

Essentially I have several "snapshots" of the geometry which I want to interchange, but I dont want to replicate all of the other data which doesn't change in order to save memory.

Ive tried some tests on the declaration part of the code, and as soon as I specify two different stream sources for the data, I get nothing drawn. I'm pretty sure i'm missing something basic about using declarations, because its not something i've done before.



March 31, 2005, 11:30 PM

I may be wrong, but I think you have to declare things in order, so you have to declare stream 1 after stream 0. I haven't worked with multiple streams in a while though, so I'm not 100% sure.

This thread contains 4 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.