使用定点的顶点数据

更新:2007 年 11 月

您可以使用定点顶点数据来提高那些未在硬件中实现几何形变和光效处理的三维图形驱动程序的几何形变和光效处理速度。一些驱动程序能够加快定点数据的处理速度。您可以通过测试 DeviceCaps 结构的 NativeFloat 属性来确定驱动程序是否使用了浮点数学运算。如果该属性的值为 false,则最好为设备使用定点格式的数据。所有的 Windows Mobile Direct3D 驱动程序都必须同时支持定点数据和浮点数据。

定点顶点缓冲区和浮点顶点缓冲区的使用方式相同。两者之间仅存在以下差异:它们包含的数据的格式不同,且创建顶点缓冲区时指定的灵活顶点的格式不同。

如果数据最初不是定点格式的,则您可以构造一个包含浮点数据的 Mesh 对象,然后通过调用 Mesh 对象的 Clone 方法将其转换为固定点数据。

下表列出了一些 VertexFormats 枚举值,这些值可用于为定点数据和浮点数据指定各种灵活格式。此列表并没有囊括所有的可能性,但是它给出了一些示例来说明定点灵活顶点格式和浮点灵活顶点格式之间差异。

格式

浮点规范

定点规范

仅位置

VertexFormats.Position

VertexFormats.PositionFixed

位置和法线

VertexFormats.Position | VertexFormats.Normal

VertexFormats.PositionFixed | VertexFormats.NormalFixed

位置和漫射色

VertexFormats.Position | VertexFormats.Diffuse

VertexFormats.PositionFixed | VertexFormats.Diffuse

位置和一个二维纹理坐标

VertexFormats.Position | VertexFormats.Texture1

VertexFormats.PositionFixed | VertexFormats.Texture1 | VertexTextureCoordinate.Fixed(0)

位置、法线、反射色、漫射色、一维纹理坐标和二维纹理坐标

VertexFormats.Position | VertexFormats.Normal | VertexFormats.Diffuse | VertexFormats.Texture2 | VertexTextureCoordinate.Size1(0)

VertexFormats.PositionFixed | VertexFormats.NormalFixed | VertexFormats.Diffuse | VertexFormats.Texture2 | VertexTextureCoordinate.Size1(0) | VertexTextureCoordinate.Fixed(0) | VertexTextureCoordinate.Fixed(1)

 

请参见

其他资源

.NET Compact Framework 中的 Mobile Direct3D 编程