Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MonoGame-Android SamplerState.LinearWrap_C#_Android_.net_Xamarin.android_Monogame - Fatal编程技术网

C# MonoGame-Android SamplerState.LinearWrap

C# MonoGame-Android SamplerState.LinearWrap,c#,android,.net,xamarin.android,monogame,C#,Android,.net,Xamarin.android,Monogame,我们使用SamplerState.LinearRap在游戏中平铺很多东西。我们的游戏共享一个SpriteBatch对象,调用如下开始: _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, _rasterState); 这对于Windows上的XNA和iOS上的MonoGame都非常有效 问题是,在Android上,如

我们使用SamplerState.LinearRap在游戏中平铺很多东西。我们的游戏共享一个SpriteBatch对象,调用如下开始:

_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, _rasterState);
这对于Windows上的XNA和iOS上的MonoGame都非常有效

问题是,在Android上,如果启用LinearRap,任何两个大小的非幂纹理都将渲染为黑色矩形,即使它是以不需要包装的方式绘制的。如果我们切换到SamplerState.LinearCamp默认值,这些纹理在Android上不再呈现黑色。通常情况下,如果您尝试在其他平台上平铺纹理,非二次幂的纹理会留下空白空间,直到下一个最大的二次幂


这是Android上OpenGL的一个限制,还是MonoGame中的一个问题?我不想将每个纹理的大小调整为二的幂,但如果这是唯一的选择,或者有很好的理由,我们会这样做。

通过MonoGame挖掘,我在ESTexture2D.cs中发现:

                _width = imageSource.Width;
                _height = imageSource.Height;

                // There are rules for npot textures that we must abide by (wrap = ClampToEdge and filter = Nearest or Linear)
                if (!MathHelper.IsPowerOfTwo(_width) || !MathHelper.IsPowerOfTwo(_height))
                {
                    //filter = ALL11.Linear;
                    //wrap = ALL11.ClampToEdge;
                    _width = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Width) / Math.Log10(2))));
                    _height = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Height) / Math.Log10(2))));
                }
我对filter和wrap的更改进行了注释,并将大小调整为2的幂


这解决了我的问题,但我不确定是否是一个有效的修复单游戏。我不知道如果您使用SamplerState.LinearCamp会有什么影响。

通过MonoGame挖掘,我在ESTexture2D.cs中发现了以下内容:

                _width = imageSource.Width;
                _height = imageSource.Height;

                // There are rules for npot textures that we must abide by (wrap = ClampToEdge and filter = Nearest or Linear)
                if (!MathHelper.IsPowerOfTwo(_width) || !MathHelper.IsPowerOfTwo(_height))
                {
                    //filter = ALL11.Linear;
                    //wrap = ALL11.ClampToEdge;
                    _width = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Width) / Math.Log10(2))));
                    _height = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Height) / Math.Log10(2))));
                }
我对filter和wrap的更改进行了注释,并将大小调整为2的幂


这解决了我的问题,但我不确定是否是一个有效的修复单游戏。我不知道如果您使用SamplerState.LinearCamp会有什么影响。

我相信这已在Developed3D分支中修复


D.

我相信这在开发部门已经得到了解决


D.

谢谢,多米尼克,我们很快就要开始切换到develop3d了。谢谢,多米尼克,我们很快就要开始切换到develop3d了。