Beispiel #1
0
        // Draws a sprite from a sprite sheet in
        // the specified X and Y position of the screen

        public void DrawImage(Image images, short x, short y, short width, short height)
        {
            Sdl.SDL_Rect src  = new Sdl.SDL_Rect(x, y, width, height);
            Sdl.SDL_Rect dest = new Sdl.SDL_Rect((short)images.GetX(), (short)images.GetY(),
                                                 width, height);
            Sdl.SDL_BlitSurface(images.GetImage(), ref src, screen, ref dest);
        }
Beispiel #2
0
        public void Draw(byte[] graphics)
        {
            //surface.Lock();
            Sdl.SDL_LockSurface(surface.Handle);
            var point = new Sdl.SDL_Rect
            {
                w = 10,
                h = 10
            };

            for (var i = 0; i < (H * PixelSize); i += 10)
            {
                for (var j = 0; j < (W * PixelSize); j += 10)
                {
                    //screen[j + i * surface.w] = graphics[(j / 10) + (i / 10) * 64] ? 0xFFFFFFFF : 0;
                    var value = graphics[(j / 10) + (i / 10) * 64] != 0 ? 0xFFFFFFFF : 0;
                    point.x = (short)j;
                    point.y = (short)i;
                    Sdl.SDL_FillRect(surface.Handle, ref point, value); //directly calling surface,Fill(...) here fails
                }
            }

            Sdl.SDL_UnlockSurface(surface.Handle); //surface.Unlock();
            surface.Update();
            Sdl.SDL_Delay(15);
        }
Beispiel #3
0
    static short startX, startY; // For Scroll


    public static void Init(short w, short h, int colors, bool fullScreen)
    {
        width = w;
        height = h;

        int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT;
        if (fullScreen)
            flags |= Sdl.SDL_FULLSCREEN;
        Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
        hiddenScreen = Sdl.SDL_SetVideoMode(
          width,
          height,
          colors,
          flags);

        Sdl.SDL_Rect rect2 =
          new Sdl.SDL_Rect(0, 0, (short)width, (short)height);
        Sdl.SDL_SetClipRect(hiddenScreen, ref rect2);

        SdlTtf.TTF_Init();

        // Joystick initialization
        isThereJoystick = true;
        if (Sdl.SDL_NumJoysticks() < 1)
            isThereJoystick = false;

        if (isThereJoystick)
        {
            joystick = Sdl.SDL_JoystickOpen(0);
            if (joystick == IntPtr.Zero)
                isThereJoystick = false;
        }

    }
Beispiel #4
0
 // Clears the menu of player ( right part)
 public void ClearRightPart()
 {
     // x, y, width, height
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(
         600, 200, 400, (short)(height));
     Sdl.SDL_FillRect(hiddenScreen, ref source, 0);
 }
Beispiel #5
0
 public static void DrawSprite(Image image, short xScreen, short yScreen,
                               short x, short y, short width, short height)
 {
     Sdl.SDL_Rect src  = new Sdl.SDL_Rect(x, y, width, height);
     Sdl.SDL_Rect dest = new Sdl.SDL_Rect(xScreen, yScreen, width, height);
     Sdl.SDL_BlitSurface(image.ImagePtr, ref src, screen, ref dest);
 }
Beispiel #6
0
    // Private (auxiliar) methods

    private static void drawHiddenImage(IntPtr image, int x, int y)
    {
        Sdl.SDL_Rect origin = new Sdl.SDL_Rect(0, 0, width, height);
        Sdl.SDL_Rect dest   = new Sdl.SDL_Rect((short)x, (short)y,
                                               width, height);
        Sdl.SDL_BlitSurface(image, ref origin, hiddenScreen, ref dest);
    }
Beispiel #7
0
    public Hardware(short width, short height, short depth, bool fullScreen)
    {
        screenWidth  = width;
        screenHeight = height;
        colorDepth   = depth;

        Red   = new Sdl.SDL_Color(255, 0, 0);
        White = new Sdl.SDL_Color(255, 255, 255);

        TextNums  = new IntPtr[10];
        TextColon = new IntPtr();
        TextComma = new IntPtr();

        int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT;

        if (fullScreen)
        {
            flags = flags | Sdl.SDL_FULLSCREEN;
        }

        Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
        screen = Sdl.SDL_SetVideoMode(screenWidth, screenHeight, colorDepth, flags);
        Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight);
        Sdl.SDL_SetClipRect(screen, ref rect);

        SdlTtf.TTF_Init();
    }
