Ejemplo n.º 1
0
        private static unsafe uint SetupPixelFormat(IntPtr surfacep)
        {
            Sdl.Surface *surface = (Sdl.Surface *)surfacep;
            PixelFormat *format  = (PixelFormat *)surface->format;
            uint         glformat;

            if (format->BytesPerPixel == 3)
            {
                glformat = gl.RGB;
            }
            else if (format->BytesPerPixel == 4)
            {
                glformat = gl.RGBA;
            }
            else
            {
                throw new Exception("Surface format not supported (only 24 and 32BPP modes supported at the moment)");
            }

            gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1);
            gl.PixelStorei(gl.UNPACK_ROW_LENGTH,
                           surface->pitch / format->BytesPerPixel);

            return(glformat);
        }
Ejemplo n.º 2
0
        public unsafe void copy_to(IntPtr surfacep, uint surface_x, uint surface_y,
                                   uint texture_x, uint texture_y,
                                   uint width, uint height)
        {
            Sdl.Surface *surface = (Sdl.Surface *)surfacep;
            PixelFormat *format  = (PixelFormat *)surface->format;

            GlUtil.Assert("Before update texture");

            uint surface_format = SetupPixelFormat(surfacep);


            /* We're extracting sub rectangles from the SDL_Surface pixeldata, by
             * setting the pitch to the real width, but telling OpenGL just our
             * desired image dimensions.
             */
            IntPtr pixeldata = (IntPtr)
                               (((byte *)surface->pixels) + surface_y * surface->pitch
                                + format->BytesPerPixel * surface_x);

            gl.TexSubImage2D(gl.TEXTURE_2D, 0, (int)texture_x, (int)texture_y,
                             (int)width, (int)height, surface_format,
                             gl.UNSIGNED_BYTE, pixeldata);

            GlUtil.Assert("Updating Texture Part");
        }
Ejemplo n.º 3
0
        public PixelFormat
        (
            uint?format        = null,
            Palette *palette   = null,
            byte?bitsPerPixel  = null,
            byte?bytesPerPixel = null,
            uint?rmask         = null,
            uint?gmask         = null,
            uint?bmask         = null,
            uint?amask         = null,
            byte?rloss         = null,
            byte?gloss         = null,
            byte?bloss         = null,
            byte?aloss         = null,
            byte?rshift        = null,
            byte?gshift        = null,
            byte?bshift        = null,
            byte?ashift        = null,
            int?refcount       = null,
            PixelFormat *next  = null
        ) : this()
        {
            if (format is not null)
            {
                Format = format.Value;
            }

            if (palette is not null)
            {
                Palette = palette;
            }

            if (bitsPerPixel is not null)
            {
                BitsPerPixel = bitsPerPixel.Value;
            }

            if (bytesPerPixel is not null)
            {
                BytesPerPixel = bytesPerPixel.Value;
            }

            if (rmask is not null)
            {
                Rmask = rmask.Value;
            }

            if (gmask is not null)
            {
                Gmask = gmask.Value;
            }

            if (bmask is not null)
            {
                Bmask = bmask.Value;
            }

            if (amask is not null)
            {
                Amask = amask.Value;
            }

            if (rloss is not null)
            {
                Rloss = rloss.Value;
            }

            if (gloss is not null)
            {
                Gloss = gloss.Value;
            }

            if (bloss is not null)
            {
                Bloss = bloss.Value;
            }

            if (aloss is not null)
            {
                Aloss = aloss.Value;
            }

            if (rshift is not null)
            {
                Rshift = rshift.Value;
            }

            if (gshift is not null)
            {
                Gshift = gshift.Value;
            }

            if (bshift is not null)
            {
                Bshift = bshift.Value;
            }

            if (ashift is not null)
            {
                Ashift = ashift.Value;
            }

            if (refcount is not null)
            {
                Refcount = refcount.Value;
            }

            if (next is not null)
            {
                Next = next;
            }
        }
Ejemplo n.º 4
0
 public static extern int SetPixelFormatPalette(PixelFormat *format, Palette *palette);
Ejemplo n.º 5
0
 public static extern uint MapRGBA(PixelFormat *format, byte r, byte g, byte b, byte a);
Ejemplo n.º 6
0
 public static extern void GetRGBA(uint pixel, PixelFormat *format, byte *r, byte *g, byte *b, byte *a);
Ejemplo n.º 7
0
 public static extern void FreeFormat(PixelFormat *format);
Ejemplo n.º 8
0
        public Surface
        (
            uint?flags          = null,
            PixelFormat *format = null,
            int?w          = null,
            int?h          = null,
            int?pitch      = null,
            void *pixels   = null,
            void *userdata = null,
            int?locked     = null,
            void *lockData = null,
            Silk.NET.Maths.Rectangle <int>?clipRect = null,
            BlitMap *map = null,
            int?refcount = null
        ) : this()
        {
            if (flags is not null)
            {
                Flags = flags.Value;
            }

            if (format is not null)
            {
                Format = format;
            }

            if (w is not null)
            {
                W = w.Value;
            }

            if (h is not null)
            {
                H = h.Value;
            }

            if (pitch is not null)
            {
                Pitch = pitch.Value;
            }

            if (pixels is not null)
            {
                Pixels = pixels;
            }

            if (userdata is not null)
            {
                Userdata = userdata;
            }

            if (locked is not null)
            {
                Locked = locked.Value;
            }

            if (lockData is not null)
            {
                LockData = lockData;
            }

            if (clipRect is not null)
            {
                ClipRect = clipRect.Value;
            }

            if (map is not null)
            {
                Map = map;
            }

            if (refcount is not null)
            {
                Refcount = refcount.Value;
            }
        }
Ejemplo n.º 9
0
 public static extern Surface *ConvertSurface(Surface *src, PixelFormat *fmt, uint flags);