示例#1
0
 /// <summary>
 /// Creates a new TextureCubemapArray instance with faces compatible to the given bitmap.
 /// </summary>
 /// <param name="bitmap">Specifies the bitmap to which the new texture will be compatible.</param>
 /// <param name="layers">Specifies the number of array layers the texture will contain.</param>
 /// <param name="texture">Outputs the newly created texture.</param>
 /// <param name="levels">Specifies the number of mipmap levels.</param>
 public static void CreateCompatible(Bitmap bitmap, out TextureCubemapArray texture, int layers, int levels = 0)
 {
     if (bitmap.Width != bitmap.Height)
     {
         throw new ArgumentException("The faces of cube map textures must be square.");
     }
     texture = new TextureCubemapArray(BitmapFormat.Get(bitmap).InternalFormat, bitmap.Width, layers, levels);
 }
示例#2
0
        /// <summary>
        /// Uploads the contents of a bitmap to the given texture layer and level.<br/>
        /// Will result in an OpenGL error if the given bitmap is incompatible with the textures storage.
        /// </summary>
        public static void LoadBitmap(this LayeredTexture texture, Bitmap bitmap, int layer, int level = 0)
        {
            texture.Bind();
            var data = LockBits(bitmap);

            try
            {
                var map = BitmapFormat.Get(bitmap);
                GL.TexSubImage3D(texture.TextureTarget, level, 0, 0, layer, data.Width, data.Height, 1,
                                 map.PixelFormat, map.PixelType, data.Scan0);
            }
            finally
            {
                bitmap.UnlockBits(data);
            }
            CheckError();
        }
示例#3
0
        /// <summary>
        /// Uploads the contents of a bitmap to a single face of the given cube map level.<br/>
        /// Will result in an OpenGL error if the given bitmap is incompatible with the textures storage.
        /// </summary>
        public static void LoadBitmap(this TextureCubemap texture, Bitmap bitmap, int face, int level = 0)
        {
            const TextureTarget firstFace = TextureTarget.TextureCubeMapPositiveX;

            texture.Bind();
            var data = LockBits(bitmap);

            try
            {
                var map = BitmapFormat.Get(bitmap);
                GL.TexSubImage2D(firstFace + face, level, 0, 0, data.Width, data.Height,
                                 map.PixelFormat, map.PixelType, data.Scan0);
            }
            finally
            {
                bitmap.UnlockBits(data);
            }
            CheckError();
        }
示例#4
0
 /// <summary>
 /// Creates a new TextureRectangle instance compatible to the given bitmap.
 /// </summary>
 /// <param name="bitmap">Specifies the bitmap to which the new texture will be compatible.</param>
 /// <param name="texture">Outputs the newly created texture.</param>
 public static void CreateCompatible(Bitmap bitmap, out TextureRectangle texture)
 {
     texture = new TextureRectangle(BitmapFormat.Get(bitmap).InternalFormat, bitmap.Width, bitmap.Height);
 }
示例#5
0
 /// <summary>
 /// Creates a new Texture2DArray instance compatible to the given bitmap.
 /// </summary>
 /// <param name="bitmap">Specifies the bitmap to which the new texture will be compatible.</param>
 /// <param name="texture">Outputs the newly created texture.</param>
 /// <param name="layers">Specifies the number of array layers the texture will contain.</param>
 /// <param name="levels">Specifies the number of mipmap levels.</param>
 public static void CreateCompatible(Bitmap bitmap, out Texture2DArray texture, int layers, int levels = 0)
 {
     texture = new Texture2DArray(BitmapFormat.Get(bitmap).InternalFormat, bitmap.Width, bitmap.Height, layers, levels);
 }