Beispiel #8
0
        public void Load()

        {
            string file = "test.bmp";

            IntPtr surfacePtr = VideoSetup();

            IntPtr imagePtr = SdlImage.IMG_Load(file);

            Assert.IsFalse(imagePtr == IntPtr.Zero);

            Sdl.SDL_Rect rect1 = new Sdl.SDL_Rect(0, 0, 200, 200);

            Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, 200, 200);

            int result = Sdl.SDL_BlitSurface(imagePtr, ref rect1, surfacePtr, ref rect2);

            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 200, 200);

            Thread.Sleep(sleepTime);

            Assert.AreEqual(result, 0);

            this.Quit();
        }
Beispiel #9
0
        public void FillRectAndFlip()
        {
            IntPtr surfacePtr = VideoSetup();

            Assert.IsNotNull(surfacePtr);
            Sdl.SDL_Rect rect = new Sdl.SDL_Rect(100, 100, 100, 100);
            Sdl.SDL_FillRect(surfacePtr, ref rect, 10000);
            int resultFlip = Sdl.SDL_Flip(surfacePtr);

            Thread.Sleep(sleepTime);

            Sdl.SDL_Rect rect2   = new Sdl.SDL_Rect(150, 150, 150, 150);
            int          result2 = Sdl.SDL_FillRect(surfacePtr, ref rect2, 1000);

            Assert.AreEqual(result2, 0);
            resultFlip = Sdl.SDL_Flip(surfacePtr);
            Assert.AreEqual(resultFlip, 0);
            Thread.Sleep(sleepTime);

            int result3 = Sdl.SDL_FillRect(surfacePtr, ref rect, 5000);

            Assert.AreEqual(result3, 0);
            resultFlip = Sdl.SDL_Flip(surfacePtr);

            Assert.AreEqual(resultFlip, 0);
            Thread.Sleep(sleepTime);
            Sdl.SDL_FreeSurface(surfacePtr);
        }
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        public void Run()
        {
            int  flags    = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT);
            int  bpp      = 16;
            int  width    = 640;
            int  height   = 480;
            bool quitFlag = false;

            Random rand = new Random();

            //string musicFile = "Data/SdlExamples.Reactangles.sound.ogg";

            Sdl.SDL_Event evt;

            try
            {
                Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
                Sdl.SDL_WM_SetCaption("Tao.Sdl Example - GfxPrimitives", "");
                IntPtr surfacePtr = Sdl.SDL_SetVideoMode(
                    width,
                    height,
                    bpp,
                    flags);

                Sdl.SDL_Rect rect2 =
                    new Sdl.SDL_Rect(0, 0, (short)width, (short)height);
                Sdl.SDL_SetClipRect(surfacePtr, ref rect2);
                while (quitFlag == false)
                {
                    Sdl.SDL_PollEvent(out evt);

                    if (evt.type == Sdl.SDL_QUIT)
                    {
                        quitFlag = true;
                    }
                    else if (evt.type == Sdl.SDL_KEYDOWN)
                    {
                        if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE) ||
                            (evt.key.keysym.sym == (int)Sdl.SDLK_q))
                        {
                            quitFlag = true;
                        }
                    }

                    try
                    {
                        SdlGfx.filledCircleRGBA(surfacePtr, (short)rand.Next(10, width - 100), (short)rand.Next(10, height - 100), (short)rand.Next(10, 100), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255));
                        Sdl.SDL_Flip(surfacePtr);
                        Thread.Sleep(100);
                    }
                    catch (Exception) {}
                }
            }
            catch
            {
                Sdl.SDL_Quit();
                throw;
            }
        }
