public Rect(SDL2.SDL.SDL_Rect rect) { x = rect.x; y = rect.y; w = rect.w; h = rect.h; }
public static void SetFont(string Path, int CharCountX = 16, int CharCountY = 16) { CartConsole.FontPath = Path; CartConsole.CharCountX = CharCountX; CartConsole.CharCountY = CharCountY; if (FontTex != IntPtr.Zero) { SDL.SDL_FreeSurface(FontTex); FontTex = IntPtr.Zero; } FontTex = SDLi.IMG_Load(Path); if (FontTex == IntPtr.Zero) throw new Exception("Could not load font:\n" + Path); SDL.SDL_SetColorKey(FontTex, 1, SDL.SDL_MapRGB(PixelFormat, 255, 0, 255)); SDL.SDL_SetSurfaceBlendMode(FontTex, SDL.SDL_BlendMode.SDL_BLENDMODE_NONE); var FontTexTmp = SDL.SDL_CreateTextureFromSurface(Rend, FontTex); SDL.SDL_FreeSurface(FontTex); FontTex = FontTexTmp; uint Format = 0; int Access = 0; if (SDL.SDL_QueryTexture(FontTex, out Format, out Access, out FontW, out FontH) != 0) throw new Exception(SDL.SDL_GetError()); POS = new SDL.SDL_Rect(); TEXPOS = new SDL.SDL_Rect(); POS.x = POS.y = 0; TEXPOS.w = POS.w = CharW = FontW / CharCountX; TEXPOS.h = POS.h = CharH = FontH / CharCountY; SetSize(W, H); }