Ejemplo n.º 1
0
        public Texture2D(
            GraphicsDevice graphicsDevice,
            int width,
            int height,
            bool mipMap,
            SurfaceFormat format
            )
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }

            GraphicsDevice = graphicsDevice;
            Width          = width;
            Height         = height;
            LevelCount     = mipMap ? CalculateMipLevels(width, height) : 1;

            // TODO: Use QueryRenderTargetFormat!
            if (this is IRenderTarget)
            {
                if (format == SurfaceFormat.ColorSrgbEXT)
                {
                    if (FNA3D.FNA3D_SupportsSRGBRenderTargets(GraphicsDevice.GLDevice) == 0)
                    {
                        // Renderable but not on this device
                        Format = SurfaceFormat.Color;
                    }
                    else
                    {
                        Format = format;
                    }
                }
                else if (format != SurfaceFormat.Color &&
                         format != SurfaceFormat.Rgba1010102 &&
                         format != SurfaceFormat.Rg32 &&
                         format != SurfaceFormat.Rgba64 &&
                         format != SurfaceFormat.Single &&
                         format != SurfaceFormat.Vector2 &&
                         format != SurfaceFormat.Vector4 &&
                         format != SurfaceFormat.HalfSingle &&
                         format != SurfaceFormat.HalfVector2 &&
                         format != SurfaceFormat.HalfVector4 &&
                         format != SurfaceFormat.HdrBlendable)
                {
                    // Not a renderable format period
                    Format = SurfaceFormat.Color;
                }
                else
                {
                    Format = format;
                }
            }
            else
            {
                Format = format;
            }

            texture = FNA3D.FNA3D_CreateTexture2D(
                GraphicsDevice.GLDevice,
                Format,
                Width,
                Height,
                LevelCount,
                (byte)((this is IRenderTarget) ? 1 : 0)
                );
        }
Ejemplo n.º 2
0
 public void Begin()
 {
     FNA3D.FNA3D_QueryBegin(GraphicsDevice.GLDevice, query);
 }
Ejemplo n.º 3
0
 public void End()
 {
     FNA3D.FNA3D_QueryEnd(GraphicsDevice.GLDevice, query);
 }
Ejemplo n.º 4
0
 public OcclusionQuery(GraphicsDevice graphicsDevice)
 {
     GraphicsDevice = graphicsDevice;
     query          = FNA3D.FNA3D_CreateQuery(GraphicsDevice.GLDevice);
 }