Beispiel #11
0
 public void DrawEnemy(Enemy enemy)
 {
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(0, 0, enemy.Width,
                                            enemy.Height);
     Sdl.SDL_Rect target = new Sdl.SDL_Rect(enemy.X, enemy.Y,
                                            enemy.Width, enemy.Height);
     Sdl.SDL_BlitSurface(enemy.EnemyImage.ImagePtr, ref source, screen, ref target);
 }
Beispiel #12
0
 public void DrawSprite(
     Image image, short xScreen, short yScreen,
     short x, short y, short width, short height)
 {
     Sdl.SDL_Rect src  = new Sdl.SDL_Rect(x, y, width, height);
     Sdl.SDL_Rect dest = new Sdl.SDL_Rect(xScreen, yScreen, width, height);
     Sdl.SDL_BlitSurface(image.GetPointer(), ref src, hiddenScreen, ref dest);
 }
Beispiel #13
0
 //Method to draw image in the current coordinates.
 public void DrawImage(Image img)
 {
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(0, 0, img.ImageWidth,
                                            img.ImageHeight);
     Sdl.SDL_Rect target = new Sdl.SDL_Rect(img.X, img.Y,
                                            img.ImageWidth, img.ImageHeight);
     Sdl.SDL_BlitSurface(img.ImagePtr, ref source, screen, ref target);
 }
Beispiel #14
0
 // Clears the bottom of the screen
 public void ClearBottom()
 {
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(0,
                                            GameController.SCREEN_HEIGHT,
                                            screenWidth, (short)(screenHeight -
                                                                 GameController.SCREEN_HEIGHT));
     Sdl.SDL_FillRect(screen, ref source, 0);
 }
Beispiel #15
0
 // Writes a text from IntPtr
 public void WriteTextRender(IntPtr textAsImage, short x, short y)
 {
     Sdl.SDL_Rect src = new Sdl.SDL_Rect(0, 0, screenWidth,
                                         screenHeight);
     Sdl.SDL_Rect dest = new Sdl.SDL_Rect(x, y, screenWidth,
                                          screenHeight);
     Sdl.SDL_BlitSurface(textAsImage, ref src, screen, ref dest);
 }
Beispiel #16
0
 // Draws an image in its current coordinates
 public void DrawImage(Image img)
 {
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(0, 0, img.width,
                                            img.height);
     Sdl.SDL_Rect target = new Sdl.SDL_Rect(img.X, img.Y,
                                            img.width, img.height);
     Sdl.SDL_BlitSurface(
         img.GetPointer(), ref source, hiddenScreen, ref target);
 }
Beispiel #17
0
 //New exprerimental DrawImage
 public void DrawImageMap(Image img, short XMap, short YMap)
 {
     Sdl.SDL_Rect source = new Sdl.SDL_Rect(0, 0, img.ImageWidth,
                                            img.ImageHeight);
     Sdl.SDL_Rect target = new Sdl.SDL_Rect((short)(img.X - XMap),
                                            (short)(img.Y - YMap),
                                            img.ImageWidth, img.ImageHeight);
     Sdl.SDL_BlitSurface(img.ImagePtr, ref source, screen, ref target);
 }
Beispiel #18
0
    // Operaciones

    /// Inicializa el modo grafico a un cierto ancho, alto y profundidad de color, p.ej. 640, 480, 24 bits
    public static void Inicializar(short an, short al, int colores, bool pantallaCompleta)
    {
        //System.Console.Write("Inicializando...");
        ancho = an;
        alto  = al;

        int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT;

        if (pantallaCompleta)
        {
            flags |= Sdl.SDL_FULLSCREEN;
        }
        Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
        pantallaOculta = Sdl.SDL_SetVideoMode(
            ancho,
            alto,
            colores,
            flags);

        // Preparamos el rectángulo de la pantalla
        Sdl.SDL_Rect rect2 =
            new Sdl.SDL_Rect(0, 0, (short)ancho, (short)alto);
        Sdl.SDL_SetClipRect(pantallaOculta, ref rect2);

        // Soporte de tipos de letra TTF
        SdlTtf.TTF_Init();

        // Inicialización del joystick
        existeJoystick = true;
        if (Sdl.SDL_NumJoysticks() < 1)
        {
            existeJoystick = false;
        }

        if (existeJoystick)
        {
            joystick = Sdl.SDL_JoystickOpen(0);
            if (joystick == IntPtr.Zero)
            {
                existeJoystick = false;
            }
        }

        // Inicializamos sonidos con SDL mixer
        if (SdlMixer.Mix_OpenAudio(22050,
                                   unchecked (Sdl.AUDIO_S16LSB), 2, 1024) == -1)
        {
            ErrorFatal("No se ha podido inicializar el Sonido");
        }

        // Pausa entre clics, para evitar dos clic demasiado cercanos
        pausaClics   = 10;
        instanteClic = Sdl.SDL_GetTicks();
    }
