How to articles for the Graphics pipeline
These articles provide a details on how to use the Graphics API in MonoGame.
In This Section
This section demonstrates several graphical concepts divided into the following categories:
2D Sprite Rendering
This section walks through several core concepts related to sprite rendering, including drawing text to the screen.
-
Demonstrates how to draw a sprite by using the SpriteBatch class.
How To Draw A Sprite Background
Demonstrates how to draw a foreground and background sprite using the SpriteBatch class, where only part of the foreground sprite masks the background.
-
Demonstrates how to tint a sprite using a Color value.
-
Demonstrates how to rotate a sprite around its center.
-
Demonstrates how to rotate a group of sprites around a single point.
-
Demonstrates how to scale a sprite using a uniform scale.
How To Scale A Sprite using A Matrix
Demonstrates how to scale sprites using a matrix that is created based on the viewport width.
-
Demonstrates how to draw a sprite repeatedly in the x and y directions in one Draw call.
-
Demonstrates how to import a SpriteFont into a project and to draw text using the DrawString method.
-
Demonstrates how to animate a sprite from a texture using a custom class.
How To Make A Scrolling Background
Demonstrates how to draw a scrolling background sprite using the SpriteBatch class.
Cameras
Rotating and Moving the Camera
Demonstrates how to rotate and move a camera in a 3D environment. You can rotate the camera about its y-axis, and move it forward and backward. You control the camera's position and orientation by using the directional keys on your keyboard or by using the D-pad of your gamepad.
-
Demonstrates how to position the camera so that all objects in a scene are within the view frustum while maintaining the camera's original orientation.
-
Demonstrates how to create a render target using the RenderTarget2D class.
How to create a Full-Screen Game
Demonstrates how to start a game in full-screen mode.
How to restrict Aspect Ratio on a Graphics Device
Demonstrates how to create a custom GraphicsDeviceManager that only selects graphics devices with widescreen aspect ratios in full-screen mode.
How to display Multiple Screens with Viewports
Demonstrates how to use viewports to display different scenes simultaneously using two cameras.
3D Rendering
This section walks through several core concepts related 3D rendering and math practices with MonoGame.
-
This example demonstrates how to use the Vector3 and Matrix classes to transform a point. A matrix transform can include scaling, rotating, and translating information.
-
Demonstrates how to create and initialize an instance of the BasicEffect class and use it to draw simple geometry.
Using a Basic Effect with Texturing
Demonstrates how to create and draw a simple quad—two triangles that form a rectangle or square—using DrawUserIndexedPrimitives.
-
Demonstrates how to create a state object using any of the state object classes: BlendState, DepthStencilState, RasterizerState, or SamplerState.
Drawing 3D Primitives using Lists or Strips
Demonstrates how to draw 3D primitives using lines and triangles arranged as strips or lists.
How to render a Model using a Basic Effect
Demonstrates how to load and render a model using the MonoGame Content Pipeline. It is assumed that an existing Windows game project is loaded in MonoGame.
-
Demonstrates how to enable anti-aliasing for your game.
How to create a Custom Vertex Declaration
Demonstrates how to create a custom vertex declaration and use it to render a 3D object.
How to Dynamically Update Vertex Data
Geometry in a 3D game is defined by vertex data. Sometimes, a game needs to modify vertex data or even generate new vertex data dynamically (at run time). Here are some solutions for dynamically updating vertex data.
3D Collisions
Bounding Volumes and Collisions
Collision detection determines whether objects in a game world overlap each other.
Selecting an Object with a Mouse
Demonstrates how to check whether the mouse is positioned over a 3D object by creating a ray starting at the camera's near clipping plane and ending at its far clipping plane.
-
Demonstrates how to use the BoundingSphere class to check whether two models are colliding.