Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
RenderTarget.OpenGL.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
4 using System;
5 using SiliconStudio.Core;
6 using SiliconStudio.Core.ReferenceCounting;
7 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
8 using OpenTK.Graphics.ES30;
9 #else
10 using OpenTK.Graphics.OpenGL;
11 #endif
12 
13 namespace SiliconStudio.Paradox.Graphics
14 {
15  /// <summary>
16  /// A renderable Texture2D.
17  /// </summary>
18  public partial class RenderTarget
19  {
20  /// <summary>
21  /// Initializes a new instance of the <see cref="RenderTarget2D"/> class.
22  /// </summary>
23  /// <param name="device">The device.</param>
24  /// <param name="name">The name of this texture.</param>
25  /// <param name="description">The description.</param>
26  /// <param name="initialize">if set to <c>true</c> [initialize].</param>
27  internal RenderTarget(GraphicsDevice device, Texture texture, ViewType viewType, int arraySlize, int mipSlice, PixelFormat viewFormat = PixelFormat.None)
28  : base(device)
29  {
30  texture.AddReferenceInternal();
31  Texture = texture;
32  Description = texture.Description;
33  resourceId = texture.ResourceId;
34 
35  Width = Math.Max(1, Description.Width >> mipSlice);
36  Height = Math.Max(1, Description.Height >> mipSlice);
37 
38  ViewType = viewType;
39  ArraySlice = arraySlize;
40  MipLevel = mipSlice;
41  ViewFormat = viewFormat == PixelFormat.None ? Description.Format : viewFormat;
42  }
43 
44  /// <inheritdoc/>
45  protected internal override bool OnRecreate()
46  {
47  // Dependency: wait for underlying texture to be recreated first
48  if (Texture.LifetimeState != GraphicsResourceLifetimeState.Active)
49  return false;
50 
51  base.OnRecreate();
52  resourceId = Texture.ResourceId;
53 
54  return true;
55  }
56 
57  protected override void DestroyImpl()
58  {
59  Texture.ReleaseInternal();
60 
61  resourceId = 0;
62 
63  base.DestroyImpl();
64  }
65  }
66 }
67 
68 #endif
ViewType
Defines how a view is selected from a resource.
Definition: ViewType.cs:31
Same as Deferred mode, except sprites are sorted by texture prior to drawing. This can improve perfor...
GraphicsResourceLifetimeState
Describes the lifetime state of a graphics resource.
Creates a render target buffer.
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32