Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SwapChainGraphicsPresenter.OpenTK.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_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
4 using OpenTK;
5 
6 namespace SiliconStudio.Paradox.Graphics
7 {
8  public class SwapChainGraphicsPresenter : GraphicsPresenter
9  {
10  private RenderTarget backBuffer;
11 
12  public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
13  {
14  device.InitDefaultRenderTarget(presentationParameters);
15  backBuffer = device.DefaultRenderTarget;
16  DepthStencilBuffer = device.windowProvidedDepthBuffer;
17  }
18 
19  public override RenderTarget BackBuffer
20  {
21  get { return backBuffer; }
22  }
23 
24  public override object NativePresenter
25  {
26  get { return null; }
27  }
28 
29  public override bool IsFullScreen
30  {
31  get
32  {
33  return ((OpenTK.GameWindow)Description.DeviceWindowHandle.NativeHandle).WindowState == WindowState.Fullscreen;
34  }
35  set
36  {
37  var gameWindow = (OpenTK.GameWindow)Description.DeviceWindowHandle.NativeHandle;
38  if (gameWindow.Exists)
39  gameWindow.WindowState = value ? WindowState.Fullscreen : WindowState.Normal;
40  }
41  }
42 
43  public override void Present()
44  {
45  GraphicsDevice.Begin();
46 
47  // If we made a fake render target to avoid OpenGL limitations on window-provided back buffer, let's copy the rendering result to it
48  if (GraphicsDevice.DefaultRenderTarget != GraphicsDevice.windowProvidedRenderTarget)
49  GraphicsDevice.Copy(GraphicsDevice.DefaultRenderTarget.Texture, GraphicsDevice.windowProvidedRenderTarget.Texture);
50  OpenTK.Graphics.GraphicsContext.CurrentContext.SwapBuffers();
51  GraphicsDevice.End();
52  }
53 
54  protected override void ResizeBackBuffer(int width, int height, PixelFormat format)
55  {
56  }
57 
58  protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format)
59  {
60  ReleaseCurrentDepthStencilBuffer();
61  }
62 
63  protected override void CreateDepthStencilBuffer()
64  {
65  }
66  }
67 }
68 #endif
Creates a render target buffer.
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
Definition: DirectXTexP.h:175
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32