Skip to content

Commit

Permalink
simplify CreateDevice()
Browse files Browse the repository at this point in the history
IsRenderTargetBound is never true on a new Device
  • Loading branch information
nkast committed Feb 22, 2025
1 parent d644c6b commit 2120ded
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
18 changes: 6 additions & 12 deletions Platforms/Game/.Android/ConcreteGraphicsDeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,9 @@ public override void CreateDevice()
base.GraphicsDevice.PresentationParameters.BackBufferWidth = surfaceView.Width;
base.GraphicsDevice.PresentationParameters.BackBufferHeight = surfaceView.Height;

if (!((IPlatformGraphicsContext)((IPlatformGraphicsDevice)base.GraphicsDevice).Strategy.MainContext).Strategy.IsRenderTargetBound)
{
PresentationParameters pp2 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
}
PresentationParameters pp2 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);

TouchPanel.DisplayWidth = base.GraphicsDevice.PresentationParameters.BackBufferWidth;
TouchPanel.DisplayHeight = base.GraphicsDevice.PresentationParameters.BackBufferHeight;
Expand All @@ -145,12 +142,9 @@ public override void CreateDevice()
base.GraphicsDevice.PresentationParameters.BackBufferWidth = surfaceView.Width;
base.GraphicsDevice.PresentationParameters.BackBufferHeight = surfaceView.Height;

if (!((IPlatformGraphicsContext)((IPlatformGraphicsDevice)base.GraphicsDevice).Strategy.MainContext).Strategy.IsRenderTargetBound)
{
PresentationParameters pp3 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
}
PresentationParameters pp3 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);

TouchPanel.DisplayWidth = base.GraphicsDevice.PresentationParameters.BackBufferWidth;
TouchPanel.DisplayHeight = base.GraphicsDevice.PresentationParameters.BackBufferHeight;
Expand Down
18 changes: 6 additions & 12 deletions Platforms/Game/.CardboardLegacy/ConcreteGraphicsDeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,9 @@ public override void CreateDevice()
base.GraphicsDevice.PresentationParameters.BackBufferWidth = surfaceView.Width;
base.GraphicsDevice.PresentationParameters.BackBufferHeight = surfaceView.Height;

if (!((IPlatformGraphicsContext)((IPlatformGraphicsDevice)base.GraphicsDevice).Strategy.MainContext).Strategy.IsRenderTargetBound)
{
PresentationParameters pp2 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
}
PresentationParameters pp2 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp2.BackBufferWidth, pp2.BackBufferHeight);

TouchPanel.DisplayWidth = base.GraphicsDevice.PresentationParameters.BackBufferWidth;
TouchPanel.DisplayHeight = base.GraphicsDevice.PresentationParameters.BackBufferHeight;
Expand All @@ -145,12 +142,9 @@ public override void CreateDevice()
base.GraphicsDevice.PresentationParameters.BackBufferWidth = surfaceView.Width;
base.GraphicsDevice.PresentationParameters.BackBufferHeight = surfaceView.Height;

if (!((IPlatformGraphicsContext)((IPlatformGraphicsDevice)base.GraphicsDevice).Strategy.MainContext).Strategy.IsRenderTargetBound)
{
PresentationParameters pp3 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
}
PresentationParameters pp3 = this.GraphicsDevice.PresentationParameters;
base.GraphicsDevice.Viewport = new Viewport(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);
base.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, pp3.BackBufferWidth, pp3.BackBufferHeight);

TouchPanel.DisplayWidth = base.GraphicsDevice.PresentationParameters.BackBufferWidth;
TouchPanel.DisplayHeight = base.GraphicsDevice.PresentationParameters.BackBufferHeight;
Expand Down

0 comments on commit 2120ded

Please sign in to comment.