Multiple-streams
I was trying to stream some vertex-informations, but it doesn''t work, I
tryed to create an buffer with vertex-positions and vertex colors, but it
fails to create the vertex-color-buffer, here is some code (please don''t wonder why it''s VB ), perhaps you
could find out what''s wrong
Private Const D3DFVF_CUSTOMVERTEX = (D3DFVF_XYZ Or D3DFVF_DIFFUSE)
Dim pos(2) As D3DVECTOR
Dim col(2) As Long
Dim buf1 As Direct3DVertexBuffer8
Dim buf2 As Direct3DVertexBuffer8
pos(0) = MakeVector(-30, -30, 0)
pos(1) = MakeVector(30, -30, 0)
pos(2) = MakeVector(0, 30, 0)
col(0) = &HFFFF0099
col(1) = &HFFAAFF00
col(2) = &HFF002200
Set buf1 = D3Ddevice.CreateVertexBuffer(12 * 3, 0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED)
D3DVertexBuffer8SetData buf1, 0, 12 * 3, 0, pos(0)
Set buf2 = D3Ddevice.CreateVertexBuffer(4 * 3, 0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED)
D3DVertexBuffer8SetData buf2, 0, 4 * 3, 0, col(0)
I also tried to use
Set buf1 = D3Ddevice.CreateVertexBuffer(12 * 3, 0, D3DFVF_XYZ,
D3DPOOL_MANAGED)
D3DVertexBuffer8SetData buf1, 0, 12 * 3, 0, pos(0)
Set buf2 = D3Ddevice.CreateVertexBuffer(4 * 3, 0, D3DFVF_DIFFUSE,
D3DPOOL_MANAGED)
D3DVertexBuffer8SetData buf2, 0, 4 * 3, 0, col(0)
but both doesn''t work
I uploaded an sample(VB-code) to http://mitglied.lycos.de/lupin003/tri.zip, please
take a look and tell me what I''ve done wrong
Marius Schmidt
matrixvb.da.ru
please help me, this is my second question since I''m registered, I never got an answer for my first one, is this question too complex for you or don''t you understand what I need?
*bumb*
I don''t know if I have to use vertex-streams to solve my problem, any help would be very usefull, I would use another method too...
I don''t know if I have to use vertex-streams to solve my problem, any help would be very usefull, I would use another method too...
There are a number of reasons why it may not work, but without the full source code I can only speculate.
When Renering the mesh the diffuse colour is only used when the lighting is turned off and the vertex shader is set to the custom vertex FVF ( the code is in C++ by the way ) :
d3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
and in the render function
d3DDevice->SetStreamSource( 0, vertexBuffer, sizeof(CUSTOMVERTEX) );
d3DDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
d3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, numTriangles );
obviously the last line would change depending on what primative type you are using.
Hope that is of some help.
And why is it in VB?
Chris.
When Renering the mesh the diffuse colour is only used when the lighting is turned off and the vertex shader is set to the custom vertex FVF ( the code is in C++ by the way ) :
d3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
and in the render function
d3DDevice->SetStreamSource( 0, vertexBuffer, sizeof(CUSTOMVERTEX) );
d3DDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
d3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, numTriangles );
obviously the last line would change depending on what primative type you are using.
Hope that is of some help.
And why is it in VB?
Chris.
Because I''m using VB for D3D programming :D
Ok, thanks for your help! I know how to use vertex-streams, but my problem is that I have to set wich parts of my Vertex-UDT should get rendered, sometimes I need to render the color and the texture, sometimes I need to render the lightmap and the texture and sometimes I only need to render the color and the lightmap. I have an UDT desribing the position, the normal, the color, the lightmap-coordinate and the texture-coordinate, but of course I don''t need to render all the info given from the UDT, only a bit of it, how could I set what I want to use explicit?
btw, I understand all C++ source-code
Ok, thanks for your help! I know how to use vertex-streams, but my problem is that I have to set wich parts of my Vertex-UDT should get rendered, sometimes I need to render the color and the texture, sometimes I need to render the lightmap and the texture and sometimes I only need to render the color and the lightmap. I have an UDT desribing the position, the normal, the color, the lightmap-coordinate and the texture-coordinate, but of course I don''t need to render all the info given from the UDT, only a bit of it, how could I set what I want to use explicit?
btw, I understand all C++ source-code
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement