internal static Surface INTERNAL_Surface_Create(SDLRenderer renderer, int width, int height, int bpp, uint pixelFormat)
            {
                // Create Surface instance
                var surface = new Surface();

                // Assign the renderer
                surface._sdlRenderer = renderer;

                // Create from the renderer
                surface._sdlSurface = SDL.SDL_CreateRGBSurfaceWithFormat(0, width, height, bpp, pixelFormat);
                if (surface._sdlSurface == IntPtr.Zero)
                {
                    surface.Dispose();
                    return(null);
                }

                // Fetch the Surface formatting information
                if (!surface.FillOutInfo())
                {
                    // Someting dun goned wrung
                    surface.Dispose();
                    return(null);
                }

                return(surface);
            }
Example #2
0
            internal static Font INTERNAL_Font_Create(SDLRenderer renderer, int ptSize, string filename)
            {
                // Create Font instance
                var font = new Font();

                // Assign the renderer
                font._sdlRenderer = renderer;

                // Create from the renderer
                font._ptSize  = ptSize;
                font._sdlFont = SDL_ttf.TTF_OpenFont(filename, ptSize);
                if (font._sdlFont == IntPtr.Zero)
                {
                    font.Dispose();
                    return(null);
                }

                // Fetch the Surface formatting information
                if (!font.FillOutInfo())
                {
                    // Someting dun goned wrung
                    font.Dispose();
                    return(null);
                }

                return(font);
            }
Example #3
0
            protected virtual void Dispose(bool disposing)
            {
                if (_disposed)
                {
                    return;
                }

                if (_sdlFont != IntPtr.Zero)
                {
                    SDL2.SDL_ttf.TTF_CloseFont(_sdlFont);
                }
                _sdlFont     = IntPtr.Zero;
                _sdlRenderer = null;

                _disposed = true;
            }
Example #4
0
            protected virtual void Dispose(bool disposing)
            {
                if (_disposed)
                {
                    return;
                }

                if (_sdlTexture != IntPtr.Zero)
                {
                    SDL.SDL_DestroyTexture(_sdlTexture);
                }
                _sdlTexture = IntPtr.Zero;
                _renderer   = null;

                _disposed = true;
            }
            internal static Surface INTERNAL_Surface_Wrap(SDLRenderer renderer, IntPtr sdlSurface)
            {
                // Create Surface instance
                var surface = new Surface();

                // Assign the renderer
                surface._sdlRenderer = renderer;

                // Assign the SDL_Surface
                surface._sdlSurface = sdlSurface;

                // Fetch the Surface formatting information
                if (!surface.FillOutInfo())
                {
                    // Someting dun goned wrung
                    surface.Dispose();
                    return(null);
                }

                return(surface);
            }
            protected virtual void Dispose(bool disposing)
            {
                if (_disposed)
                {
                    return;
                }

                DeleteTexture();

                if (_sdlSurface != IntPtr.Zero)
                {
                    SDL.SDL_FreeSurface(_sdlSurface);
                }
                _sdlSurface = IntPtr.Zero;
                unsafe
                {
                    _sdlSurfacePtr = null;
                }
                _sdlRenderer = null;

                _disposed = true;
            }