Home > 未分类 > 多流渲染的SetStreamSource()

多流渲染的SetStreamSource()

使用如下2个Stream存储顶点信息:Position/Normal/Color/TexCoord

   VertexElement[] elemTex = new VertexElement[] {
    new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
    new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
    new VertexElement(0, 24, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
    new VertexElement(1, 0, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
    VertexElement.VertexDeclarationEnd
   };

 
则SetStreamSource()的最后一个参数Stride必须指定:
device.SetStreamSource(0, m_VBGeo, 0, CustomVertex.PositionNormalColored.StrideSize);
device.SetStreamSource(1, m_VBTex, 0, sizeof(float) * 2);
不能使用不带该参数的构造:
device.SetStreamSource(0, m_VBGeo, 0);
device.SetStreamSource(1, m_VBTex, 0);
否则会导致纹理寻址不正确。
Advertisements
Categories: 未分类
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: