예제 #1
0
        public Texture(Bitmap bitmap, TextureFilter textureFilter, bool mipmappingEnabled)
            : this()
        {
            BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            int length = data.Stride * data.Height;
            byte[] image = new byte[length];

            Marshal.Copy(data.Scan0, image, 0, length);
            bitmap.UnlockBits(data);

            byte[] pixels = new byte[length];
            for (int index = 0; index <= image.Length - 4; index += 4)
            {
                byte R = image[index + 2];
                byte G = image[index + 1];
                byte B = image[index];
                byte A = image[index + 3];

                pixels[index] = R;
                pixels[index + 1] = G;
                pixels[index + 2] = B;
                pixels[index + 3] = A;
            }

            SetTexture(pixels, bitmap.Width, bitmap.Height, PixelFormat.Rgba);
            SetParameters(textureFilter, mipmappingEnabled);
        }
예제 #2
0
        public void SetStates()
        {
            //if (Renderer.RendererDiagnosticSettings.RenderBreaksPerformStateChanges)
            {
                if (ColorOperation != Graphics.ColorOperation.Color)
                {
                    Renderer.Texture = Texture;
                }

                if (Texture == null && ColorOperation == ColorOperation.Texture)
                {
                    ColorOperation = ColorOperation.Color;
                }

                Renderer.ColorOperation     = ColorOperation;
                Renderer.BlendOperation     = BlendOperation;
                Renderer.TextureAddressMode = TextureAddressMode;
                _originalTextureFilter      = FlatRedBallServices.GraphicsOptions.TextureFilter;
                //if (TextureFilter != FlatRedBallServices.GraphicsOptions.TextureFilter)
                FlatRedBallServices.GraphicsOptions.TextureFilter = TextureFilter;

#if !USE_CUSTOM_SHADER
                if (ColorOperation == Graphics.ColorOperation.ColorTextureAlpha)
                {
                    Renderer.SetFogForColorOperation(Red, Green, Blue);
                }
#endif
            }
        }
예제 #3
0
        //internal static double ToWebGL(this TextureAttachment textureAttachment)
        //{
        //	switch (textureAttachment)
        //	{
        //		case TextureAttachment.Depth:
        //			return GL.DEPTH_ATTACHMENT;
        //		case TextureAttachment.DepthStencil:
        //			return GL.DEPTH_STENCIL_ATTACHMENT;
        //		case TextureAttachment.Colour0:
        //			return GL.COLOR_ATTACHMENT0;
        //		case TextureAttachment.Colour1 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT1_WEBGL;
        //		case TextureAttachment.Colour2 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT2_WEBGL;
        //		case TextureAttachment.Colour3 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT3_WEBGL;
        //		case TextureAttachment.Colour4 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT4_WEBGL;
        //		case TextureAttachment.Colour5 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT5_WEBGL;
        //		case TextureAttachment.Colour6 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT6_WEBGL;
        //		case TextureAttachment.Colour7 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT7_WEBGL;
        //		case TextureAttachment.Colour8 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT8_WEBGL;
        //		case TextureAttachment.Colour9 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT9_WEBGL;
        //		case TextureAttachment.Colour10 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT10_WEBGL;
        //		case TextureAttachment.Colour11 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT11_WEBGL;
        //		case TextureAttachment.Colour12 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT12_WEBGL;
        //		case TextureAttachment.Colour13 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT13_WEBGL;
        //		case TextureAttachment.Colour14 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT14_WEBGL;
        //		case TextureAttachment.Colour15 when Extensions.WEBGL_draw_buffers != null:
        //			return Extensions.WEBGL_draw_buffers.COLOR_ATTACHMENT15_WEBGL;
        //		default:
        //			throw new IllegalValueException(typeof(TextureAttachment), textureAttachment);
        //	}
        //}

        internal static uint ToWebGL(this TextureFilter textureFilter)
        {
            switch (textureFilter)
            {
            case TextureFilter.Nearest:
                return(GL.NEAREST);

            case TextureFilter.Linear:
                return(GL.LINEAR);

            case TextureFilter.NearestMipmapNearest:
                return(GL.NEAREST_MIPMAP_NEAREST);

            case TextureFilter.LinearMipmapNearest:
                return(GL.LINEAR_MIPMAP_NEAREST);

            case TextureFilter.NearestMipmapLinear:
                return(GL.NEAREST_MIPMAP_LINEAR);

            case TextureFilter.LinearMipmapLinear:
                return(GL.LINEAR_MIPMAP_LINEAR);

            default:
                throw new IllegalValueException(typeof(TextureFilter), textureFilter);
            }
        }
예제 #4
0
        internal static XFG.TextureFilter ToXNATextureFilter(TextureFilter filter)
        {
            switch (filter)
            {
            case TextureFilter.Anisotropic:
                return(XFG.TextureFilter.Anisotropic);

            case TextureFilter.Linear:
                return(XFG.TextureFilter.Linear);

            case TextureFilter.LinearMipPoint:
                return(XFG.TextureFilter.LinearMipPoint);

            case TextureFilter.MinLinearMagPointMipLinear:
                return(XFG.TextureFilter.MinLinearMagPointMipLinear);

            case TextureFilter.MinLinearMagPointMipPoint:
                return(XFG.TextureFilter.MinLinearMagPointMipPoint);

            case TextureFilter.MinPointMagLinearMipLinear:
                return(XFG.TextureFilter.MinPointMagLinearMipLinear);

            case TextureFilter.MinPointMagLinearMipPoint:
                return(XFG.TextureFilter.MinPointMagLinearMipPoint);

            case TextureFilter.Point:
                return(XFG.TextureFilter.Point);

            case TextureFilter.PointMipLinear:
                return(XFG.TextureFilter.PointMipLinear);

            default:
                throw new InvalidCastException();
            }
        }
예제 #5
0
파일: Texture.cs 프로젝트: newo2001/GSharp
        public TextureAtlas(string texturePath, string descriptorPath, TextureFilter filter = TextureFilter.Linear) : base(texturePath, filter)
        {
            locations = new Dictionary <string, Vector4>();
            string[] lines = new TextFile("../../" + descriptorPath).GetText().Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');

            for (int i = 0; i < lines.Length; i++)
            {
                string[] tokens = lines[i].Split(' ');
                if (tokens.Length != 5)
                {
                    Logger.Log("Parsing texture atlas descriptor failed, line " + i + " did not have 5 tokens", Severity.Error);
                    return;
                }

                if (!Int32.TryParse(tokens[1], out int x) || !Int32.TryParse(tokens[2], out int y) || !Int32.TryParse(tokens[3], out int w) || !Int32.TryParse(tokens[4], out int h))
                {
                    Logger.Log("Parsing texture atlas descriptor failed, line " + i + " had a NaN coordinate");
                    return;
                }
                else
                {
                    locations.Add(tokens[0], new Vector4(x, y, w, h));
                }
            }
        }
예제 #6
0
 public c000081(Game p0, GraphicsDeviceManager p1)
 {
     this.f0000b5 = TextureFilter.Point;
     this.f00000a = false;
     this.f000051 = Color.Black;
     this.f0000b6 = FormBorderStyle.Fixed3D;
     this.f0000a1 = false;
     this.f0000b5 = TextureFilter.Linear;
     this.f00000b = 800;
     this.f00000f = 600;
     this.f000057 = false;
     this.f0000b7 = MultiSampleType.TwoSamples;
     if (p1 != null)
     {
         this.f000056 = p1.IsFullScreen;
     }
     this.m000001();
     if (p0 != null)
     {
         this.m000004(p0.Window.ClientBounds.Width);
         this.m00004b(p0.Window.ClientBounds.Height);
     }
     if ((p1 != null) && !p1.GraphicsDevice.CreationParameters.Adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, SurfaceFormat.Color, this.m000008(), this.m0000ed()))
     {
         this.m0000ee(MultiSampleType.None);
     }
     this.m000003();
 }
예제 #7
0
        private static SharpDX.Direct3D11.Filter GetFilter(TextureFilter filter)
        {
            switch (filter)
            {
            case TextureFilter.Anisotropic:
                return(SharpDX.Direct3D11.Filter.Anisotropic);

            case TextureFilter.Linear:
                return(SharpDX.Direct3D11.Filter.MinMagMipLinear);

            case TextureFilter.LinearMipPoint:
                return(SharpDX.Direct3D11.Filter.MinMagLinearMipPoint);

            case TextureFilter.MinLinearMagPointMipLinear:
                return(SharpDX.Direct3D11.Filter.MinLinearMagPointMipLinear);

            case TextureFilter.MinLinearMagPointMipPoint:
                return(SharpDX.Direct3D11.Filter.MinLinearMagMipPoint);

            case TextureFilter.MinPointMagLinearMipLinear:
                return(SharpDX.Direct3D11.Filter.MinPointMagMipLinear);

            case TextureFilter.MinPointMagLinearMipPoint:
                return(SharpDX.Direct3D11.Filter.MinPointMagLinearMipPoint);

            case TextureFilter.Point:
                return(SharpDX.Direct3D11.Filter.MinMagMipPoint);

            case TextureFilter.PointMipLinear:
                return(SharpDX.Direct3D11.Filter.MinMagPointMipLinear);

            default:
                throw new NotImplementedException("Invalid texture filter!");
            }
        }
예제 #8
0
        public static Filter Convert(SamplerType type, TextureFilter min, TextureFilter mag, TextureFilter mip)
        {
            int offset;

            switch (type)
            {
            case SamplerType.Normal:
                offset = 0;
                break;

            case SamplerType.Comparison:
                offset = 0x80;
                break;

            case SamplerType.Minimum:
                offset = 0x100;
                break;

            case SamplerType.Maximum:
                offset = 0x180;
                break;

            default:
                throw new NotSupportedException("SamplerType is not supported.");
            }
            Filter f;

            if (!filters.TryGetValue(new Tuple <TextureFilter, TextureFilter, TextureFilter>(min, mag, mip), out f))
            {
                throw new NotSupportedException("TextureFilter variant not supported.");
            }
            return((Filter)(f + offset));
        }
예제 #9
0
        internal static D3D.Filter ToD3DFilter(TextureFilter filter)
        {
            switch (filter)
            {
            case TextureFilter.Anisotropic:
                return(D3D.Filter.Anisotropic);

            case TextureFilter.Linear:
                return(D3D.Filter.MinMagMipLinear);

            case TextureFilter.LinearMipPoint:
                return(D3D.Filter.MinMagLinearMipPoint);

            case TextureFilter.Point:
                return(D3D.Filter.MinMagMipPoint);

            case TextureFilter.PointMipLinear:
                return(D3D.Filter.MinMagPointMipLinear);

            case TextureFilter.MinLinearMagPointMipLinear:
                return(D3D.Filter.MinLinearMagPointMipLinear);

            case TextureFilter.MinLinearMagPointMipPoint:
                return(D3D.Filter.MinLinearMagMipPoint);

            case TextureFilter.MinPointMagLinearMipLinear:
                return(D3D.Filter.MinPointMagMipLinear);

            case TextureFilter.MinPointMagLinearMipPoint:
                return(D3D.Filter.MinPointMagLinearMipPoint);

            default:
                throw new ArgumentException("Invalid filter");
            }
        }
예제 #10
0
        internal WebGLTexture(byte[] data, TextureType type,
                              int width, int height, int depth,
                              TextureFormat format,
                              TextureFilter minFilter, TextureFilter magFilter,
                              TextureWrap wrapX, TextureWrap wrapY)
        {
            Type   = type;
            Width  = width;
            Height = height;
            Depth  = depth;
            Format = format;
            id     = GL.createTexture();
            switch (Type)
            {
            case TextureType.Texture2D:
                TextureTarget = GL.TEXTURE_2D;
                break;

            //case TextureType.Texture2DArray: // Not available in WebGL 1.0
            //	TextureTarget = GL.TEXTURE_2D_ARRAY;
            //	break;
            //case TextureType.Texture3D: // Not available in WebGL 1.0
            //	TextureTarget = GL.TEXTURE_3D;
            //	break;
            default:
                throw new IllegalValueException(typeof(TextureType), Type);
            }
            MinFilter = minFilter;
            MagFilter = magFilter;
            WrapX     = wrapX;
            WrapY     = wrapY;

            SetData(data);
        }
예제 #11
0
        private void GetInfoFromSprite()
        {
            //TODO: recalculate only if these values have changed (or any parent's values)
            this._matrix = this.CreateMatrix(this._sp.CalcRectInDrawTarget(), this._sp.Rotation, this._sp.RegPoint, this._sp.SourceRect.Size);

            Stage stage = ((Stage)EH.Instance.Stage);

            stage.ZCurrent  += stage.ZStep;
            this._matrix.M43 = 10000f - stage.ZCurrent - 1;
            //this._matrix.M43 = 10000f-m_sp.LocZ-1;

            this._ffpOp = this._sp.Ink;
            this._blend = this._sp.Blend;

            if (this._sp.TextureMagFilter == Sprite.TextureFilters.High)
            {
                this._magFilter = TextureFilter.GaussianQuad;
            }
            else if (this._sp.TextureMagFilter == Sprite.TextureFilters.Low)
            {
                this._magFilter = TextureFilter.Linear;
            }

            if (this._sp.TextureMinFilter == Sprite.TextureFilters.High)
            {
                this._minFilter = TextureFilter.GaussianQuad;
            }
            else if (this._sp.TextureMinFilter == Sprite.TextureFilters.Low)
            {
                this._minFilter = TextureFilter.Linear;
            }

            this._tx = ((MemberSpriteBitmapRenderStrategy)_sp.Member.RenderStrategy).Texture; //m_sp.Member.Texture
        }
예제 #12
0
        internal static OpenGLBindings.TextureFilter ToOpenGL(this TextureFilter textureFilter)
        {
            switch (textureFilter)
            {
            case TextureFilter.Nearest:
                return(OpenGLBindings.TextureFilter.Nearest);

            case TextureFilter.Linear:
                return(OpenGLBindings.TextureFilter.Linear);

            case TextureFilter.NearestMipmapNearest:
                return(OpenGLBindings.TextureFilter.NearestMipmapNearest);

            case TextureFilter.LinearMipmapNearest:
                return(OpenGLBindings.TextureFilter.LinearMipmapNearest);

            case TextureFilter.NearestMipmapLinear:
                return(OpenGLBindings.TextureFilter.NearestMipmapLinear);

            case TextureFilter.LinearMipmapLinear:
                return(OpenGLBindings.TextureFilter.LinearMipmapLinear);

            default:
                throw new IllegalValueException(typeof(TextureFilter), textureFilter);
            }
        }
예제 #13
0
 /// <summary>
 /// intialisation
 /// </summary>
 /// <param name="stage">The texture stage from which to fill this RenderState</param>
 /// <param name="device">The device from which to fill this RenderState</param>
 public TextureFilterState(int stage, Device device)
 {
     Stage     = stage;
     MinFilter = device.SamplerStates[stage].MinFilter;
     MagFilter = device.SamplerStates[stage].MagFilter;
     MipFilter = device.SamplerStates[stage].MipFilter;
 }
예제 #14
0
 public static TextureMinFilter GetMinFilter(TextureFilter filter)
 {
     if (!FilterMap.ContainsKey(filter) || FilterMap[filter] == null || FilterMap[filter].MinFilter == null) {
         throw new NotImplementedException("The MinFilter '" + filter + "' is not currently supported.");
     }
     return (TextureMinFilter)FilterMap[filter].MinFilter;
 }
예제 #15
0
        private static SharpDX.Direct3D11.Filter GetFilter(TextureFilter filter)
        {
            switch (filter)
            {
                case TextureFilter.Anisotropic:
                    return SharpDX.Direct3D11.Filter.Anisotropic;

                case TextureFilter.Linear:
                    return SharpDX.Direct3D11.Filter.MinMagMipLinear;

                case TextureFilter.LinearMipPoint:
                    return SharpDX.Direct3D11.Filter.MinMagLinearMipPoint;

                case TextureFilter.MinLinearMagPointMipLinear:
                    return SharpDX.Direct3D11.Filter.MinLinearMagPointMipLinear;

                case TextureFilter.MinLinearMagPointMipPoint:
                    return SharpDX.Direct3D11.Filter.MinLinearMagMipPoint;

                case TextureFilter.MinPointMagLinearMipLinear:
                    return SharpDX.Direct3D11.Filter.MinPointMagMipLinear;

                case TextureFilter.MinPointMagLinearMipPoint:
                    return SharpDX.Direct3D11.Filter.MinPointMagLinearMipPoint;

                case TextureFilter.Point:
                    return SharpDX.Direct3D11.Filter.MinMagMipPoint;

                case TextureFilter.PointMipLinear:
                    return SharpDX.Direct3D11.Filter.MinMagPointMipLinear;

                default:
                    throw new ArgumentException("Invalid texture filter!");
            }
        }
        public static Microsoft.Xna.Framework.Graphics.TextureFilter ToXnaFilter(this TextureFilter lgdxFilter)
        {
            Microsoft.Xna.Framework.Graphics.TextureFilter xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;

            switch (lgdxFilter)
            {
            case TextureFilter.Linear:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;
                break;

            case TextureFilter.Nearest:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Point;
                break;

            case TextureFilter.MipMap:
                //case TextureFilter.MipMapLinearLinear:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Anisotropic;
                break;

            case TextureFilter.MipMapLinearNearest:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinPointMagLinearMipPoint;
                break;

            case TextureFilter.MipMapNearestLinear:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinLinearMagPointMipLinear;
                break;

            case TextureFilter.MipMapNearestNearest:
                xnaFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinLinearMagPointMipPoint;
                break;
            }

            return(xnaFilter);
        }
예제 #17
0
파일: GL10.cs 프로젝트: vb0067/LGame
        public GL10()
        {
            int num;

            this.color                              = new float[4];
            this.clearColor                         = Color.Black;
            this.ColorWriteChannels                 = ColorWriteChannels.All;
            this.AlphaDestinationBlend              = Blend.InverseSourceAlpha;
            this.depthFunc                          = CompareFunction.Always;
            this.textureFilter                      = TextureFilter.Linear;
            this.textureAddressU                    = TextureAddressMode.Clamp;
            this.textureAddressV                    = TextureAddressMode.Clamp;
            this.vertex                             = new Vertex[8];
            this.texture                            = new Texture[0x100];
            this.matrixStack                        = new Stack <Matrix>();
            this.effect                             = new BasicEffect(GLEx.device);
            this.effect.VertexColorEnabled          = true;
            this.alphaTestEffect                    = new AlphaTestEffect(GLEx.device);
            this.alphaTestEffect.VertexColorEnabled = true;
            for (num = 0; num < this.vertex.Length; num++)
            {
                this.vertex[num] = new Vertex();
            }
            for (num = 0; num < 4; num++)
            {
                this.color[num] = 1f;
            }
        }
예제 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextureSamplerState"/> class.
 /// </summary>
 public TextureSamplerState()
 {
     BorderColor        = new GorgonColor(0);
     HorizontalWrapping = TextureAddressing.Clamp;
     VerticalWrapping   = TextureAddressing.Clamp;
     TextureFilter      = TextureFilter.Point;
 }
예제 #19
0
파일: Texture.cs 프로젝트: newo2001/GSharp
        public Texture(string path, TextureFilter filter = TextureFilter.Linear)
        {
            Image  img = Image.FromFile("../../" + path);
            Bitmap bmp = new Bitmap(img);

            Width  = bmp.Width;
            Height = bmp.Height;
            int minFilter = filter == TextureFilter.Linear ? (int)TextureMinFilter.Linear : (int)TextureMinFilter.Nearest;
            int magFilter = filter == TextureFilter.Linear ? (int)TextureMagFilter.Linear : (int)TextureMagFilter.Nearest;

            byte[] data = new byte[Width * Height * 4];

            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    Color color = bmp.GetPixel(x, y);
                    data[(bmp.Height - y - 1) * bmp.Width * 4 + x * 4]     = color.R;
                    data[(bmp.Height - y - 1) * bmp.Width * 4 + x * 4 + 1] = color.G;
                    data[(bmp.Height - y - 1) * bmp.Width * 4 + x * 4 + 2] = color.B;
                    data[(bmp.Height - y - 1) * bmp.Width * 4 + x * 4 + 3] = color.A;
                }
            }

            Handle = GL.GenTexture();
            Bind();
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, minFilter);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, magFilter);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, data);

            img.Dispose();
        }
예제 #20
0
        public static All GetGLTextureFilter(TextureFilter filter, TextureMipmapMode mipmapMode)
        {
            switch (filter)
            {
            case TextureFilter.Linear:
                switch (mipmapMode)
                {
                case TextureMipmapMode.Linear:
                    return(All.LinearMipmapLinear);

                case TextureMipmapMode.Nearest:
                    return(All.LinearMipmapNearest);

                default:
                    throw new ArgumentException(nameof(mipmapMode));
                }

            case TextureFilter.Nearest:
                switch (mipmapMode)
                {
                case TextureMipmapMode.Linear:
                    return(All.NearestMipmapLinear);

                case TextureMipmapMode.Nearest:
                    return(All.NearestMipmapNearest);

                default:
                    throw new ArgumentException(nameof(mipmapMode));
                }

            default:
                throw new ArgumentException(nameof(filter));
            }
        }
예제 #21
0
        public static int getGLEnumFromTextureFilter(TextureFilter filter)
        {
            switch (filter)
            {
            case TextureFilter.Nearest:
                return((int)All.Nearest);

            case TextureFilter.Linear:
                return((int)All.Linear);

            case TextureFilter.MipMap:
                return((int)All.LinearMipmapLinear);

            case TextureFilter.MipMapNearestNearest:
                return((int)All.NearestMipmapNearest);

            case TextureFilter.MipMapLinearNearest:
                return((int)All.LinearMipmapNearest);

            case TextureFilter.MipMapNearestLinear:
                return((int)All.NearestMipmapLinear);

            case TextureFilter.MipMapLinearLinear:
                return((int)All.LinearMipmapLinear);

            default:
                throw new ArgumentOutOfRangeException(nameof(filter), filter, null);
            }
        }
예제 #22
0
        internal static TextureMinFilter JoinMinFilter(TextureFilter mipmap, TextureFilter minification)
        {
            switch (minification)
            {
            case TextureFilter.Nearest:
                switch (mipmap)
                {
                case TextureFilter.None: return(TextureMinFilter.Nearest);

                case TextureFilter.Nearest: return(TextureMinFilter.NearestMipmapNearest);

                case TextureFilter.Linear: return(TextureMinFilter.NearestMipmapLinear);

                default: throw new ArgumentException("minification");
                }

            case TextureFilter.Linear:
                switch (mipmap)
                {
                case TextureFilter.None: return(TextureMinFilter.Linear);

                case TextureFilter.Nearest: return(TextureMinFilter.LinearMipmapNearest);

                case TextureFilter.Linear: return(TextureMinFilter.LinearMipmapLinear);

                default: throw new ArgumentException("minification");
                }

            default:
                throw new ArgumentException("mipmap");
            }
        }
예제 #23
0
 public void ChangeTextureFilterModeOfAllTextures(TextureFilter mode)
 {
     foreach (var spriteSheetImage in _spriteSheetsImages)
     {
         spriteSheetImage.Value.Texture.Options.Filter = mode;
     }
 }
예제 #24
0
        public RenderBreak(int itemNumber, Texture2D texture,
                           ColorOperation colorOperation,
                           BlendOperation blendOperation, TextureAddressMode textureAddressMode)
        {
#if DEBUG
            ObjectCausingBreak = null;
#endif
            LayerName = Renderer.CurrentLayerName;


            PrimitiveType = PrimitiveType.TriangleList;
            ItemNumber    = itemNumber;

            if (texture != null && texture.IsDisposed)
            {
                throw new ObjectDisposedException("Cannot create render break with disposed Texture2D");
            }

            mTexture               = texture;
            ColorOperation         = colorOperation;
            BlendOperation         = blendOperation;
            TextureAddressMode     = textureAddressMode;
            TextureFilter          = FlatRedBallServices.GraphicsOptions.TextureFilter;
            _originalTextureFilter = TextureFilter.Linear;

#if MONOGAME
            Red   = 0;
            Green = 0;
            Blue  = 0;
#endif
        }
예제 #25
0
        public void SetupSettings()
        {
            // Setup renderstates
            SetAlphaBlendEnable(false);
            SetAlphaTestEnable(false);
            SetCullMode(Cull.None);
            SetDestinationBlend(Blend.InverseSourceAlpha);
            SetFillMode(FillMode.Solid);
            SetMultisampleAntialias((General.Settings.AntiAliasingSamples > 0));
            SetSourceBlend(Blend.SourceAlpha);
            SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
            SetZEnable(false);
            SetZWriteEnable(false);

            // Texture addressing
            SetSamplerState(TextureAddress.Wrap);

            //mxd. It's still nice to have anisotropic filtering when texture filtering is disabled
            TextureFilter magminfilter = (General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Nearest);

            SetSamplerFilter(
                magminfilter,
                magminfilter,
                General.Settings.VisualBilinear ? MipmapFilter.Linear : MipmapFilter.Nearest,
                General.Settings.FilterAnisotropy);

            // Initialize presentations
            Presentation.Initialize();
        }