Beispiel #19
0
        public void SoftStretch(SurfaceEx sourceSurface, Rectangle destinationRectangle, Rectangle sourceRectangle)
        {
            Sdl.SDL_Rect sdl_Rect  = SurfaceEx.ConvertRecttoSDLRect(sourceRectangle);
            Sdl.SDL_Rect sdl_Rect2 = SurfaceEx.ConvertRecttoSDLRect(destinationRectangle);
            int          num       = SurfaceEx.SDL_SoftStretch(sourceSurface.Handle, ref sdl_Rect, base.Handle, ref sdl_Rect2);

            GC.KeepAlive(this);
            if (num != 0)
            {
                throw SdlException.Generate();
            }
        }
Beispiel #20
0
        private void InitWindow(Configuration configuration)
        {
            width                = configuration.resWidth;
            height               = configuration.resHeight;
            centerX              = width / 2;
            centerY              = height / 2;
            bpp                  = configuration.bpp;
            Name                 = configuration.title;
            Fullscreen           = configuration.fullscreen;
            buttonActionDelegate = new ButtonAction(buttonAction);
            alwaysUpdateMouse    = true;
            exceptions           = 0;


            if (Fullscreen)
            {
                flags = (/*Sdl.SDL_HWACCEL | Sdl.SDL_HWSURFACE |*/ Sdl.SDL_OPENGL | Sdl.SDL_FULLSCREEN);

                bpp = 32 /*System.Windows.Forms.Screen.PrimaryScreen.BitsPerPixel*/;

                /*Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
                 * Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;*/
            }
            else
            {
                flags = (/*Sdl.SDL_HWACCEL | Sdl.SDL_HWSURFACE |*/ Sdl.SDL_OPENGL);
            }

            quitFlag = false;
            try
            {
                Log.Write("InitSDL: " + Width.ToString() + "x" + Height.ToString() + "@" + bpp.ToString());

                Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
                Sdl.SDL_WM_SetCaption(Name, "");

                IntPtr surfacePtr = Sdl.SDL_SetVideoMode(Width, Height, 32, flags);

                Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)Width, (short)Height);
                Sdl.SDL_SetClipRect(surfacePtr, ref rect2);
                Sdl.SDL_WarpMouse((short)centerX, (short)centerY);
                Log.Write("[" + (short)centerX + ", " + (short)centerY + "] <- [" + centerX + ", " + centerY + "]");
                Sdl.SDL_ShowCursor(0);
            }
            catch
            {
                Sdl.SDL_Quit();                 // Vi kallar inte Quit() här för detta är Ändå första funktionen så om det inte går här så blir det så mycket null fel I Quit();
                quitFlag = true;
                Log.Write("Create OpenGL Window Failure", LogType.CriticalError);
                throw;
            }
        }
Beispiel #21
0
    public static void Init(short w, short h, int colorDepth, bool fullScreen)
    {
        width  = w;
        height = h;
        colors = colorDepth;

        flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT;
        if (fullScreen)
        {
            flags |= Sdl.SDL_FULLSCREEN;
        }
        Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
        hiddenScreen = Sdl.SDL_SetVideoMode(
            width,
            height,
            colors,
            flags);

        Sdl.SDL_Rect rect2 =
            new Sdl.SDL_Rect(0, 0, (short)width, (short)height);
        Sdl.SDL_SetClipRect(hiddenScreen, ref rect2);

        SdlTtf.TTF_Init();

        // Joystick initialization
        isThereJoystick = true;
        if (Sdl.SDL_NumJoysticks() < 1)
        {
            isThereJoystick = false;
        }

        if (isThereJoystick)
        {
            joystick = Sdl.SDL_JoystickOpen(0);
            if (joystick == IntPtr.Zero)
            {
                isThereJoystick = false;
            }
        }

        // Sound initialization
        SdlMixer.Mix_OpenAudio(22050,
                               (short)SdlMixer.MIX_DEFAULT_FORMAT, 2, 1024);


        // Time lapse between two consecutive mouse clicks,
        // so that they are not too near
        mouseClickLapse = 10;
        lastMouseClick  = Sdl.SDL_GetTicks();
    }
