From 9c6e11a1face000638642b46a224d169c00eda02 Mon Sep 17 00:00:00 2001 From: CaptainSegis Date: Thu, 16 Feb 2017 14:25:45 -0500 Subject: [PATCH] Fixed OpenTK issues in NewInventoryScreen. --- .../Screens/Inventory/NewInventoryScreen.vb | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/2.5DHero/2.5DHero/Screens/Inventory/NewInventoryScreen.vb b/2.5DHero/2.5DHero/Screens/Inventory/NewInventoryScreen.vb index a5eb6bcb3..885616650 100644 --- a/2.5DHero/2.5DHero/Screens/Inventory/NewInventoryScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Inventory/NewInventoryScreen.vb @@ -10,6 +10,11 @@ Public Class NewInventoryScreen Private _translation As Globalization.Classes.LOCAL_InventoryScreen + Private target_1 As RenderTarget2D + Private target_2 As RenderTarget2D + Private itemBatch As CoreSpriteBatch + Private infoBatch As CoreSpriteBatch + ''' ''' Texture from file: GUI\Menus\General ''' @@ -112,6 +117,10 @@ Public Class NewInventoryScreen Public Sub New(ByVal currentScreen As Screen) _translation = New Globalization.Classes.LOCAL_InventoryScreen() + target_1 = New RenderTarget2D(GraphicsDevice, 816, 400 - 32, False, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents) + target_2 = New RenderTarget2D(GraphicsDevice, 500, 368) + itemBatch = New CoreSpriteBatch(GraphicsDevice) + infoBatch = New CoreSpriteBatch(GraphicsDevice) Identification = Identifications.InventoryScreen PreScreen = currentScreen @@ -248,12 +257,11 @@ Public Class NewInventoryScreen 'Bring back when Monogame begins supporting this stuff ' Dim target As New RenderTarget2D(GraphicsDevice, 816, CInt(_enrollY) - 32, False, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents) - Dim target As New RenderTarget2D(GraphicsDevice, 816, CInt(_enrollY) - 32, False, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents) - GraphicsDevice.SetRenderTarget(target) + GraphicsDevice.SetRenderTarget(target_1) GraphicsDevice.Clear(Color.Transparent) 'Create a designated sprite batch: - Dim itemBatch As New CoreSpriteBatch(GraphicsDevice) + itemBatch.BeginBatch() Dim itemPanelAlpha As Integer = CInt(If(_tabInControl, 180, 255) * _interfaceFade) @@ -294,7 +302,7 @@ Public Class NewInventoryScreen 'When the info is visible, draw it: If _infoSize > 0 Then - DrawInfo(itemBatch, target) + DrawInfo(itemBatch, target_1) End If itemBatch.EndBatch() @@ -307,7 +315,7 @@ Public Class NewInventoryScreen drawheight = CInt(_enrollY) - 32 End If - SpriteBatch.Draw(target, New Rectangle(halfWidth - 400, halfHeight - 200 + 48, 816, drawheight), mainBackgroundColor) + SpriteBatch.Draw(target_1, New Rectangle(halfWidth - 400, halfHeight - 200 + 48, 816, drawheight), mainBackgroundColor) End If End Sub @@ -320,11 +328,9 @@ Public Class NewInventoryScreen 'Bring back when Monogame begins supporting this stuff ' Dim target As New RenderTarget2D(GraphicsDevice, _infoSize, 368, False, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents) - Dim target As New RenderTarget2D(GraphicsDevice, _infoSize, 368, False, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents) - GraphicsDevice.SetRenderTarget(target) + GraphicsDevice.SetRenderTarget(target_2) 'Render background: - Dim infoBatch As New CoreSpriteBatch(GraphicsDevice) infoBatch.BeginBatch() For y = 0 To 368 Step 16 For x = 0 To _infoSize + 16 Step 16 @@ -383,7 +389,7 @@ Public Class NewInventoryScreen 'Set the target that was previously active and render the new target on top of that: GraphicsDevice.SetRenderTarget(preTarget) - preBatch.Draw(target, New Rectangle(_infoPosition + 80, 0, target.Width, target.Height), Color.White) + preBatch.Draw(target_2, New Rectangle(_infoPosition + 80, 0, target_2.Width, target_2.Height), Color.White) End Sub '''