Utility

The Graphics class contains several useful methods and properties that you may want to utilize in your program.

  • Graphics.Windows => Returns a List<Window> with all active windows.

  • Graphics.Screens => Returns a List<Rect>, representing the width and height of all screens.

  • Graphics.Renderers => Returns a List<Renderer> with all active renderers.

  • Graphics.MaxTextureSize => Returns a Size representing the GPU texture size limit.

  • Graphics.ScreenExists(int ScreenIndex) => Returns whether or not there's a screen at the given index.

  • Graphics.GetWidth(int ScreenIndex OR Window w) => Returns the width of the given screen, or the screen the given window is on.

  • Graphics.GetHeight(int ScreenIndex OR Window w) => Returns the height of the given screen, or the screen the given window is on.

  • Graphics.Sleep(long milliseconds) => Sleeps for the given timespan.

circle-exclamation

Graphics.Update() is comprised of three parts, in the following order:

  1. Graphics.UpdateInput(false) => Updates keyboard input for methods like Input.Trigger(), calls the OnTick event on all windows, and calls OnMousePress while the mouse is being pressed.

  2. Graphics.UpdateGraphics(false) => Tells all renderers to re-render if the renderer has been marked "dirty" (i.e. a sprite/viewport/bitmap has been modified in any way that would affect the displayed result). If the argument passed is true, all renderers will re-render regardless of whether or not they are marked "dirty". If vsync is enabled, this method will block until enough time has passed to be synchronized with the refresh rate of the monitor the window is in.

  3. Graphics.UpdateWindows() => Polls all pending SDL events. This is mouse events, exit events, resize events, etc. If this method is not called, the window will freeze.

Last updated