Skip to content

Instantly share code, notes, and snippets.

@thatcosmonaut
Last active February 28, 2020 02:34
Show Gist options
  • Save thatcosmonaut/11154d56e2400c30066b4fdbb5762983 to your computer and use it in GitHub Desktop.
Save thatcosmonaut/11154d56e2400c30066b4fdbb5762983 to your computer and use it in GitHub Desktop.
public SamuraiGunnGame()
{
_graphicsDeviceManager = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsFixedTimeStep = Config.FORCE_FIXED_TIMESTEP;
_virtualDimensions = new Microsoft.Xna.Framework.Rectangle(0, 0, s_virtual_width, s_virtual_height);
_graphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.FORCE_VSYNC;
_graphicsDeviceManager.IsFullScreen = Config.FORCE_FULLSCREEN;
int backBufferWidth = 0;
int backBufferHeight = 0;
if (Config.FORCE_FULLSCREEN)
{
foreach (var dm in GraphicsDevice.Adapter.SupportedDisplayModes)
{
if (dm.Width > backBufferWidth || dm.Height > backBufferHeight)
{
backBufferWidth = dm.Width;
backBufferHeight = dm.Height;
}
}
}
else
{
backBufferWidth = s_virtual_width;
backBufferHeight = s_virtual_height;
}
_graphicsDeviceManager.PreferredBackBufferWidth = backBufferWidth;
_graphicsDeviceManager.PreferredBackBufferHeight = backBufferHeight;
#if DEBUG
IsMouseVisible = true;
#endif
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
base.Initialize();
_gameRenderTarget = new RenderTarget2D(GraphicsDevice, s_render_width, s_render_height);
_levelBrowserRenderTarget = new RenderTarget2D(GraphicsDevice, s_virtual_width, s_virtual_height);
_uiRenderTarget = new RenderTarget2D(GraphicsDevice, 1920, 1080);
_postProcessRenderTarget = new RenderTarget2D(GraphicsDevice, s_virtual_width, s_virtual_height);
_debugUIRenderTarget = new RenderTarget2D(GraphicsDevice, s_virtual_width, s_virtual_height);
_finalRenderTarget = new RenderTarget2D(GraphicsDevice, s_virtual_width, s_virtual_height);
Resolution.Init(
GraphicsDevice,
GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight,
s_virtual_width,
s_virtual_height
);
Window.ClientSizeChanged += OnClientSizeChanged;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment