Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GraphicsContentHelper.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework.Content;
2
4
5internal static class GraphicsContentHelper
6{
7 internal static GraphicsDevice GraphicsDeviceFromContentReader(ContentReader contentReader)
8 {
9 IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)contentReader.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));
10 if (graphicsDeviceService == null)
11 {
12 throw contentReader.CreateContentLoadException(FrameworkResources.NoGraphicsDeviceContent);
13 }
14 GraphicsDevice graphicsDevice = graphicsDeviceService.GraphicsDevice;
15 if (graphicsDevice == null)
16 {
17 throw contentReader.CreateContentLoadException(FrameworkResources.NoGraphicsDeviceContent);
18 }
19 GraphicsProfile graphicsProfile = graphicsDevice.GraphicsProfile;
20 GraphicsProfile graphicsProfile2 = (GraphicsProfile)contentReader.graphicsProfile;
21 if (!IsProfileCompatible(graphicsProfile, graphicsProfile2))
22 {
23 throw contentReader.CreateContentLoadException(FrameworkResources.BadXnbGraphicsProfile, graphicsProfile2, graphicsProfile);
24 }
25 return graphicsDevice;
26 }
27
28 private static bool IsProfileCompatible(GraphicsProfile deviceProfile, GraphicsProfile contentProfile)
29 {
30 switch (deviceProfile)
31 {
32 case GraphicsProfile.Reach:
33 return contentProfile == GraphicsProfile.Reach;
34 case GraphicsProfile.HiDef:
35 if (contentProfile != 0)
36 {
37 return contentProfile == GraphicsProfile.HiDef;
38 }
39 return true;
40 default:
41 return false;
42 }
43 }
44}
static bool IsProfileCompatible(GraphicsProfile deviceProfile, GraphicsProfile contentProfile)
static GraphicsDevice GraphicsDeviceFromContentReader(ContentReader contentReader)