Example #1
0
        static Texture2D GetNewTexture()
        {
            var texconfig = new TextureConfiguration {
                Interpolation = InterpolationMode.Linear,
                Mipmap        = false
            };

            return(new Texture2D(texconfig, TEXTURE_SIZE, TEXTURE_SIZE));
        }
Example #2
0
        /// <summary>
        /// Load a Texture2 from a file.
        /// </summary>
        /// <returns>The Texture2D.</returns>
        /// <param name="path">Path to the texture.</param>
        /// <param name = "config">The texture configuration.</param>
        public static Texture2D FromFile(string path, TextureConfiguration config)
        {
            // Throw if the file doesn't exist
            if (!File.Exists(path))
            {
                LogExtensions.ThrowStatic("Could not find file '{0}'", path);
            }

            Texture2D tex;

            // Load the image
            int x = -1, y = -1, n = -1;
            var data = Stb.Load(path, ref x, ref y, ref n, 4);

            tex = new Texture2D(config, x, y);
            tex.SetData(data, null);
            Stb.Free(data);
            // Return the texture
            return(tex);
        }
Example #3
0
 public Texture2D(TextureConfiguration config, int width, int height)
     : this(TextureTarget.Texture2D, PixelInternalFormat.Rgba, GLPixelFormat.Bgra, PixelType.UnsignedByte, config.Interpolation, config.Mipmap, width, height)
 {
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="nginz.Texture2D"/> class.
 /// </summary>
 /// <param name="bmp">The bitmap.</param>
 /// <param name = "config">The configuration.</param>
 /// <param name = "preserveBitmap">Whether the bitmap should be disposed.</param>
 public Texture2D(Bitmap bmp, TextureConfiguration config, bool preserveBitmap = false)
     : this(config, bmp.Width, bmp.Height)
 {
     // Update the texture data
     Update(bmp: bmp, preserveBitmap: preserveBitmap);
 }
Example #5
0
 static Texture2D GetNewTexture()
 {
     var texconfig = new TextureConfiguration {
         Interpolation = InterpolationMode.Linear,
         Mipmap = false
     };
     return new Texture2D (texconfig, TEXTURE_SIZE, TEXTURE_SIZE);
 }