Retargetting non-executable projects to .NET Standard (#1801)

* Retarget BizHawk.Emulation.* to .NET Standard 2.0

* Retarget BizHawk.Bizware.BizwareGL to .NET Standard 2.0

In practice this mostly involves moving classes to BizHawk.Client.EmuHawk.
This commit is contained in:
James Groom 2020-02-18 16:31:49 +00:00 committed by GitHub
parent fcc3ac88c0
commit 46a4d8ffa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 120 additions and 168 deletions

View File

@ -1,28 +0,0 @@
using System;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.Common
{
public static class Extensions
{
public static IGuiRenderer CreateRenderer(this IGL gl)
{
if (gl is IGL_TK)
{
return new GuiRenderer(gl);
}
if (gl is IGL_SlimDX9)
{
return new GuiRenderer(gl);
}
if (gl is IGL_GdiPlus)
{
return new GDIPlusGuiRenderer((IGL_GdiPlus)gl);
}
throw new NotSupportedException();
}
}
}

View File

@ -96,9 +96,18 @@
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
HintPath="$(SolutionDir)packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll" HintPath="$(SolutionDir)packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll"
Private="true" /> Private="true" />
<!--<Reference Include="OpenTK, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
HintPath="../packages/OpenTK.3.0.1/lib/net20/OpenTK.dll"
Private="true" />-->
<Reference Include="OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
HintPath="../packages/OpenTK.GLControl.3.0.1/lib/net20/OpenTK.GLControl.dll"
Private="true" />
<Reference Include="ICSharpCode.SharpZipLib, Version=1.1.0.145, Culture=neutral, PublicKeyToken=1b03e6acf1164f73" <Reference Include="ICSharpCode.SharpZipLib, Version=1.1.0.145, Culture=neutral, PublicKeyToken=1b03e6acf1164f73"
HintPath="$(SolutionDir)packages/SharpZipLib.1.1.0/lib/net45/ICSharpCode.SharpZipLib.dll" HintPath="$(SolutionDir)packages/SharpZipLib.1.1.0/lib/net45/ICSharpCode.SharpZipLib.dll"
Private="true" /> Private="true" />
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"
HintPath="../packages/System.Drawing.Common.4.7.0/lib/net461/System.Drawing.Common.dll"
Private="true" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="GongShell" <Reference Include="GongShell"
@ -426,6 +435,11 @@
<Compile Update="CustomControls/ToolStripEx.cs" SubType="Component" /> <Compile Update="CustomControls/ToolStripEx.cs" SubType="Component" />
<Compile Update="CustomControls/TransparentTrackbar.cs" SubType="Component" /> <Compile Update="CustomControls/TransparentTrackbar.cs" SubType="Component" />
<Compile Update="CustomControls/ViewportPanel.cs" SubType="Component" /> <Compile Update="CustomControls/ViewportPanel.cs" SubType="Component" />
<Compile Update="GraphicsImplementations/GLControlWrapper_GdiPlus.cs" SubType="Component" />
<Compile Update="GraphicsImplementations/GLControlWrapper_SlimDX9.cs" SubType="Component" />
<Compile Update="GraphicsImplementations/GraphicsControl.cs" SubType="UserControl" />
<Compile Update="GraphicsImplementations/GraphicsControl_TK.cs" SubType="UserControl" />
<Compile Update="GraphicsImplementations/RetainedGraphicsControl.cs" SubType="UserControl" />
<Compile Update="LogWindow.cs" SubType="Form" /> <Compile Update="LogWindow.cs" SubType="Form" />
<Compile Update="LogWindow.Designer.cs" DependentUpon="LogWindow.cs" /> <Compile Update="LogWindow.Designer.cs" DependentUpon="LogWindow.cs" />
<EmbeddedResource Update="LogWindow.resx" DependentUpon="LogWindow.cs" /> <EmbeddedResource Update="LogWindow.resx" DependentUpon="LogWindow.cs" />

View File

@ -9,7 +9,7 @@ using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
public class GLControlWrapper_GdiPlus : Control, IGraphicsControl public class GLControlWrapper_GdiPlus : Control, IGraphicsControl
{ {

View File

@ -9,7 +9,7 @@ using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
using SlimDX.Direct3D9; using SlimDX.Direct3D9;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
public class GLControlWrapper_SlimDX9 : Control, IGraphicsControl public class GLControlWrapper_SlimDX9 : Control, IGraphicsControl
{ {

View File

@ -1,7 +1,9 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Bizware.BizwareGL using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.EmuHawk
{ {
/// <summary> /// <summary>
/// a base class for deriving/wrapping from a IGraphicsControl. /// a base class for deriving/wrapping from a IGraphicsControl.

View File

@ -11,7 +11,7 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
class GLControlWrapper : GLControl, IGraphicsControl class GLControlWrapper : GLControl, IGraphicsControl
{ {

View File

@ -0,0 +1,17 @@
using System;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.EmuHawk
{
public static class IGLExtensions
{
public static IGuiRenderer CreateRenderer(this IGL gl) => gl switch
{
IGL_GdiPlus _ => (IGuiRenderer) new GDIPlusGuiRenderer(gl),
IGL_SlimDX9 _ => new GuiRenderer(gl),
IGL_TK _ => new GuiRenderer(gl),
_ => throw new NotSupportedException()
};
}
}

View File

@ -16,7 +16,7 @@ using swf = System.Windows.Forms;
//TODO - maybe a layer to cache Graphics parameters (notably, filtering) ? //TODO - maybe a layer to cache Graphics parameters (notably, filtering) ?
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
public class IGL_GdiPlus : IGL public class IGL_GdiPlus : IGL
{ {
@ -62,7 +62,7 @@ namespace BizHawk.Bizware.BizwareGL
public void FreeTexture(Texture2d tex) public void FreeTexture(Texture2d tex)
{ {
var tw = tex.Opaque as TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
tw.Dispose(); tw.Dispose();
} }
@ -151,7 +151,7 @@ namespace BizHawk.Bizware.BizwareGL
public void TexParameter2d(Texture2d tex, TextureParameterName pname, int param) public void TexParameter2d(Texture2d tex, TextureParameterName pname, int param)
{ {
var tw = tex.Opaque as TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
if (pname == TextureParameterName.TextureMinFilter) if (pname == TextureParameterName.TextureMinFilter)
tw.MinFilter = (TextureMinFilter)param; tw.MinFilter = (TextureMinFilter)param;
if (pname == TextureParameterName.TextureMagFilter) if (pname == TextureParameterName.TextureMagFilter)
@ -161,7 +161,7 @@ namespace BizHawk.Bizware.BizwareGL
public Texture2d LoadTexture(sd.Bitmap bitmap) public Texture2d LoadTexture(sd.Bitmap bitmap)
{ {
var sdbmp = (sd.Bitmap)bitmap.Clone(); var sdbmp = (sd.Bitmap)bitmap.Clone();
TextureWrapper tw = new TextureWrapper(); GDIPTextureWrapper tw = new GDIPTextureWrapper();
tw.SDBitmap = sdbmp; tw.SDBitmap = sdbmp;
return new Texture2d(this, tw, bitmap.Width, bitmap.Height); return new Texture2d(this, tw, bitmap.Width, bitmap.Height);
} }
@ -185,7 +185,7 @@ namespace BizHawk.Bizware.BizwareGL
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp) public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
{ {
var tw = tex.Opaque as TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
bmp.ToSysdrawingBitmap(tw.SDBitmap); bmp.ToSysdrawingBitmap(tw.SDBitmap);
} }
@ -194,14 +194,14 @@ namespace BizHawk.Bizware.BizwareGL
{ {
//definitely needed (by TextureFrugalizer at least) //definitely needed (by TextureFrugalizer at least)
var sdbmp = bmp.ToSysdrawingBitmap(); var sdbmp = bmp.ToSysdrawingBitmap();
var tw = new TextureWrapper(); var tw = new GDIPTextureWrapper();
tw.SDBitmap = sdbmp; tw.SDBitmap = sdbmp;
return new Texture2d(this, tw, bmp.Width, bmp.Height); return new Texture2d(this, tw, bmp.Width, bmp.Height);
} }
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex) public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
{ {
var tw = tex.Opaque as TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
var blow = new BitmapLoadOptions() var blow = new BitmapLoadOptions()
{ {
AllowWrap = false //must be an independent resource AllowWrap = false //must be an independent resource
@ -320,7 +320,7 @@ namespace BizHawk.Bizware.BizwareGL
} }
else else
{ {
var tw = Target.Texture2d.Opaque as TextureWrapper; var tw = Target.Texture2d.Opaque as GDIPTextureWrapper;
r = Target.Texture2d.Rectangle; r = Target.Texture2d.Rectangle;
refGraphics = Graphics.FromImage(tw.SDBitmap); refGraphics = Graphics.FromImage(tw.SDBitmap);
} }
@ -368,7 +368,7 @@ namespace BizHawk.Bizware.BizwareGL
public unsafe RenderTarget CreateRenderTarget(int w, int h) public unsafe RenderTarget CreateRenderTarget(int w, int h)
{ {
TextureWrapper tw = new TextureWrapper(); GDIPTextureWrapper tw = new GDIPTextureWrapper();
tw.SDBitmap = new Bitmap(w,h, sdi.PixelFormat.Format32bppArgb); tw.SDBitmap = new Bitmap(w,h, sdi.PixelFormat.Format32bppArgb);
var tex = new Texture2d(this, tw, w, h); var tex = new Texture2d(this, tw, w, h);
@ -406,7 +406,7 @@ namespace BizHawk.Bizware.BizwareGL
} }
else else
{ {
var tw = rt.Texture2d.Opaque as TextureWrapper; var tw = rt.Texture2d.Opaque as GDIPTextureWrapper;
CurrentRenderTargetWrapper = rt.Opaque as RenderTargetWrapper; CurrentRenderTargetWrapper = rt.Opaque as RenderTargetWrapper;
_CurrentOffscreenGraphics = Graphics.FromImage(tw.SDBitmap); _CurrentOffscreenGraphics = Graphics.FromImage(tw.SDBitmap);
//if (CurrentRenderTargetWrapper.MyBufferedGraphics == null) //if (CurrentRenderTargetWrapper.MyBufferedGraphics == null)
@ -429,21 +429,6 @@ namespace BizHawk.Bizware.BizwareGL
public BufferedGraphicsContext MyBufferedGraphicsContext; public BufferedGraphicsContext MyBufferedGraphicsContext;
public class TextureWrapper : IDisposable
{
public sd.Bitmap SDBitmap;
public TextureMinFilter MinFilter = TextureMinFilter.Nearest;
public TextureMagFilter MagFilter = TextureMagFilter.Nearest;
public void Dispose()
{
if (SDBitmap != null)
{
SDBitmap.Dispose();
SDBitmap = null;
}
}
}
} //class IGL_GdiPlus } //class IGL_GdiPlus

View File

@ -21,7 +21,7 @@ using swf = System.Windows.Forms;
//todo - do a better job selecting shader model? base on caps somehow? try several and catch compilation exceptions (yuck, exceptions) //todo - do a better job selecting shader model? base on caps somehow? try several and catch compilation exceptions (yuck, exceptions)
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
public class IGL_SlimDX9 : IGL public class IGL_SlimDX9 : IGL

View File

@ -25,7 +25,7 @@ using sd = System.Drawing;
using sdi = System.Drawing.Imaging; using sdi = System.Drawing.Imaging;
using swf = System.Windows.Forms; using swf = System.Windows.Forms;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
/// <summary> /// <summary>
/// OpenTK implementation of the BizwareGL.IGL interface. /// OpenTK implementation of the BizwareGL.IGL interface.

View File

@ -8,7 +8,7 @@ using System.Text;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Client.EmuHawk
{ {
/// <summary> /// <summary>
/// Adapts a GraphicsControl to gain the power of remembering what was drawn to it, and keeping it presented in response to Paint events /// Adapts a GraphicsControl to gain the power of remembering what was drawn to it, and keeping it presented in response to Paint events

View File

@ -130,7 +130,7 @@ namespace BizHawk.Client.EmuHawk
} }
// create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores // create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores
GlobalWin.IGL_GL = new Bizware.BizwareGL.IGL_TK(2, 0, false); GlobalWin.IGL_GL = new IGL_TK(2, 0, false);
// setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method // setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
GLManager.CreateInstance(); GLManager.CreateInstance();
@ -140,13 +140,13 @@ namespace BizHawk.Client.EmuHawk
REDO_DISPMETHOD: REDO_DISPMETHOD:
if (Global.Config.DispMethod == EDispMethod.GdiPlus) if (Global.Config.DispMethod == EDispMethod.GdiPlus)
{ {
GlobalWin.GL = new Bizware.BizwareGL.IGL_GdiPlus(); GlobalWin.GL = new IGL_GdiPlus();
} }
else if (Global.Config.DispMethod == EDispMethod.SlimDX9) else if (Global.Config.DispMethod == EDispMethod.SlimDX9)
{ {
try try
{ {
GlobalWin.GL = new Bizware.BizwareGL.IGL_SlimDX9(); GlobalWin.GL = new IGL_SlimDX9();
} }
catch(Exception ex) catch(Exception ex)
{ {
@ -248,7 +248,7 @@ namespace BizHawk.Client.EmuHawk
//cleanup: //cleanup:
//cleanup IGL stuff so we can get better refcounts when exiting process, for debugging //cleanup IGL stuff so we can get better refcounts when exiting process, for debugging
//DOESNT WORK FOR SOME REASON //DOESNT WORK FOR SOME REASON
//GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(); //GlobalWin.IGL_GL = new IGL_TK();
//GLManager.Instance.Dispose(); //GLManager.Instance.Dispose();
//if (GlobalWin.IGL_GL != GlobalWin.GL) //if (GlobalWin.IGL_GL != GlobalWin.GL)
// GlobalWin.GL.Dispose(); // GlobalWin.GL.Dispose();

View File

@ -6,11 +6,29 @@
Name="Newtonsoft.Json" Name="Newtonsoft.Json"
Private="true" Private="true"
SpecificVersion="true" /> SpecificVersion="true" />
<!--<PackageReference Include="OpenTK" Version="3.0.1" PrivateAssets="All" />
<Reference Include="$(MachineNuGetPackageDir)/opentk/3.0.1/lib/net20/OpenTK.dll"
FusionName="OpenTK, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
Name="OpenTK"
Private="true"
SpecificVersion="true" />-->
<PackageReference Include="OpenTK.GLControl" Version="3.0.1" PrivateAssets="All" />
<Reference Include="$(MachineNuGetPackageDir)/opentk.glcontrol/3.0.1/lib/net20/OpenTK.GLControl.dll"
FusionName="OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
Name="OpenTK.GLControl"
Private="true"
SpecificVersion="true" />
<PackageReference Include="SharpZipLib" Version="1.1.0" PrivateAssets="All" /> <PackageReference Include="SharpZipLib" Version="1.1.0" PrivateAssets="All" />
<Reference Include="$(MachineNuGetPackageDir)/sharpziplib/1.1.0/lib/net45/ICSharpCode.SharpZipLib.dll" <Reference Include="$(MachineNuGetPackageDir)/sharpziplib/1.1.0/lib/net45/ICSharpCode.SharpZipLib.dll"
FusionName="ICSharpCode.SharpZipLib, Version=1.1.0.145, Culture=neutral, PublicKeyToken=1b03e6acf1164f73" FusionName="ICSharpCode.SharpZipLib, Version=1.1.0.145, Culture=neutral, PublicKeyToken=1b03e6acf1164f73"
Name="ICSharpCode.SharpZipLib" Name="ICSharpCode.SharpZipLib"
Private="true" Private="true"
SpecificVersion="true" /> SpecificVersion="true" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" PrivateAssets="All" />
<Reference Include="$(MachineNuGetPackageDir)/system.drawing.common/4.7.0/lib/net461/System.Drawing.Common.dll"
FusionName="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"
Name="System.Drawing.Common"
Private="true"
SpecificVersion="true" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" /> <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
<!--<package id="OpenTK" version="3.0.1" targetFramework="net20" />-->
<package id="OpenTK.GLControl" version="3.0.1" targetFramework="net20" />
<package id="SharpZipLib" version="1.1.0" targetFramework="net45" /> <package id="SharpZipLib" version="1.1.0" targetFramework="net45" />
<package id="System.Drawing.Common" version="4.7.0" targetFramework="net461" />
</packages> </packages>

View File

@ -2,25 +2,11 @@
<Import Project="$(SolutionDir)Common.props" /> <Import Project="$(SolutionDir)Common.props" />
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net48</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<!--<Reference Include="Microsoft.CSharp" />-->
<!--<Reference Include="System" />-->
<!--<Reference Include="System.Core" />-->
<!--<Reference Include="System.Data" />-->
<!--<Reference Include="System.Data.DataSetExtensions" />-->
<!--<Reference Include="System.Xml" />-->
<!--<Reference Include="System.Xml.Linq" />-->
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" PrivateAssets="All" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj" /> <ProjectReference Include="$(SolutionDir)BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(SolutionDir)Version/svnrev.cs" /> <Compile Include="$(SolutionDir)Version/svnrev.cs" />
<Compile Include="$(SolutionDir)Version/VersionInfo.cs" /> <Compile Include="$(SolutionDir)Version/VersionInfo.cs" />
</ItemGroup> </ItemGroup>

View File

@ -2,66 +2,23 @@
<Import Project="$(SolutionDir)Common.props" /> <Import Project="$(SolutionDir)Common.props" />
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net48</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<!-- This stuff was unique to this project and also not mentioned in the tutorial, so I've left them commented here. -->
<!--
<PropertyGroup>
<FileUpgradeFlags />
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish/</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5" Install="false" ProductName=".NET Framework 3.5 SP1 Client Profile" Visible="False" /> <PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" PrivateAssets="All" />
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1" Install="true" ProductName=".NET Framework 3.5 SP1" Visible="False" />
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1" Install="true" ProductName="Windows Installer 3.1" Visible="False" />
</ItemGroup>
-->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<!--<Reference Include="System" />-->
<!--<Reference Include="System.ComponentModel.DataAnnotations" />-->
<!--<Reference Include="System.Core" RequiredTargetFramework="3.5" />-->
<!--<Reference Include="System.Data" />-->
<!--<Reference Include="System.Data.DataSetExtensions" RequiredTargetFramework="3.5" />-->
<!--<Reference Include="System.Drawing" />-->
<!--<Reference Include="System.Numerics" />-->
<Reference Include="System.Windows.Forms" />
<!--<Reference Include="System.Xml" />-->
<!--<Reference Include="System.Xml.Linq" RequiredTargetFramework="3.5" />-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="ELFSharp" Version="0.1.0" PrivateAssets="All" /> <PackageReference Include="ELFSharp" Version="0.1.0" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" PrivateAssets="All" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" PrivateAssets="All" />
<PackageReference Include="OpenTK" Version="3.0.1" PrivateAssets="All" /> <PackageReference Include="OpenTK" Version="3.0.1" PrivateAssets="All" />
<Reference Include="PeNet" HintPath="$(SolutionDir)References/PeNet.dll" Private="true" /> <Reference Include="PeNet"
<Reference Include="Virtu" HintPath="$(SolutionDir)References/Virtu.dll" Private="true" /> HintPath="$(SolutionDir)References/PeNet.dll"
</ItemGroup> Private="true" />
<ItemGroup> <Reference Include="Virtu"
HintPath="$(SolutionDir)References/Virtu.dll"
Private="true" />
<ProjectReference Include="$(SolutionDir)BizHawk.BizInvoke/BizHawk.BizInvoke.csproj" /> <ProjectReference Include="$(SolutionDir)BizHawk.BizInvoke/BizHawk.BizInvoke.csproj" />
<ProjectReference Include="$(SolutionDir)BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj" /> <ProjectReference Include="$(SolutionDir)BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(SolutionDir)Version/svnrev.cs" /> <Compile Include="$(SolutionDir)Version/svnrev.cs" />
<Compile Include="$(SolutionDir)Version/VersionInfo.cs" /> <Compile Include="$(SolutionDir)Version/VersionInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources/*" /> <None Include="Resources/*" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,24 +2,11 @@
<Import Project="$(SolutionDir)Common.props" /> <Import Project="$(SolutionDir)Common.props" />
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net48</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<!--<Reference Include="Microsoft.CSharp" />-->
<!--<Reference Include="System" />-->
<!--<Reference Include="System.Core" />-->
<!--<Reference Include="System.Data" />-->
<!--<Reference Include="System.Data.DataSetExtensions" />-->
<!--<Reference Include="System.Xml" />-->
<!--<Reference Include="System.Xml.Linq" />-->
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(SolutionDir)BizHawk.Common/BizHawk.Common.csproj" /> <ProjectReference Include="$(SolutionDir)BizHawk.Common/BizHawk.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(SolutionDir)Version/svnrev.cs" /> <Compile Include="$(SolutionDir)Version/svnrev.cs" />
<Compile Include="$(SolutionDir)Version/VersionInfo.cs" /> <Compile Include="$(SolutionDir)Version/VersionInfo.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -2,24 +2,15 @@
<Import Project="$(SolutionDir)Common.props" /> <Import Project="$(SolutionDir)Common.props" />
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net48</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" PrivateAssets="All" />
<Reference Include="System.Windows.Forms" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" PrivateAssets="All" />
<PackageReference Include="OpenTK" Version="3.0.1" PrivateAssets="All" /> <PackageReference Include="OpenTK" Version="3.0.1" PrivateAssets="All" />
<PackageReference Include="OpenTK.GLControl" Version="3.0.1" PrivateAssets="All" />
<Reference Include="SlimDX"
HintPath="$(SolutionDir)References/x64/SlimDX.dll"
Private="true" />
<ProjectReference Include="$(SolutionDir)BizHawk.Common/BizHawk.Common.csproj" /> <ProjectReference Include="$(SolutionDir)BizHawk.Common/BizHawk.Common.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="GLControlWrapper_GdiPlus.cs" SubType="Component" />
<Compile Update="GLControlWrapper_SlimDX9.cs" SubType="Component" />
<Compile Update="GraphicsControl.cs" SubType="UserControl" />
<Compile Update="GraphicsControl_TK.cs" SubType="UserControl" />
<Compile Update="IGuiRenderer.cs" SubType="Code" /> <Compile Update="IGuiRenderer.cs" SubType="Code" />
<Compile Update="RetainedGraphicsControl.cs" SubType="UserControl" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,21 @@
using System;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL
{
public class GDIPTextureWrapper : IDisposable
{
public System.Drawing.Bitmap SDBitmap;
public TextureMinFilter MinFilter = TextureMinFilter.Nearest;
public TextureMagFilter MagFilter = TextureMagFilter.Nearest;
public void Dispose()
{
if (SDBitmap != null)
{
SDBitmap.Dispose();
SDBitmap = null;
}
}
}
}

View File

@ -15,10 +15,9 @@ namespace BizHawk.Bizware.BizwareGL
{ {
public class GDIPlusGuiRenderer : IGuiRenderer public class GDIPlusGuiRenderer : IGuiRenderer
{ {
public GDIPlusGuiRenderer(IGL_GdiPlus gl) public GDIPlusGuiRenderer(IGL gl)
{ {
Owner = gl; Owner = gl;
Gdi = gl as IGL_GdiPlus;
} }
OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] {
@ -164,8 +163,8 @@ namespace BizHawk.Bizware.BizwareGL
public void DrawSubrect(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1) public void DrawSubrect(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
{ {
var tw = tex.Opaque as IGL_GdiPlus.TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
var g = Gdi.GetCurrentGraphics(); var g = ((dynamic) Gdi).GetCurrentGraphics() as sd.Graphics;
PrepDraw(g, tex); PrepDraw(g, tex);
SetupMatrix(g); SetupMatrix(g);
@ -200,7 +199,7 @@ namespace BizHawk.Bizware.BizwareGL
void PrepDraw(sd.Graphics g, Texture2d tex) void PrepDraw(sd.Graphics g, Texture2d tex)
{ {
var tw = tex.Opaque as IGL_GdiPlus.TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
//TODO - we can support bicubic for the final presentation.. //TODO - we can support bicubic for the final presentation..
if ((int)tw.MagFilter != (int)tw.MinFilter) if ((int)tw.MagFilter != (int)tw.MinFilter)
throw new InvalidOperationException($"{nameof(tw)}.{nameof(tw.MagFilter)} != {nameof(tw)}.{nameof(tw.MinFilter)}"); throw new InvalidOperationException($"{nameof(tw)}.{nameof(tw.MagFilter)} != {nameof(tw)}.{nameof(tw.MinFilter)}");
@ -253,7 +252,7 @@ namespace BizHawk.Bizware.BizwareGL
unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1) unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
{ {
var g = Gdi.GetCurrentGraphics(); var g = ((dynamic) Gdi).GetCurrentGraphics() as sd.Graphics;
PrepDraw(g, tex); PrepDraw(g, tex);
SetupMatrix(g); SetupMatrix(g);
@ -271,7 +270,7 @@ namespace BizHawk.Bizware.BizwareGL
float sw = sx2 - sx; float sw = sx2 - sx;
float sh = sy2 - sy; float sh = sy2 - sy;
var tw = tex.Opaque as IGL_GdiPlus.TextureWrapper; var tw = tex.Opaque as GDIPTextureWrapper;
g.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half; g.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half;
g.DrawImage(tw.SDBitmap, destPoints, new sd.RectangleF(sx, sy, sw, sh), sd.GraphicsUnit.Pixel, CurrentImageAttributes); g.DrawImage(tw.SDBitmap, destPoints, new sd.RectangleF(sx, sy, sw, sh), sd.GraphicsUnit.Pixel, CurrentImageAttributes);
g.Transform = new sd.Drawing2D.Matrix(); //.Reset() doesnt work ? ? g.Transform = new sd.Drawing2D.Matrix(); //.Reset() doesnt work ? ?
@ -285,7 +284,7 @@ namespace BizHawk.Bizware.BizwareGL
public bool IsActive { get; private set; } public bool IsActive { get; private set; }
public IGL Owner { get; private set; } public IGL Owner { get; private set; }
public IGL_GdiPlus Gdi; public IGL Gdi => Owner;
} }
} }

View File

@ -5,8 +5,6 @@ using System.Drawing;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
using swf = System.Windows.Forms;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {
@ -208,10 +206,12 @@ namespace BizHawk.Bizware.BizwareGL
/// </summary> /// </summary>
void SetViewport(int width, int height); void SetViewport(int width, int height);
#if false // Unused and WinForms unavailable on .NET Standard
/// <summary> /// <summary>
/// sets the viewport (and scissor) according to the client area of the provided control /// sets the viewport (and scissor) according to the client area of the provided control
/// </summary> /// </summary>
void SetViewport(swf.Control control); void SetViewport(System.Windows.Forms.Control control);
#endif
/// <summary> /// <summary>
/// sets the viewport (and scissor) according to the provided specifications /// sets the viewport (and scissor) according to the provided specifications

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;

View File

@ -4,6 +4,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>8.0</LangVersion> <LangVersion>8.0</LangVersion>
<NoWarn>NU1701</NoWarn><!-- can't use .ruleset, and NU1702 can't be silenced at all (see https://github.com/NuGet/Home/issues/8797) -->
<OutputPath>$(SolutionDir)output/dll</OutputPath> <OutputPath>$(SolutionDir)output/dll</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<RunAnalyzersDuringBuild Condition=" '$(MachineRunAnalyzersDuringBuild)' == '' ">false</RunAnalyzersDuringBuild> <RunAnalyzersDuringBuild Condition=" '$(MachineRunAnalyzersDuringBuild)' == '' ">false</RunAnalyzersDuringBuild>