26 using SiliconStudio.Core;
27 using SiliconStudio.Paradox.Graphics;
28 using SiliconStudio.Core.Mathematics;
30 namespace SiliconStudio.
Paradox.Games
38 private int preferredBackBufferHeight;
39 private int preferredBackBufferWidth;
41 private bool isBackBufferToResize;
44 private bool beginDrawOk;
45 private bool windowUserResized;
84 return preferredBackBufferFormat;
89 if (preferredBackBufferFormat != value)
91 preferredBackBufferFormat = value;
92 isBackBufferToResize =
true;
101 public int PreferredBackBufferHeight
105 return preferredBackBufferHeight;
110 if (preferredBackBufferHeight != value)
112 preferredBackBufferHeight = value;
113 isBackBufferToResize =
true;
122 public int PreferredBackBufferWidth
126 return preferredBackBufferWidth;
131 if (preferredBackBufferWidth != value)
133 preferredBackBufferWidth = value;
134 isBackBufferToResize =
true;
147 return preferredDepthStencilFormat;
152 preferredDepthStencilFormat = value;
159 GameContext.RequestedWidth = PreferredBackBufferWidth;
160 GameContext.RequestedHeight = PreferredBackBufferHeight;
162 Window.Visible =
true;
164 Window.ClientSizeChanged += WindowOnClientSizeChanged;
171 var bounds = Window.ClientBounds;
172 format = PreferredBackBufferFormat == PixelFormat.None ? PixelFormat.R8G8B8A8_UNorm : PreferredBackBufferFormat;
174 PreferredBackBufferWidth == 0 || windowUserResized ? bounds.Width : PreferredBackBufferWidth,
175 PreferredBackBufferHeight == 0 || windowUserResized ? bounds.Height : PreferredBackBufferHeight);
180 if (Presenter == null)
183 var
size = GetRequestedSize(out resizeFormat);
184 var presentationParameters =
new PresentationParameters((
int)size.X, (
int)size.Y,
Window.NativeWindow, resizeFormat) { DepthStencilFormat = PreferredDepthStencilFormat };
185 presentationParameters.PresentationInterval = PresentInterval.Immediate;
186 Presenter =
new SwapChainGraphicsPresenter(
GraphicsDevice, presentationParameters);
187 isBackBufferToResize =
false;
195 savedPresenter = GraphicsDevice.Presenter;
196 savedViewport = GraphicsDevice.Viewport;
198 CreateOrUpdatePresenter();
200 if (isBackBufferToResize || windowUserResized)
203 var
size = GetRequestedSize(out resizeFormat);
204 Presenter.Resize((int)size.X, (
int)size.Y, resizeFormat);
206 isBackBufferToResize =
false;
207 windowUserResized =
false;
210 GraphicsDevice.Presenter = Presenter;
236 if (savedPresenter != null)
238 GraphicsDevice.Presenter = savedPresenter;
243 private void WindowOnClientSizeChanged(
object sender,
EventArgs eventArgs)
245 windowUserResized =
true;
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
Represents a two dimensional mathematical vector.
GraphicsDeviceStatus
Describes the current status of a GraphicsDevice.
A service registry is a IServiceProvider that provides methods to register and unregister services...
GraphicsDeviceStatus Status
A GameSystem that allows to draw to another window or control. Currently only valid on desktop with W...
override void Initialize()
This method is called when the component is added to the game.
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
Base class for a GameSystemBase component.
This class is a frontend to SwapChain and SwapChain1.
Defines the window dimensions of a render-target surface onto which a 3D volume projects.
GameWindowRenderer(IServiceRegistry registry, GameContext gameContext=null)
Initializes a new instance of the GameWindowRenderer class.
override bool BeginDraw()
Starts the drawing of a frame. This method is followed by calls to Draw and EndDraw.
Contains context used to render the game (Control for WinForm, a DrawingSurface for WP8...
virtual void CreateOrUpdatePresenter()
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
override void EndDraw()
Ends the drawing of a frame. This method is preceeded by calls to Draw and BeginDraw.
_In_ size_t _In_ size_t size
PixelFormat
Defines various types of pixel formats.
Describess how data will be displayed to the screen.