Class GraphicsDeviceExtensions
Provides extension methods for the GraphicsDevice to simplify common operations related to graphics rendering.
public static class GraphicsDeviceExtensions
- Inheritance
-
GraphicsDeviceExtensions
Methods
GetAspectRatio(GraphicsDevice)
The back buffer's width divided by its height: the aspect ratio of the window the game draws into.
public static float GetAspectRatio(this GraphicsDevice graphics)
Parameters
graphicsGraphicsDeviceThe GraphicsDevice whose back buffer is measured.
Returns
- float
Width over height, so 1.777 for a 16:9 window.
GetWindowSize(GraphicsDevice)
Retrieves the current window size of the GraphicsDevice as an Int2 structure.
public static Int2 GetWindowSize(this GraphicsDevice graphics)
Parameters
graphicsGraphicsDeviceThe GraphicsDevice for which the window size should be retrieved.
Returns
- Int2
An Int2 representing the current window size. The X value corresponds to the window's width, and the Y value corresponds to the window's height.
Remarks
This method provides a convenient way to access the dimensions of the back buffer, which corresponds to the size of the window in which the game or application is running.