Beispiel #1
0
        internal void Initialize(IntPtr window, int width, int height)
        {
            _ctx = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED | SDL.SDL_RendererFlags.SDL_RENDERER_TARGETTEXTURE | SDL.SDL_RendererFlags.SDL_RENDERER_PRESENTVSYNC);

            SDL.SDL_RendererInfo rendererInfo;

            SDL.SDL_GetRendererInfo(_ctx, out rendererInfo);

            MaxTextureWidth  = rendererInfo.max_texture_width;
            MaxTextureHeight = rendererInfo.max_texture_height;

            SDL.SDL_RenderSetIntegerScale(_ctx, SDL.SDL_bool.SDL_TRUE);
            SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_SCALE_QUALITY, "0");
            SDL.SDL_SetRenderDrawBlendMode(_ctx, SDL.SDL_BlendMode.SDL_BLENDMODE_NONE);

            SDL.SDL_SetRenderDrawColor(_ctx, 0, 0, 0, 255);
            SDL.SDL_RenderClear(_ctx);

            _resolution = new Size(width, height);

            _baseSurface = new PicoSurface(this, _resolution.Width, _resolution.Height, PicoSurface.AccessType.Target);

            _renderRect = new SDL.SDL_Rect()
            {
                x = 0, y = 0, w = _resolution.Width, h = _resolution.Height
            };
        }
Beispiel #2
0
        internal Font(PicoGfx gfx, Pixmap pixmap)
        {
            GlyphQuadMap = new Dictionary <int, SDL.SDL_Rect>();

            FontSurface = new PicoSurface(gfx, pixmap, PicoSurface.AccessType.Static);

            LoadGlyphMap();
        }
Beispiel #3
0
        public void DrawText(int x, int y, Font font, string text)
        {
            PicoSurface surface = font.FontSurface;

            SDL.SDL_Rect destRect = new SDL.SDL_Rect();

            int glyphSize = font.GlyphSize;

            for (int i = 0; i < text.Length; i++)
            {
                SDL.SDL_Rect glyphRect = font[text[i]];

                destRect.x = x + (i * glyphSize);
                destRect.y = y;
                destRect.w = glyphSize;
                destRect.h = glyphSize;

                SDL.SDL_RenderCopy(_ctx, surface.Texture, ref glyphRect, ref destRect);
            }
        }
Beispiel #4
0
 public void BeginSurface(PicoSurface surface)
 {
     SDL.SDL_SetRenderTarget(_ctx, surface.Texture);
     SDL.SDL_SetRenderDrawColor(_ctx, 0, 0, 0, 255);
     SDL.SDL_RenderClear(_ctx);
 }