예제 #1
0
 /// <summary>
 /// Use this function to load a surface from a BMP file. 
 /// </summary>
 /// <param name="renderer">The renderer</param>
 /// <param name="fileName">The file containing a BMP image</param>
 public Surface(Renderer renderer, string fileName)
 {
     Handle = SDL.SDL_LoadBMP(fileName);
     if (IntPtr.Zero == Handle)
     {
         throw new Exception("Error while loading bitmap: " + SDL.SDL_GetError());
     }
     _getSurfaceProperties();
 }
예제 #2
0
        /// <summary>
        /// Creates a texture for a rendering context. 
        /// </summary>
        /// <param name="renderer">The rendering context</param>
        /// <param name="pixelFormat">One of the enumerated values in SDL_PixelFormatEnum</param>
        /// <param name="accessMode">One of the enumerated values in SDL_TextureAccess</param>
        /// <param name="width">The width of the texture in pixels</param>
        /// <param name="height">The height of the texture in pixels</param>
        public Texture(Renderer renderer, uint pixelFormat , TextureAccessMode accessMode, int width, int height)
        {
            this.pixelFormat = pixelFormat;
            this.accessMode = accessMode;
            Width = width;
            Height = height;
            isLocked = false;

            Handle = SDL.SDL_CreateTexture(renderer.Handle, pixelFormat, (int)accessMode, width, height);
            if (IntPtr.Zero == Handle)
            {
                throw new Exception("Error while creating texture: " + SDL.SDL_GetError());

            }
        }
예제 #3
0
        /// <summary>
        /// Creates a texture from an existing surface. 
        /// </summary>
        /// <param name="renderer">The rendering context</param>
        /// <param name="surface">The SDL_Surface structure containing pixel data used to fill the texture</param>
        //public Texture(Renderer renderer, Surface surface)
        //{
        //    this.pixelFormat = surface.pixelFormat;
        //    this.accessMode = TextureAccessMode.TEXTUREACCESS_STATIC;
        //    Width = surface.Width;
        //    Height = surface.Height;
        //    Handle = SDL.SDL_CreateTextureFromSurface(renderer.Handle, surface);
        //    if (IntPtr.Zero == Handle)
        //    {
        //        throw new Exception("Error while creating texture from surface: " + SDL.SDL_GetError());
        //    }
        //}
        /// <summary>
        /// Use this function to load a texture from a BMP file. 
        /// </summary>
        /// <param name="renderer">The renderer</param>
        /// <param name="fileName">The file containing a BMP image</param>
        public Texture(Renderer renderer, string fileName)
        {
            Surface sSurface = new Surface(renderer, fileName);

            Handle = SDL.SDL_CreateTextureFromSurface(renderer.Handle, sSurface.Handle);
            if (IntPtr.Zero == Handle)
            {
                throw new Exception("Error while creating texture from bitmap: " + SDL.SDL_GetError());

            }
            Height = sSurface.Height;
            Width = sSurface.Width;
            accessMode = TextureAccessMode.TEXTUREACCESS_STATIC;

            sSurface.Dispose();
        }