Пример #1
0
 public void Apply()
 {
     if (IsDepthEnabled)
     {
         GL.Enable(EnableCap.DepthTest);
         Utilities.CheckLastGLES3Error();
         GL.DepthFunc(OpenGLESFormats.ConvertDepthComparison(DepthComparison));
         Utilities.CheckLastGLES3Error();
         GL.DepthMask(true);
         Utilities.CheckLastGLES3Error();
     }
     else
     {
         GL.Disable(EnableCap.DepthTest);
         Utilities.CheckLastGLES3Error();
     }
 }
Пример #2
0
            public unsafe InternalSamplerState(
                SamplerAddressMode addressU,
                SamplerAddressMode addressV,
                SamplerAddressMode addressW,
                SamplerFilter filter,
                int maxAnisotropy,
                RgbaFloat borderColor,
                DepthComparison comparison,
                int minLod,
                int maxLod,
                int lodBias,
                bool mip)
            {
                _samplerID = GL.GenSampler();

                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapR, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressU));
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapS, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressV));
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapT, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressW));
                Utilities.CheckLastGLError();

                if (addressU == SamplerAddressMode.Border || addressV == SamplerAddressMode.Border || addressW == SamplerAddressMode.Border)
                {
#pragma warning disable CS0618 // TextureBorderColor is not exposed on SamplerParameterName
                    GL.SamplerParameter(_samplerID, All.TextureBorderColor, (float *)&borderColor);
#pragma warning restore CS0618
                    Utilities.CheckLastGLError();
                }

                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinLod, (float)minLod);
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMaxLod, (float)maxLod);
                Utilities.CheckLastGLError();

                if (filter == SamplerFilter.Anisotropic || filter == SamplerFilter.ComparisonAnisotropic)
                {
#pragma warning disable CS0618 // TextureMaxAnisotropyExt is not exposed on SamplerParameterName
                    GL.SamplerParameter(_samplerID, All.TextureMaxAnisotropyExt, (float)maxAnisotropy);
#pragma warning restore CS0618 // Type or member is obsolete
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinFilter, mip ? (int)TextureMinFilter.LinearMipmapLinear : (int)TextureMinFilter.Linear);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                    Utilities.CheckLastGLError();
                }
                else
                {
                    OpenGLESFormats.VeldridToGLTextureMinMagFilter(filter, mip, out TextureMinFilter min, out TextureMagFilter mag);
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinFilter, (int)min);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMagFilter, (int)mag);
                    Utilities.CheckLastGLError();
                }

                if (s_comparisonFilters.Contains(filter))
                {
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureCompareMode, (int)All.CompareRefToTexture);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureCompareFunc, (int)OpenGLESFormats.ConvertDepthComparison(comparison));
                    Utilities.CheckLastGLError();
                }
            }