From 214f024d86591987b874b86d53ac42b3faeb8523 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 8 Apr 2021 14:16:35 +1000 Subject: [PATCH] Replace void* param in IGL.BindArrayData w/ IntPtr --- src/BizHawk.Bizware.BizwareGL/IGL.cs | 2 +- src/BizHawk.Bizware.BizwareGL/RetroShader.cs | 2 +- src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs | 5 +---- src/BizHawk.Bizware.OpenTK3/GuiRenderer.cs | 4 ++-- src/BizHawk.Bizware.OpenTK3/IGL_TK.cs | 15 ++++++--------- .../GraphicsImplementations/IGL_GdiPlus.cs | 4 +--- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/BizHawk.Bizware.BizwareGL/IGL.cs b/src/BizHawk.Bizware.BizwareGL/IGL.cs index 611d7a80a3..996464c4de 100644 --- a/src/BizHawk.Bizware.BizwareGL/IGL.cs +++ b/src/BizHawk.Bizware.BizwareGL/IGL.cs @@ -87,7 +87,7 @@ namespace BizHawk.Bizware.BizwareGL /// /// Binds array data for use with the currently-bound pipeline's VertexLayout /// - unsafe void BindArrayData(void* pData); + void BindArrayData(IntPtr pData); /// /// Begins a rendering scene; use before doing any draw calls, as per normal diff --git a/src/BizHawk.Bizware.BizwareGL/RetroShader.cs b/src/BizHawk.Bizware.BizwareGL/RetroShader.cs index 5659fc5138..109fd16260 100644 --- a/src/BizHawk.Bizware.BizwareGL/RetroShader.cs +++ b/src/BizHawk.Bizware.BizwareGL/RetroShader.cs @@ -122,7 +122,7 @@ namespace BizHawk.Bizware.BizwareGL pData[i++] = 1; pData[i++] = v1; Owner.SetBlendState(Owner.BlendNoneCopy); - Owner.BindArrayData(pData); + Owner.BindArrayData(new(pData)); Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); } diff --git a/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs b/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs index 317c9ffb41..6744f8ec37 100644 --- a/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs +++ b/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs @@ -951,10 +951,7 @@ namespace BizHawk.Bizware.DirectX Dev.DrawUserPrimitives(pt, primCount, (void*)ptr, (uint)stride); } - public unsafe void BindArrayData(void* pData) - { - _pVertexData = new IntPtr(pData); - } + public void BindArrayData(IntPtr pData) => _pVertexData = pData; public void BeginScene() { diff --git a/src/BizHawk.Bizware.OpenTK3/GuiRenderer.cs b/src/BizHawk.Bizware.OpenTK3/GuiRenderer.cs index eee78c579c..034970cd8b 100644 --- a/src/BizHawk.Bizware.OpenTK3/GuiRenderer.cs +++ b/src/BizHawk.Bizware.OpenTK3/GuiRenderer.cs @@ -253,7 +253,7 @@ namespace BizHawk.Bizware.OpenTK3 fixed (float* pData = &data[0]) { - Owner.BindArrayData(pData); + Owner.BindArrayData(new(pData)); Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); } } @@ -322,7 +322,7 @@ namespace BizHawk.Bizware.OpenTK3 pData[30] = CornerColors[3].Z; pData[31] = CornerColors[3].W; - Owner.BindArrayData(pData); + Owner.BindArrayData(new(pData)); Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); #if DEBUG diff --git a/src/BizHawk.Bizware.OpenTK3/IGL_TK.cs b/src/BizHawk.Bizware.OpenTK3/IGL_TK.cs index 6efc2d9543..cc553d87c3 100644 --- a/src/BizHawk.Bizware.OpenTK3/IGL_TK.cs +++ b/src/BizHawk.Bizware.OpenTK3/IGL_TK.cs @@ -386,10 +386,7 @@ namespace BizHawk.Bizware.OpenTK3 GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, mode); } - public unsafe void BindArrayData(void* pData) - { - MyBindArrayData(sStatePendingVertexLayout, pData); - } + public void BindArrayData(IntPtr pData) => MyBindArrayData(sStatePendingVertexLayout, pData); public void DrawArrays(BizGL.PrimitiveType mode, int first, int count) { @@ -749,7 +746,7 @@ namespace BizHawk.Bizware.OpenTK3 currBindings.Clear(); } - private unsafe void MyBindArrayData(VertexLayout layout, void* pData) + private void MyBindArrayData(VertexLayout layout, IntPtr pData) { UnbindVertexAttributes(); @@ -781,7 +778,7 @@ namespace BizHawk.Bizware.OpenTK3 (VertexAttribPointerType) (int) kvp.Value.AttribType, // these are the same enum kvp.Value.Normalized, kvp.Value.Stride, - new IntPtr(pData) + kvp.Value.Offset); + pData + kvp.Value.Offset); GL.EnableVertexAttribArray(kvp.Key); currBindings.Add(kvp.Key); } @@ -795,17 +792,17 @@ namespace BizHawk.Bizware.OpenTK3 { case AttribUsage.Position: GL.EnableClientState(ArrayCap.VertexArray); - GL.VertexPointer(kvp.Value.Components,VertexPointerType.Float,kvp.Value.Stride,new IntPtr(pData) + kvp.Value.Offset); + GL.VertexPointer(kvp.Value.Components,VertexPointerType.Float,kvp.Value.Stride,pData + kvp.Value.Offset); break; case AttribUsage.Texcoord0: GL.ClientActiveTexture(TextureUnit.Texture0); GL.EnableClientState(ArrayCap.TextureCoordArray); - GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset); + GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, pData + kvp.Value.Offset); break; case AttribUsage.Texcoord1: GL.ClientActiveTexture(TextureUnit.Texture1); GL.EnableClientState(ArrayCap.TextureCoordArray); - GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset); + GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, pData + kvp.Value.Offset); GL.ClientActiveTexture(TextureUnit.Texture0); break; case AttribUsage.Color0: diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs index cd4b536b52..06461b972e 100644 --- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs +++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs @@ -47,9 +47,7 @@ namespace BizHawk.Client.EmuHawk _currentClearColor = color; } - public unsafe void BindArrayData(void* pData) - { - } + public void BindArrayData(IntPtr pData) {} public void FreeTexture(Texture2d tex) {