Beispiel #22
0
 private void GfxSetup()
 {
     surfacePtr = Sdl.SDL_SetVideoMode(
         width,
         height,
         bpp,
         flags);
     rect2 = new Sdl.SDL_Rect(
         0,
         0,
         (short)width,
         (short)height);
     Sdl.SDL_SetClipRect(surfacePtr, ref rect2);
 }
Beispiel #23
0
        private void TimerTick(object sender, EventArgs e)
        {
            if (qView != null)
            {
                WorldDefinition.World.Clock.tick();
                WorldDefinition.World.Clock.tick();

                sourceRect = new Sdl.SDL_Rect((short)ScrollPosition.X, (short)ScrollPosition.Y, (short)width, (short)height);
                dst        = new Sdl.SDL_Rect(0, 0, (short)width, (short)height);
                Tao.Sdl.Sdl.SDL_BlitSurface(qView.OffscreenBuffer.SurfacePtr(), ref sourceRect, screen.Handle, ref dst);
            }

            FinalDraw();
        }
Beispiel #24
0
        private int checkMask(Surface source, Sdl.SDL_Rect r, Color fill)
        {
            int col, pink1, pink2;

            String curSig   = "mask" + fill.ToArgb();
            int    curIndex = -1;

            for (int i = 1; i <= currentSurfaceCount; i++)
            {
                if (surfaceSignatures[i] == curSig)
                {
                    curIndex = i;
                }
            }

            if (curIndex == -1)
            {
                curIndex = currentSurfaceCount;
                surfacePtrs[curIndex] = Sdl.SDL_CreateRGBSurface(flags, r.w, r.h, bpp, 0, 0, 0, 0);

                Sdl.SDL_Surface maskSurf = (Sdl.SDL_Surface)Marshal.PtrToStructure(surfacePtrs[curIndex], typeof(Sdl.SDL_Surface));
                col = Sdl.SDL_MapRGB(maskSurf.format, fill.R, fill.G, fill.B);

                pink1 = Sdl.SDL_MapRGB(source.surface.format, 255, 0, 255);
                pink2 = Sdl.SDL_MapRGB(maskSurf.format, 255, 0, 255);

                drect = new Sdl.SDL_Rect(0, 0, 1, 1);
                for (int xx = 0; xx < maskSurf.w; xx++)
                {
                    for (int yy = 0; yy < maskSurf.h; yy++)
                    {
                        drect.x = (short)xx;
                        drect.y = (short)yy;
                        if (this.GetIntPixel(source.SurfacePtr(), xx, yy) != pink1)
                        {
                            Sdl.SDL_FillRect(surfacePtrs[curIndex], ref drect, col);
                        }
                        else
                        {
                            Sdl.SDL_FillRect(surfacePtrs[curIndex], ref drect, pink2);
                        }
                    }
                }
                Tao.Sdl.Sdl.SDL_SetColorKey(surfacePtrs[curIndex], Sdl.SDL_SRCCOLORKEY | Sdl.SDL_RLEACCEL, pink1);
                surfaceSignatures[curIndex] = curSig;
                currentSurfaceCount++;
                Console.WriteLine("Created a new one at: " + curIndex + ", sig: " + curSig);
            }
            return(curIndex);
        }