예제 #26
0
        public static void ParseRDPSetOtherMode(F3DEX2Command cmd,
                                                out PipelineMode pm, out CycleType cyc, out TexturePersp tp, out TextureDetail td, out TextureLOD tl,
                                                out TextureLUT tt, out TextureFilter tf, out TextureConvert tc, out CombineKey ck, out ColorDither cd,
                                                out AlphaDither ad, out AlphaCompare ac, out DepthSource zs, out RenderMode rm)
        {
            rm = new RenderMode(cmd.Words & (0xFFFFFFFF & ~((ulong)AlphaCompare.Mask | (ulong)DepthSource.Mask)));

            if (!rm.Known) // Handle TCL modes by checking again with alpha compare and dither included
            {
                rm = new RenderMode(cmd.Words & (0xFFFFFFFF & ~(ulong)DepthSource.Mask));
            }

            ulong wordH = cmd.Words >> 32;

            ad  = (AlphaDither)(wordH & (ulong)AlphaDither.Mask);
            cd  = (ColorDither)(wordH & (ulong)ColorDither.Mask);
            ck  = (CombineKey)(wordH & (ulong)CombineKey.Mask);
            pm  = (PipelineMode)(wordH & (ulong)PipelineMode.Mask);
            cyc = (CycleType)(wordH & (ulong)CycleType.Mask);
            tp  = (TexturePersp)(wordH & (ulong)TexturePersp.Mask);
            td  = (TextureDetail)(wordH & (ulong)TextureDetail.Mask);
            tl  = (TextureLOD)(wordH & (ulong)TextureLOD.Mask);
            tt  = (TextureLUT)(wordH & (ulong)TextureLUT.Mask);
            tf  = (TextureFilter)(wordH & (ulong)TextureFilter.Mask);
            tc  = (TextureConvert)(wordH & (ulong)TextureConvert.Mask);

            ac = (AlphaCompare)(cmd.Words & (ulong)AlphaCompare.Mask);
            zs = (DepthSource)(cmd.Words & (ulong)DepthSource.Mask);
        }
예제 #27
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Initialisation
        //---------------------------------------------------------------
        /// <summary>
        /// initialisation
        /// </summary>
        /// <param name="stage">textureStage to set filters for</param>
        /// <param name="minFilter">Minification filter</param>
        /// <param name="magFilter">Magnifiaction filter</param>
        /// <param name="mipFilter">Mipmap filter</param>
        public TextureFilterState(int stage, TextureFilter minFilter, TextureFilter magFilter, TextureFilter mipFilter)
        {
            Stage     = stage;
            MinFilter = minFilter;
            MagFilter = magFilter;
            MipFilter = mipFilter;
        }
예제 #28
0
 public void set(GLTexture texture, TextureFilter minFilter = TextureFilter.Linear, TextureFilter magFilter = TextureFilter.Linear, TextureWrap uWrap = TextureWrap.ClampToEdge, TextureWrap vWrap = TextureWrap.ClampToEdge)
 {
     this.texture   = texture;
     this.minFilter = minFilter;
     this.magFilter = magFilter;
     this.uWrap     = uWrap;
     this.vWrap     = vWrap;
 }
예제 #29
0
 void Start () 
 {
     a.material.mainTexture = tex;
     b.material.mainTexture = TextureFilter.SobelFilter(tex);
     c.material.mainTexture = TextureFilter.Convolution(tex, TextureFilter.SHARPEN_KERNEL, 1);
     d.material.mainTexture = TextureFilter.Convolution(tex, TextureFilter.LINEAR_KERNEL, 10);
     e.material.mainTexture = TextureFilter.Threshold(tex, .5f);
 }
예제 #30
0
 public void set(TextureDescriptor other)
 {
     texture   = other.texture;
     minFilter = other.minFilter;
     magFilter = other.magFilter;
     uWrap     = other.uWrap;
     vWrap     = other.vWrap;
 }
예제 #31
0
 public void setFilter(TextureFilter minFilter, TextureFilter magFilter)
 {
     this.minFilter = minFilter;
     this.magFilter = magFilter;
     bind();
     GL.TexParameter(glTarget, TextureParameterName.TextureMinFilter, TextureHelper.getGLEnumFromTextureFilter(minFilter));
     GL.TexParameter(glTarget, TextureParameterName.TextureMagFilter, TextureHelper.getGLEnumFromTextureFilter(magFilter));
 }
예제 #32
0
 public override void Render(Device dxDevice, TextureFilter texFilter, TextureAddress texAddressMode)
 {
     dxDevice.RenderState.AlphaBlendEnable = true;
     dxDevice.RenderState.SourceBlend      = Blend.SourceAlpha;
     dxDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;
     dxDevice.RenderState.BlendOperation   = BlendOperation.Add;
     base.Render(dxDevice, texFilter, texAddressMode);
 }
예제 #33
0
 private void AddTextureFilter(TextureFilter filterType)
 {
     // Add this item
     if (!textureFilterCombo.ContainsItem(filterType.ToString()))
     {
         textureFilterCombo.AddItem(filterType.ToString(), filterType);
     }
 }
예제 #34
0
 internal TextureSamplerState(TextureAddress uv, TextureFilter min, TextureFilter mag, TextureFilter mip, int maxAni)
 {
     Mode = 0;
     this.AddressUV = uv;
     this.MinFilter = min;
     this.MagFilter = mag;
     this.MipFilter = mip;
     this.MaxAnisotropy = maxAni;
 }
예제 #35
0
 internal TextureSamplerState(TextureAddress uv, TextureFilter min, TextureFilter mag, TextureFilter mip, int maxAni)
 {
     Mode               = 0;
     this.AddressUV     = uv;
     this.MinFilter     = min;
     this.MagFilter     = mag;
     this.MipFilter     = mip;
     this.MaxAnisotropy = maxAni;
 }
예제 #36
0
 private int ChangeFilter( TextureFilter textureFilter )
 {
     switch ( textureFilter )
     {
         case TextureFilter.Nearest: return ( int ) SharpDX.Direct3D9.TextureFilter.Point;
         case TextureFilter.Linear: return ( int ) SharpDX.Direct3D9.TextureFilter.Linear;
         case TextureFilter.Anisotropic: return ( int ) SharpDX.Direct3D9.TextureFilter.Anisotropic;
         default: throw new ArgumentException ();
     }
 }
 /// <summary>
 /// Applies a texture filter to a given gl texture target
 /// </summary>
 public static void ApplyTextureFilter( int target, int filterType, TextureFilter filter )
 {
     switch ( filter )
     {
         case TextureFilter.NearestTexel				: Gl.glTexParameteri( target, filterType, Gl.GL_NEAREST ); break;
         case TextureFilter.LinearTexel				: Gl.glTexParameteri( target, filterType, Gl.GL_LINEAR ); break;
         case TextureFilter.NearestTexelNearestMipMap: Gl.glTexParameteri( target, filterType, Gl.GL_NEAREST_MIPMAP_NEAREST ); break;
         case TextureFilter.LinearTexelNearestMipMap	: Gl.glTexParameteri( target, filterType, Gl.GL_LINEAR_MIPMAP_NEAREST ); break;
         case TextureFilter.NearestTexelLinearMipMap	: Gl.glTexParameteri( target, filterType, Gl.GL_NEAREST_MIPMAP_LINEAR ); break;
         case TextureFilter.LinearTexelLinearMipMap	: Gl.glTexParameteri( target, filterType, Gl.GL_LINEAR_MIPMAP_LINEAR ); break;
     }
 }
예제 #38
0
        public BasicTexture(Pixmap pixmap, TextureFilter textureFilter)
        {
            int[] TempGL = new int[1];

            Gl.glGenTextures(1, TempGL);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, TempGL[0]);

            Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, pixmap.Bpp, pixmap.Width, pixmap.Height, pixmap.getFormat(), Gl.GL_UNSIGNED_BYTE, pixmap.Data);

            textureID = TempGL[0];
            this.textureFilter = textureFilter;
            width = pixmap.Width;
            height = pixmap.Height;
        }
예제 #39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wrapS"></param>
        /// <param name="wrapT"></param>
        /// <param name="wrapR"></param>
        /// <param name="minFilter"></param>
        /// <param name="magFilter"></param>
        public SamplerParameters(
            TextureWrapping wrapS = TextureWrapping.ClampToEdge,
            TextureWrapping wrapT = TextureWrapping.ClampToEdge,
            TextureWrapping wrapR = TextureWrapping.ClampToEdge,
            TextureFilter minFilter = TextureFilter.Linear,
            TextureFilter magFilter = TextureFilter.Linear
            )
        {
            this.wrapS = wrapS;
            this.wrapT = wrapT;
            this.wrapR = wrapR;

            this.minFilter = minFilter;
            this.magFilter = magFilter;
        }
예제 #40
0
        private SamplerState(
			string name,
			TextureFilter filter,
			TextureAddressMode addressU,
			TextureAddressMode addressV,
			TextureAddressMode addressW
		)
            : this()
        {
            Name = name;
            Filter = filter;
            AddressU = addressU;
            AddressV = addressV;
            AddressW = addressW;
        }
예제 #41
0
        public static SlimDX.Direct3D9.TextureFilter MapFrom(TextureFilter textureFilter)
        {
            switch (textureFilter)
            {
                case TextureFilter.None:
                    return SlimDX.Direct3D9.TextureFilter.None;

                case TextureFilter.Linear:
                    return SlimDX.Direct3D9.TextureFilter.Linear;

                case TextureFilter.Anisotropic:
                    return SlimDX.Direct3D9.TextureFilter.Linear;

                case TextureFilter.Point:
                    return SlimDX.Direct3D9.TextureFilter.Point;

                default:
                    throw new ArgumentOutOfRangeException("textureFilter");
            }
        }
예제 #42
0
        private void GetInfoFromSprite()
        {
            //TODO: recalculate only if these values have changed (or any parent's values)
            this._matrix = this.CreateMatrix(this._sp.CalcRectInDrawTarget(), this._sp.Rotation, this._sp.RegPoint, this._sp.SourceRect.Size);

            Stage stage = ((Stage)EH.Instance.Stage);
            stage.ZCurrent += stage.ZStep;
            this._matrix.M43 = 10000f - stage.ZCurrent - 1;
            //this._matrix.M43 = 10000f-m_sp.LocZ-1;

            this._ffpOp = this._sp.Ink;
            this._blend = this._sp.Blend;

            if (this._sp.TextureMagFilter == Sprite.TextureFilters.High)
                this._magFilter = TextureFilter.GaussianQuad;
            else if (this._sp.TextureMagFilter == Sprite.TextureFilters.Low)
                this._magFilter = TextureFilter.Linear;

            if (this._sp.TextureMinFilter == Sprite.TextureFilters.High)
                this._minFilter = TextureFilter.GaussianQuad;
            else if (this._sp.TextureMinFilter == Sprite.TextureFilters.Low)
                this._minFilter = TextureFilter.Linear;

            this._tx = ((MemberSpriteBitmapRenderStrategy)_sp.Member.RenderStrategy).Texture; //m_sp.Member.Texture
        }
예제 #43
0
 private int GetFilter( TextureFilter textureFilter )
 {
     switch ( textureFilter )
     {
         case TextureFilter.Nearest: return ( int ) TextureMinFilter.Nearest;
         case TextureFilter.Linear: return ( int ) TextureMinFilter.Linear;
         case TextureFilter.Anisotropic: return ( int ) TextureMinFilter.LinearMipmapLinear;
         default: throw new ArgumentException ();
     }
 }
 private Result StretchRect(IntPtr devicePointer, IntPtr sourceSurface, IntPtr sourceRect, IntPtr destSurface, IntPtr destRect, TextureFilter filterType)
 {
     throw new NotImplementedException();
 }
예제 #45
0
파일: GFX.cs 프로젝트: nhippenmeyer/CS248
 public void SetTextureFilter(int index, TextureFilter filter)
 {
     TextureFilter mipFilter = filter;
     if (filter == TextureFilter.Anisotropic)
     {
         GFX.Device.SamplerStates[index].MaxAnisotropy = 16;
         mipFilter = TextureFilter.Linear;
     }
     GFX.Device.SamplerStates[index].MagFilter = filter;
     GFX.Device.SamplerStates[index].MinFilter = filter;
     GFX.Device.SamplerStates[index].MipFilter = mipFilter;
 }
예제 #46
0
        private static void m0000ec(TextureFilter p0)
        {
            GraphicsDevice device = c000074.GetGraphicsDevice();
            switch (p0)
            {
                case TextureFilter.Point:
                    if (!device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyPoint || !device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyPoint)
                    {
                        throw new ArgumentException("Your graphics device does not support " + p0);
                    }
                    break;

                case TextureFilter.Linear:
                    if (!(device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyLinear && device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyLinear))
                    {
                        throw new ArgumentException("Your graphics device does not support " + p0);
                    }
                    break;

                case TextureFilter.Anisotropic:
                    if (!(device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyAnisotropic && device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyAnisotropic))
                    {
                        throw new ArgumentException("Your graphics device does not support " + p0);
                    }
                    break;

                case TextureFilter.PyramidalQuad:
                    if (!(device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyPyramidalQuad && device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyPyramidalQuad))
                    {
                        throw new ArgumentException("Your graphics device does not support " + p0);
                    }
                    break;

                case TextureFilter.GaussianQuad:
                    if (!(device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMagnifyGaussianQuad && device.GraphicsDeviceCapabilities.TextureFilterCapabilities.SupportsMinifyGaussianQuad))
                    {
                        throw new ArgumentException("Your graphics device does not support " + p0);
                    }
                    break;
            }
        }
        private void ConvertMinFilter(TextureFilter filter, out Filter minFilter, out Filter magFilter, out SamplerMipmapMode mipmapMode, out RawBool enableComparison, out RawBool enableAnisotropy)
        {
            minFilter = magFilter = Filter.Nearest;
            mipmapMode = SamplerMipmapMode.Nearest;
            enableComparison = false;
            enableAnisotropy = false;

            switch (filter)
            {
                // Mip point
                case TextureFilter.Point:
                    break;
                case TextureFilter.MinLinearMagMipPoint:
                    minFilter = Filter.Linear;
                    break;
                case TextureFilter.MinPointMagLinearMipPoint:
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.MinMagLinearMipPoint:
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;

                // Mip linear
                case TextureFilter.MinMagPointMipLinear:
                    mipmapMode = SamplerMipmapMode.Linear;
                    break;
                case TextureFilter.MinLinearMagPointMipLinear:
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    break;
                case TextureFilter.MinPointMagMipLinear:
                    mipmapMode = SamplerMipmapMode.Linear;
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.Linear:
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.Anisotropic:
                    enableAnisotropy = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;

                // Comparison mip point
                case TextureFilter.ComparisonPoint:
                    enableComparison = true;
                    break;
                case TextureFilter.ComparisonMinLinearMagMipPoint:
                    enableComparison = true;
                    minFilter = Filter.Linear;
                    break;
                case TextureFilter.ComparisonMinPointMagLinearMipPoint:
                    enableComparison = true;
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.ComparisonMinMagLinearMipPoint:
                    enableComparison = true;
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;

                // Comparison mip linear
                case TextureFilter.ComparisonMinMagPointMipLinear:
                    enableComparison = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    break;
                case TextureFilter.ComparisonMinLinearMagPointMipLinear:
                    enableComparison = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    break;
                case TextureFilter.ComparisonMinPointMagMipLinear:
                    enableComparison = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.ComparisonLinear:
                    enableComparison = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;
                case TextureFilter.ComparisonAnisotropic:
                    enableComparison = true;
                    enableAnisotropy = true;
                    mipmapMode = SamplerMipmapMode.Linear;
                    minFilter = Filter.Linear;
                    magFilter = Filter.Linear;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
예제 #48
0
			public OpenGLTexture(
				uint handle,
				GLenum target,
				int levelCount
			) {
				Handle = handle;
				Target = target;
				HasMipmaps = levelCount > 1;

				WrapS = TextureAddressMode.Wrap;
				WrapT = TextureAddressMode.Wrap;
				WrapR = TextureAddressMode.Wrap;
				Filter = TextureFilter.Linear;
				Anistropy = 4.0f;
				MaxMipmapLevel = 0;
				LODBias = 0.0f;
			}
 public void SetSamplerState(int sampler, SamplerState state, TextureFilter value)
 {
     SetSamplerState(sampler, state, (int)value);
 }
예제 #50
0
 public SamplerState( ITexture t, TextureFilter f, TextureAddressing a, int al )
 {
     Texture = t; Filter = f; Addressing = a; AnisotropicLevel = al;
 }
예제 #51
0
 public GL10()
 {
     int num;
     this.color = new float[4];
     this.clearColor = Color.Black;
     this.ColorWriteChannels = ColorWriteChannels.All;
     this.AlphaDestinationBlend = Blend.InverseSourceAlpha;
     this.depthFunc = CompareFunction.Always;
     this.textureFilter = TextureFilter.Linear;
     this.textureAddressU = TextureAddressMode.Clamp;
     this.textureAddressV = TextureAddressMode.Clamp;
     this.vertex = new Vertex[8];
     this.texture = new Texture[0x100];
     this.matrixStack = new Stack<Matrix>();
     this.effect = new BasicEffect(GLEx.device);
     this.effect.VertexColorEnabled = true;
     this.alphaTestEffect = new AlphaTestEffect(GLEx.device);
     this.alphaTestEffect.VertexColorEnabled = true;
     for (num = 0; num < this.vertex.Length; num++)
     {
         this.vertex[num] = new Vertex();
     }
     for (num = 0; num < 4; num++)
     {
         this.color[num] = 1f;
     }
 }
예제 #52
0
        public void GLTexParameterf(int target, int pname, float param)
        {
            switch (pname)
            {
                case 0x2800:
                    switch (((int)param))
                    {
                        case 0x2600:
                            this.textureFilter = TextureFilter.Point;
                            break;

                        case 0x2601:
                            this.textureFilter = TextureFilter.Linear;
                            break;
                    }
                    break;

                case 0x2802:
                    switch (((int)param))
                    {
                        case 0x2901:
                            this.textureAddressU = TextureAddressMode.Wrap;
                            break;

                        case 0x812f:
                            this.textureAddressU = TextureAddressMode.Clamp;
                            break;
                    }
                    break;

                case 0x2803:
                    switch (((int)param))
                    {
                        case 0x2901:
                            this.textureAddressV = TextureAddressMode.Wrap;
                            break;

                        case 0x812f:
                            this.textureAddressV = TextureAddressMode.Clamp;
                            break;
                    }
                    break;
            }
        }
예제 #53
0
 public Page(string file, bool useMipMaps, SurfaceFormat format, TextureFilter filter,
     TextureAddressMode uWrap, TextureAddressMode vWrap)
 {
     TextureFile = file;
     UseMipMaps = useMipMaps;
     Format = format;
     //MinFilter = minFilter;
     //MagFilter = magFilter;
     Filter = filter;
     UWrap = uWrap;
     VWrap = vWrap;
 }
예제 #54
0
		private idImage CreateImage(string name, TextureType type, TextureFilter filter, TextureRepeat repeat, TextureDepth depth, CubeFiles cubeMap, bool allowDownSize)
		{
			idImage image = new idImage(name, type, filter, repeat, depth, cubeMap, allowDownSize);

			_images.Add(image);
			_imageDictionary.Add(name, image);

			return image;
		}
예제 #55
0
 public void GenerateMipMaps(TextureFilter filterType) { throw new NotImplementedException(); }
예제 #56
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            KeyboardState keyboard = Keyboard.GetState();

            // If the user presses the escape key, close the game
            if (keyboard.IsKeyDown(Keys.Escape) )
                Exit();

            // If the user presses the F1 key, toggle FullScreen Mode
            if (keyboard.IsKeyDown(Keys.F11) && prevKeyboardState.IsKeyUp(Keys.F11))
                IsFullScreen = !IsFullScreen;

            if (keyboard.IsKeyDown(Keys.A) && prevKeyboardState.IsKeyUp(Keys.A))
                isAnimating = !isAnimating;

            if (keyboard.IsKeyDown(Keys.R) && prevKeyboardState.IsKeyUp(Keys.R))
            {
                triangleAngle = 0f;
                rectangleAngle = 0f;
            }

            if (keyboard.IsKeyDown(Keys.F) && prevKeyboardState.IsKeyUp(Keys.F))
            {
                textureFilter = textureFilter + 1;
                if (textureFilter > TextureFilter.MinPointMagLinearMipPoint)
                    textureFilter = TextureFilter.Linear;

                GraphicsDevice.SamplerStates[0] = new SamplerState()
                {
                    Filter = textureFilter
                };
            }

            if (keyboard.IsKeyDown(Keys.PageUp))
            {
                depth -= 0.05f;
                ResetTranslation();
            }

            if (keyboard.IsKeyDown(Keys.PageDown))
            {
                depth += 0.05f;
                ResetTranslation();
            }

            if (isAnimating)
            {
                triangleAngle += MathHelper.ToRadians(1.0f);
                if (triangleAngle > MathHelper.TwoPi)
                    triangleAngle -= MathHelper.TwoPi;

                rectangleAngle -= MathHelper.ToRadians(0.75f);
                if (rectangleAngle < 0.0f)
                    rectangleAngle += MathHelper.TwoPi;
            }

            // Cache the keyboard state for the next update cycle
            prevKeyboardState = keyboard;
        }
예제 #57
0
		/// <summary>
		/// Finds or loads the given image, always returning a valid image pointer.
		/// Loading of the image may be deferred for dynamic loading.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="filter"></param>
		/// <param name="allowDownSize"></param>
		/// <param name="repeat"></param>
		/// <param name="depth"></param>
		/// <returns></returns>
		public idImage ImageFromFile(string name, TextureFilter filter, bool allowDownSize, TextureRepeat repeat, TextureDepth depth)
		{
			return ImageFromFile(name, filter, allowDownSize, repeat, depth, CubeFiles.TwoD);
		}
예제 #58
0
 public void m0000eb(TextureFilter p0)
 {
     this.f0000b5 = p0;
     if (!this.f00000a)
     {
         m0000ec(p0);
         Renderer.m0000d4().SamplerStates[0].MinFilter = this.f0000b5;
         Renderer.m0000d4().SamplerStates[0].MagFilter = this.f0000b5;
     }
 }
 public void TexParameter(TextureTarget target, TextureParameterName pname, TextureFilter param)
 {
     this.TexParameter(target, pname, (uint)param);
 }
예제 #60
0
		/// <summary>
		/// Finds or loads the given image, always returning a valid image pointer.
		/// Loading of the image may be deferred for dynamic loading.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="filter"></param>
		/// <param name="allowDownSize"></param>
		/// <param name="repeat"></param>
		/// <param name="depth"></param>
		/// <param name="cubeMap"></param>
		/// <returns></returns>
		public idImage ImageFromFile(string name, TextureFilter filter, bool allowDownSize, TextureRepeat repeat, TextureDepth depth, CubeFiles cubeMap)
		{
			if((name == null) || (name == string.Empty)
				|| (name.Equals("default", StringComparison.OrdinalIgnoreCase) == true)
				|| (name.Equals("_default", StringComparison.OrdinalIgnoreCase) == true))
			{
				idE.DeclManager.MediaPrint("DEFAULTED");

				return this.DefaultImage;
			}

			idImage image;

			// strip any .tga file extensions from anywhere in the _name, including image program parameters
			name = name.Replace(".tga", "");

			//
			// see if the image is already loaded, unless we
			// are in a reloadImages call
			//
			if(_imageDictionary.TryGetValue(name, out image) == true)
			{
				// the built in's, like _white and _flat always match the other options
				if(name.StartsWith("_") == true)
				{
					return image;
				}

				if(image.CubeFiles != cubeMap)
				{
					idConsole.Error("Image '{0}' has been referenced with conflicting cube map states", name);
				}

				if((image.Filter != filter) || (image.Repeat != repeat))
				{
					// we might want to have the system reset these parameters on every bind and
					// share the image data	

					// FIXME: this might be the wrong behaviour.  original d3 would return a new image but our dictionary
					// requires unique keys.
					return image;
				}
				else
				{
					if((image.AllowDownSize == allowDownSize) && (image.Depth == depth))
					{
						// note that it is used this level load
						image.LevelLoadReferenced = true;

						return image;
					}

					// the same image is being requested, but with a different allowDownSize or depth
					// so pick the highest of the two and reload the old image with those parameters
					if(image.AllowDownSize == false)
					{
						allowDownSize = false;
					}

					if(image.Depth > depth)
					{
						depth = image.Depth;
					}

					if((image.AllowDownSize == allowDownSize) && (image.Depth == depth))
					{
						// the already created one is already the highest quality
						image.LevelLoadReferenced = true;

						return image;
					}

					/*image.AllowDownSize = allowDownSize;
					image.Depth = depth;*/
					image.LevelLoadReferenced = true;


					if((idE.CvarSystem.GetBool("image_preload") == true) && (_insideLevelLoad == false))
					{
						image.ReferencedOutsideLevelLoad = true;
						image.ActuallyLoadImage(true, false); // check for precompressed, load is from front end

						idE.DeclManager.MediaPrint("{0}x{1} {1} (reload for mixed referneces)", image.Width, image.Height, image.Name);
					}

					return image;
				}
			}

			// HACK: to allow keep fonts from being mip'd, as new ones will be introduced with localization
			// this keeps us from having to make a material for each font tga
			if(name.Contains("fontImage_") == true)
			{
				allowDownSize = false;
			}

			//
			// create a new image
			//
			image = CreateImage(name, TextureType.TwoD, filter, repeat, depth, cubeMap, allowDownSize);
			image.LevelLoadReferenced = true;

			// load it if we aren't in a level preload
			if((idE.CvarSystem.GetBool("image_preload") == true) && (_insideLevelLoad == false))
			{
				image.ReferencedOutsideLevelLoad = true;
				image.ActuallyLoadImage(true, false); // check for precompressed, load is from front end

				idE.DeclManager.MediaPrint("{0}x{1} {2}", image.Width, image.Height, image.Name);
			}
			else
			{
				idE.DeclManager.MediaPrint(image.Name);
			}

			return image;
		}