Clamping TextureAddressMode in XNA

岁酱吖の 提交于 2019-12-12 14:51:52

问题


I've been working on implementing a 2D lighting system in XNA, and I've gotten the system to work--as long as my window's dimensions are powers of two. Otherwise, the program will fail at this line:

GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, Vertices, 0, 2);

The exception states that "XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two," and every attempt that I've made to slve this problem has failed--the most common solution I've found on the internet is to put the line GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; directly above the line above, but that hasn't solved my problem.

I apologize if I've left out any information that could be necessary to solve this; I'll be more than happy to provide more as needed.


回答1:


Isn't this the same question you asked before?

In your HLSL look for the line that declares the sampler that the pixel shader is using.

You can set the address mode to clamp in this line.

SamplerState somethingLikeThis {
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};


来源:https://stackoverflow.com/questions/10792151/clamping-textureaddressmode-in-xna

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!