Beispiel #25
0
        public void EscribirTexto(string texto, short x, short y, short size, byte r, byte g, byte b)
        {
            IntPtr tipoLetra = SdlTtf.TTF_OpenFont("SEGOEPRB.TTF", size);

            Sdl.SDL_Color color           = new Sdl.SDL_Color(r, g, b);
            IntPtr        textoComoImagen = SdlTtf.TTF_RenderText_Solid(tipoLetra, texto, color);

            if (textoComoImagen == IntPtr.Zero)
            {
                Environment.Exit(5);
            }
            Sdl.SDL_Rect origen = new Sdl.SDL_Rect(0, 0, ancho, alto);
            Sdl.SDL_Rect dest   = new Sdl.SDL_Rect(x, y, ancho, alto);
            Sdl.SDL_BlitSurface(textoComoImagen, ref origen, pantalla, ref dest);
        }
Beispiel #26
0
        // Adapted method to clear the roll if i pass the string "roll" or the chip number
        // if I pass parameter chip.

        public void Clear(string cleared)
        {
            if (cleared == "roll")
            {
                Sdl.SDL_Rect source = new Sdl.SDL_Rect(940, 330, screenWidth, screenHeight);
                Sdl.SDL_FillRect(screen, ref source, 0);
            }
            else if (cleared == "chip")
            {
                Sdl.SDL_Rect source = new Sdl.SDL_Rect(1050, 380, 100, 100);
                Sdl.SDL_FillRect(screen, ref source, 0);
            }

            UpdateScreen();
        }
Beispiel #27
0
    // Writes a text in the specified coordinates
    public void WriteText(string text, short x, short y, byte r, byte g, byte b,
                          Font fontType)
    {
        Sdl.SDL_Color color       = new Sdl.SDL_Color(r, g, b);
        IntPtr        textAsImage = SdlTtf.TTF_RenderText_Solid(fontType.GetFontType(),
                                                                text, color);

        if (textAsImage == IntPtr.Zero)
        {
            Environment.Exit(5);
        }
        Sdl.SDL_Rect src  = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight);
        Sdl.SDL_Rect dest = new Sdl.SDL_Rect(x, y, screenWidth, screenHeight);
        Sdl.SDL_BlitSurface(textAsImage, ref src, screen, ref dest);
    }
Beispiel #28
0
        public void UpdateRects()
        {
            //TODO: Must figure out a real test for this method.
            IntPtr surfacePtr = VideoSetup();

            Sdl.SDL_Rect   rect  = new Sdl.SDL_Rect(100, 100, 100, 100);
            Sdl.SDL_Rect   rect2 = new Sdl.SDL_Rect(150, 150, 150, 150);
            Sdl.SDL_Rect[] rects =
            {
                new Sdl.SDL_Rect(100, 100, 100, 100),
                new Sdl.SDL_Rect(150, 150, 150, 150)
            };
            Sdl.SDL_UpdateRects(surfacePtr, rects.Length, rects);
            Sdl.SDL_FreeSurface(surfacePtr);
        }
Beispiel #29
0
        public void zoomSurface()
        {
            this.InitSdl();
            Sdl.SDL_Rect rect1          = new Sdl.SDL_Rect(0, 0, 400, 400);
            Sdl.SDL_Rect rect2          = new Sdl.SDL_Rect(0, 0, 400, 400);
            IntPtr       bmpImagePtr    = Sdl.SDL_LoadBMP("test.bmp");
            IntPtr       zoomSurfacePtr = SdlGfx.zoomSurface(bmpImagePtr, 5, 2, SdlGfx.SMOOTHING_OFF);

            Sdl.SDL_BlitSurface(zoomSurfacePtr, ref rect1, surfacePtr, ref rect2);
            Assert.IsNotNull(zoomSurfacePtr);
            Assert.IsFalse(zoomSurfacePtr == IntPtr.Zero);
            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 400, 400);

            //int results = Sdl.SDL_Flip(surfacePtr);
            Thread.Sleep(sleepTime);
        }
Beispiel #30
0
    public static void Show(short width, short height, short colorBits)
    {
        screenWidth  = width;
        screenHeight = height;
        colorDepth   = colorBits;

        int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF |
                    Sdl.SDL_ANYFORMAT;

        Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
        screen = Sdl.SDL_SetVideoMode(screenWidth, screenHeight,
                                      colorDepth, flags);
        Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, screenWidth,
                                             screenHeight);
        Sdl.SDL_SetClipRect(screen, ref rect);
    }