Example #1
0
        /// <summary>Creates a new instance of this class.</summary>
        /// <param name="width">The width of the texture in pixels.</param>
        /// <param name="height">The height of the texture in pixels.</param>
        /// <param name="bitsPerPixel">The number of bits per pixel. Must be 32.</param>
        /// <param name="bytes">The texture data. Pixels are stored row-based from top to bottom, and within a row from left to right. For 32 bits per pixel, four bytes are used in the order red, green, blue and alpha.</param>
        /// <param name="frameInterval">The frame interval</param>
        /// <exception cref="System.ArgumentException">Raised when the number of bits per pixel is not 32.</exception>
        /// <exception cref="System.ArgumentNullException">Raised when the byte array is a null reference.</exception>
        /// <exception cref="System.ArgumentException">Raised when the byte array is of unexpected length.</exception>
        public Texture(int width, int height, int bitsPerPixel, byte[][] bytes, double frameInterval)
        {
            if (bitsPerPixel != 32)
            {
                throw new ArgumentException("The number of bits per pixel is supported.");
            }

            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }

            if (bytes[0].Length != 4 * width * height)
            {
                throw new ArgumentException("The data bytes are not of the expected length.");
            }

            this.Origin           = new ByteArrayOrigin(width, height, bytes, frameInterval);
            this.MyWidth          = width;
            this.MyHeight         = height;
            this.MyBitsPerPixel   = bitsPerPixel;
            this.MyBytes          = bytes;
            this.MyPalette        = null;
            this.MultipleFrames   = true;
            this.FrameInterval    = frameInterval;
            this.TotalFrames      = bytes.Length;
            this.MyOpenGlTextures = new OpenGlTexture[bytes.Length][];
            for (int i = 0; i < bytes.Length; i++)
            {
                MyOpenGlTextures[i] = new[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
            }
        }
Example #2
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="path">The path to the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="currentHost">The callback function to the host application</param>
 public Texture(string path, TextureParameters parameters, Hosts.HostInterface currentHost)
 {
     this.Origin         = new PathOrigin(path, parameters, currentHost);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #3
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="texture">The texture raw data.</param>
 public Texture(OpenBveApi.Textures.Texture texture)
 {
     this.Origin         = new RawOrigin(texture);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #4
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 public Texture(Bitmap bitmap, TextureParameters parameters)
 {
     this.Origin         = new BitmapOrigin(bitmap, parameters);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #5
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
 public Texture(Bitmap bitmap)
 {
     this.Origin         = new BitmapOrigin(bitmap);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #6
0
 /// <summary>Creates a new texture from a texture origin.</summary>
 /// <param name="origin">The texture raw data.</param>
 public Texture(TextureOrigin origin)
 {
     this.Origin              = origin;
     this.MyOpenGlTextures    = new OpenGlTexture[1][];
     this.MyOpenGlTextures[0] = new[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #7
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="texture">The texture raw data.</param>
 public Texture(Texture texture)
 {
     this.Origin              = new RawOrigin(texture);
     this.MyOpenGlTextures    = new OpenGlTexture[1][];
     this.MyOpenGlTextures[0] = new[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #8
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
 public Texture(Bitmap bitmap)
 {
     this.Origin              = new BitmapOrigin(bitmap);
     this.MyOpenGlTextures    = new OpenGlTexture[1][];
     this.MyOpenGlTextures[0] = new[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }