Fix and optimize target sets/clears
This commit is contained in:
parent
8e71649774
commit
0e66c1421c
@ -81,6 +81,7 @@ namespace TrueCraft.Client
|
|||||||
Graphics.PreferredBackBufferWidth = UserSettings.Local.WindowResolution.Width;
|
Graphics.PreferredBackBufferWidth = UserSettings.Local.WindowResolution.Width;
|
||||||
Graphics.PreferredBackBufferHeight = UserSettings.Local.WindowResolution.Height;
|
Graphics.PreferredBackBufferHeight = UserSettings.Local.WindowResolution.Height;
|
||||||
Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
||||||
|
Graphics.PreparingDeviceSettings += PrepareDeviceSettings;
|
||||||
Graphics.ApplyChanges();
|
Graphics.ApplyChanges();
|
||||||
Window.ClientSizeChanged += Window_ClientSizeChanged;
|
Window.ClientSizeChanged += Window_ClientSizeChanged;
|
||||||
Client = client;
|
Client = client;
|
||||||
@ -101,6 +102,11 @@ namespace TrueCraft.Client
|
|||||||
Components.Add(GamePadComponent);
|
Components.Add(GamePadComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrepareDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
|
||||||
|
{
|
||||||
|
e.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
|
||||||
|
}
|
||||||
|
|
||||||
void Window_ClientSizeChanged(object sender, EventArgs e)
|
void Window_ClientSizeChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (GraphicsDevice.Viewport.Width < 640 || GraphicsDevice.Viewport.Height < 480)
|
if (GraphicsDevice.Viewport.Width < 640 || GraphicsDevice.Viewport.Height < 480)
|
||||||
@ -418,7 +424,7 @@ namespace TrueCraft.Client
|
|||||||
|
|
||||||
GraphicsDevice.SetRenderTarget(null);
|
GraphicsDevice.SetRenderTarget(null);
|
||||||
|
|
||||||
SpriteBatch.Begin();
|
SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
|
||||||
SpriteBatch.Draw(RenderTarget, Vector2.Zero, Color.White);
|
SpriteBatch.Draw(RenderTarget, Vector2.Zero, Color.White);
|
||||||
SpriteBatch.End();
|
SpriteBatch.End();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user