예제 #1
0
 public static Texture FromFile(GraphicsDevice graphicsDevice, string filename, TextureCreationParameters creationParameters) {
     TextureInformation texinfo = GetTextureInformation(filename);
     if (creationParameters.Width == 0) creationParameters.Width = texinfo.Width;
     if (creationParameters.Height == 0) creationParameters.Height = texinfo.Height;
     if (creationParameters.Depth == 0) creationParameters.Depth = texinfo.Depth;
     if (texinfo.ResourceType == ResourceType.Texture2D)
     {
         int ImgID;
         Il.ilGenImages(1, out ImgID);
         Il.ilBindImage(ImgID);
         Il.ilLoadImage(filename);
         int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
         int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
         int depth = Il.ilGetInteger(Il.IL_IMAGE_DEPTH);
         int size = Il.ilGetInteger(Il.IL_IMAGE_SIZE_OF_DATA);
         Texture2D tex = new Texture2D(graphicsDevice, creationParameters.Width, creationParameters.Height, creationParameters.Depth, TextureUsage.None, SurfaceFormat.Rgb32);
         
         Gl.glBindTexture(Gl.GL_TEXTURE_2D, tex.textureId);
         Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Il.ilGetInteger(Il.IL_IMAGE_BYTES_PER_PIXEL), creationParameters.Width, creationParameters.Height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, Il.ilGetData());
         
         Il.ilBindImage(0);
         return tex;
     }
     else if (texinfo.ResourceType == ResourceType.Texture3D) { throw new NotImplementedException(); }
     else if (texinfo.ResourceType == ResourceType.Texture3DVolume) { throw new NotImplementedException(); } //FIXME: Should we handle this here too?
     else if (texinfo.ResourceType == ResourceType.TextureCube) { throw new NotImplementedException(); }
     else return null;
 }
예제 #2
0
 static TextureCreationParameters()
 {
     TextureCreationParameters.m_Default = new TextureCreationParameters(
         0, 0, 0, 0,
         SurfaceFormat.Unknown,
         TextureUsage.None,
         Color.TransparentBlack,
         FilterOptions.Dither | FilterOptions.Triangle,
         FilterOptions.Box);
 }
 static TextureCreationParameters()
 {
     TextureCreationParameters.m_Default = new TextureCreationParameters(
         0, 0, 0, 0,
         SurfaceFormat.Unknown,
         ResourceUsage.None,
         ResourceManagementMode.Automatic,
         Color.TransparentBlack,
         FilterOptions.Dither | FilterOptions.Triangle,
         FilterOptions.Box);
 }
예제 #4
0
        /// <summary>
        /// Gets a Microsoft.Xna.Framework.Graphics.Texture2D of the texture corresponding to the fluid type.
        /// </summary>
        /// <param name="fluidType">The fluid type to get the texture of.</param>
        /// <returns>See summary.</returns>
        public static Texture2D GetTexture(this FluidType fluidType)
        {
            if (FluidTypeExtensions.textureCache.ContainsKey(fluidType))
            {
                return FluidTypeExtensions.textureCache[fluidType];
            }
            else
            {
                System.Drawing.Bitmap image = fluidType.GetImage();

                TextureCreationParameters parameters = new TextureCreationParameters();
                parameters.Filter = FilterOptions.Triangle;
                parameters.Format = SurfaceFormat.Color;
                parameters.MipFilter = FilterOptions.Triangle;
                parameters.MipLevels = TextureManipulation.GetMaximumMipLevels(image);

                Texture2D texture = TextureManipulation.Texture2DFromBitmap(image, EngineManager.Engine.GraphicsDevice, parameters);

                texture.LevelOfDetail = 1;
                texture.GenerateMipMaps(TextureFilter.Linear);

                FluidTypeExtensions.textureCache.Add(fluidType, texture);
                return texture;
            }
        }
예제 #5
0
 public new static Texture3D FromFile(GraphicsDevice graphicsDevice, Stream textureStream, int numberBytes, TextureCreationParameters creationParameters)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 public new static Texture3D FromFile(GraphicsDevice graphicsDevice, string filename, TextureCreationParameters creationParameters)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public new static Texture2D FromFile(GraphicsDevice graphicsDevice, string filename,
                                      TextureCreationParameters creationParameters)
 {
     return((Texture2D)Texture.FromFile(graphicsDevice, filename, creationParameters));
 }
예제 #8
0
 public new static Texture2D FromFile(GraphicsDevice graphicsDevice, Stream textureStream, int numberBytes,
                                      TextureCreationParameters creationParameters)
 {
     return((Texture2D)Texture.FromFile(graphicsDevice, textureStream, numberBytes, creationParameters));
 }
예제 #9
0
 public static Texture FromFile(GraphicsDevice graphicsDevice, Stream textureStream, int numberBytes, TextureCreationParameters creationParameters) { throw new NotImplementedException(); }
예제 #10
0
        public static Texture FromFile(GraphicsDevice graphicsDevice, string filename, TextureCreationParameters creationParameters)
        {
            TextureInformation texinfo = GetTextureInformation(filename);

            if (creationParameters.Width == 0)
            {
                creationParameters.Width = texinfo.Width;
            }
            if (creationParameters.Height == 0)
            {
                creationParameters.Height = texinfo.Height;
            }
            if (creationParameters.Depth == 0)
            {
                creationParameters.Depth = texinfo.Depth;
            }
            if (texinfo.ResourceType == ResourceType.Texture2D)
            {
                int ImgID;
                Il.ilGenImages(1, out ImgID);
                Il.ilBindImage(ImgID);
                Il.ilLoadImage(filename);
                int       width  = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
                int       height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
                int       depth  = Il.ilGetInteger(Il.IL_IMAGE_DEPTH);
                int       size   = Il.ilGetInteger(Il.IL_IMAGE_SIZE_OF_DATA);
                Texture2D tex    = new Texture2D(graphicsDevice, creationParameters.Width, creationParameters.Height, creationParameters.Depth, TextureUsage.None, SurfaceFormat.Rgb32);

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, tex.textureId);
                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Il.ilGetInteger(Il.IL_IMAGE_BYTES_PER_PIXEL), creationParameters.Width, creationParameters.Height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, Il.ilGetData());

                Il.ilBindImage(0);
                return(tex);
            }
            else if (texinfo.ResourceType == ResourceType.Texture3D)
            {
                throw new NotImplementedException();
            }
            else if (texinfo.ResourceType == ResourceType.Texture3DVolume)
            {
                throw new NotImplementedException();
            }                                                                                                       //FIXME: Should we handle this here too?
            else if (texinfo.ResourceType == ResourceType.TextureCube)
            {
                throw new NotImplementedException();
            }
            else
            {
                return(null);
            }
        }
예제 #11
0
 public static Texture FromFile(GraphicsDevice graphicsDevice, Stream textureStream, TextureCreationParameters creationParameters)
 {
     throw new NotImplementedException();
 }