开发者

XNA Reach profile

I get his error

"XNA Framework Reach profile requ开发者_运维百科ires TextureAddressMode to be Clamp when using texture sizes that are not powers of two"

for line

GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleStrip, verts, 0, 2);

What should I do ?

Thanks,


When using a reach profile, use power of two sized textures or set the TextureAddressingMode to Clamp.

The TextureAddressingMode is part of the GraphicsDevice SamplerState. You need to set this state before your draw call. The following code shows how to set the first texture sampler to one of the built in sampler states.

GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleStrip, verts, 0, 2);


I my case, the Model.fx file was setting the AddressMode to Wrap and that was messing it up.

Here's the correct sampler_state from my Model.fx:

sampler TextureSampler = sampler_state
{
    Texture = (Texture);

    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;

    AddressU = Clamp;
    AddressV = Clamp;
};

More info can be found here: http://www.packtpub.com/article/xna-hsl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