Pre-Built Content |
This section explains how to add pre-built assets (effects, textures) which are required by DigitalRune Graphics at runtime.
Note |
---|
If your game uses only XNA stock effects and if it does not use any of the predefined materials, post-processors or advanced renderers, it is not necessary to add the pre-built content to your project. Some newer platforms (e.g. Linux, Mac OS X, Android, iOS) do not yet support advanced graphics (e.g. deferred rendering, post-processing). In this case there is no pre-built content necessary for this platform. Windows Phone 7 projects do not need pre-built assets at all because custom shaders are not supported on this platform. |
This topic contains the following sections:
DigitalRune Graphics requires several effects and textures. These assets include effects for built-in renderers, post-processing effects, lookup textures, and predefined material effects. These assets are pre-built and can be found in these folders:
Framework | Platform | Content Folder |
---|---|---|
XNA Framework | Windows | Content\XNA\Windows |
XNA Framework | Xbox 360 | Content\XNA\Xbox360 |
MonoGame | Windows | Content\MonoGame\Windows |
MonoGame | Windows Phone 8 | Content\MonoGame\WindowsPhone |
MonoGame | Windows Store | Content\MonoGame\WindowsStore |
Each folder contains either
If the pre-built content consists of a content project (*.contentproj) and XNB files, you need to a add a content reference to this content project in your XNA game project. The content project then automatically copies the pre-built assets to the output folder of the game.
First, you need to include the content project in the solution:
Select the content project for your target platform, for example:
For XNA on Windows (desktop) use
<DIGITALRUNE_FOLDER>\Content\XNA\Windows\DigitalRune.Graphics (Windows).contentproj
For Xbox 360 use
<DIGITALRUNE_FOLDER>\Content\XNA\Xbox360\DigitalRune.Graphics (Xbox 360).contentproj
and click Open.
Then add a content reference to the main project:
The content project copies the pre-built assets to the output folder of the game.
When you initialize the GraphicsManager in your game code, you need to provide a ContentManager which can load the pre-built assets. You can use the default ContentManager of the XNA game (Game.Content) or create a new content manager. For example:
var graphicsContentManager = new ContentManager(Services, "Content"); myGaphicsManager = new GraphicsManager(GraphicsDevice, Window, graphicsContentManager);
Please have a look at the DigitalRune Samples for more detailed example code.
If the pre-built content consists of a ZIP file, this file needs to be copied to the output folder of the game. In the game code you need to create a content manager which can read from the ZIP file using the DigitalRune Storage API.
To automatically add the ZIP file to the output folder of your game:
Select the file DigitalRune.zip for your target platform, for example:
For MonoGame on Windows (desktop) use
<DIGITALRUNE_FOLDER>\Content\MonoGame\Windows\DigitalRune.zip
Click the drop down arrow next to the Add button and select Add As Link.
When you initialize the GraphicsManager in your game code, you need to provide a ContentManager which can load the pre-built assets. For example:
var titleStorage = new TitleStorage("Content"); var graphicsStorage = new ZipStorage(titleStorage, "DigitalRune.zip"); var graphicsContentManager = new StorageContentManager(Services, graphicsStorage); myGaphicsManager = new GraphicsManager(GraphicsDevice, Window, graphicsContentManager);
Please have a look at the DigitalRune Samples for more detailed example code.