Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GpuTextureSerializer.cs
Go to the documentation of this file.
1 using System;
2 using Paradox.Framework.Diagnostics;
3 using Paradox.Framework.Serialization;
4 using Paradox.Framework.Serialization.Contents;
5 
6 namespace Paradox.Framework.Graphics.Data
7 {
8  public class GpuTextureSerializer : ContentSerializerBase<Texture>
9  {
10  private readonly GraphicsDevice graphicsDevice;
11 
12  public GpuTextureSerializer(GraphicsDevice graphicsDevice)
13  {
14  this.graphicsDevice = graphicsDevice;
15  }
16 
17  public override void Serialize(ContentSerializerContext context, ref Texture texture, ref object intermediateData)
18  {
19  if (context.RootContext.ArchiveMode == ArchiveMode.Serialize)
20  throw new NotImplementedException();
21 
22  var textureData = context.RootContext.AssetManager.Load<Image>(context.Url);
23  try
24  {
25  texture = Texture.New(graphicsDevice, textureData);
26  }
27  catch (Exception ex)
28  {
29  Logger.GetLogger("GPUTexture").Error("Unable to load Texture {0}. See Debug for more information", ex, context.Url);
30  }
31  finally
32  {
33  context.RootContext.AssetManager.Unload(textureData);
34  }
35  }
36 
37  public override object Construct(ContentSerializerContext context)
38  {
39  return null;
40  }
41  }
42 }
override object Construct(ContentSerializerContext context)
ArchiveMode
Enumerates the different mode of serialization (either serialization or deserialization).
Definition: ArchiveMode.cs:8
override void Serialize(ContentSerializerContext context, ref Texture texture, ref object intermediateData)