Graphics Service |
This section describes the graphics service.
This topic contains the following sections:
The graphics service (interface IGraphicsService) is the main interface for graphics-related tasks. It provides access to the graphics device (see GraphicsDevice), the main game window (see GameForm, Windows only), the graphics screens (see Graphics Screens) and a RenderTargetPool.
Graphics screens render game content, like the 3D scene or the HUD. The graphics service manages a collection of screens, which are rendered back to front. The graphics are displayed in a presentation target (see Windows Forms, WPF, UWP Interoperability), which is either a window, a Windows Forms control or a WPF control.
The graphics service is implemented by the class GraphicsManager. The following examples shows how to add the graphics service to an XNA game.
using DigitalRune.Graphics; using Microsoft.Xna.Framework; namespace GeneralSamples { public class MyGame : Game { private GraphicsManager _graphicsManager; public MyGame() { var graphicsDeviceManager = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1280, PreferredBackBufferHeight = 720, PreferMultiSampling = false, }; Content.RootDirectory = "Content"; } protected override void Initialize() { _graphicsManager = new GraphicsManager(GraphicsDevice, Window, Content); ... base.Initialize(); } protected override void Update(GameTime gameTime) { ... base.Update(gameTime); } protected override void Draw(GameTime gameTime) { _graphicsManager.Update(gameTime.ElapsedGameTime); _graphicsManager.Render(false); base.Draw(gameTime); } } }