modified readme and added missing files

This commit is contained in:
emmaus 2018-06-16 15:49:03 +00:00
parent c455638dd1
commit fec7e76578
10 changed files with 170 additions and 18 deletions

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.25123.0 VisualStudioVersion = 15.0.27703.2000
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator.Bind", "src\Generator.Bind\Generator.Bind.csproj", "{31D19132-0000-0000-0000-000000000000}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator.Bind", "src\Generator.Bind\Generator.Bind.csproj", "{31D19132-0000-0000-0000-000000000000}"
EndProject EndProject
@ -29,10 +29,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{F1A570
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{5EEEC96B-BD2F-45B0-935D-19E9E6D7D969}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{5EEEC96B-BD2F-45B0-935D-19E9E6D7D969}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
build.fsx = build.fsx build.fsx = build.fsx
README.md = README.md README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md RELEASE_NOTES.md = RELEASE_NOTES.md
.gitignore = .gitignore
EndProjectSection EndProjectSection
EndProject EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests", "tests\OpenTK.Tests\OpenTK.Tests.fsproj", "{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests", "tests\OpenTK.Tests\OpenTK.Tests.fsproj", "{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}"
@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Tests.Math", "tests\
EndProject EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Generators", "tests\OpenTK.Tests.Generators\OpenTK.Tests.Generators.fsproj", "{2B11AAEB-D8AC-4356-938F-532D720E0C30}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Generators", "tests\OpenTK.Tests.Generators\OpenTK.Tests.Generators.fsproj", "{2B11AAEB-D8AC-4356-938F-532D720E0C30}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTK.Standard", "src\OpenTK\OpenTK.Standard.csproj", "{67F02FD3-8F7F-4D89-8551-359993271CA3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -97,6 +99,10 @@ Global
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B11AAEB-D8AC-4356-938F-532D720E0C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.ActiveCfg = Release|Any CPU {2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.Build.0 = Release|Any CPU {2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.Build.0 = Release|Any CPU
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -107,4 +113,7 @@ Global
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B} {C2B07CD9-B388-4FC3-AF31-C648F7EA904E} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
{2B11AAEB-D8AC-4356-938F-532D720E0C30} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B} {2B11AAEB-D8AC-4356-938F-532D720E0C30} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CFF5ADCD-8B5E-4C07-ACCA-304C81D4D839}
EndGlobalSection
EndGlobal EndGlobal

View File

@ -58,8 +58,8 @@ cd opentk # Enter the source directory
./build.sh # Build on Mono (Linux / Mac OS X) ./build.sh # Build on Mono (Linux / Mac OS X)
``` ```
After this is done at least once, you can build OpenTK normally through After this is done at least once, you can build OpenTK.Standard project normally through
your IDE. your IDE. This fork is only for building opentk for .Net Standard, and not for .Net Framework.
News News
==== ====

View File

@ -35,5 +35,12 @@ namespace OpenTK.Rewrite
[Option("dllimport", Default = false, [Option("dllimport", Default = false,
HelpText = "Force native calls to use DllImport instead of GetProcAddress.")] HelpText = "Force native calls to use DllImport instead of GetProcAddress.")]
public bool UseDLLImport { get; set; } public bool UseDLLImport { get; set; }
/// <summary>
/// Toggles rewriting for NetStandard.
/// </summary>
[Option('n', "netstandard", Default = false,
HelpText = "Toggles rewriting for NetStandard.")]
public bool IsNetStandard { get; set; }
} }
} }

View File

@ -55,6 +55,8 @@ namespace OpenTK.Rewrite
program.Rewrite(); program.Rewrite();
} }
private static string GetCoreAssemblyName() => Options.IsNetStandard ? "netstandard" : "mscorlib";
// mscorlib types // mscorlib types
private static AssemblyDefinition mscorlib; private static AssemblyDefinition mscorlib;
@ -93,6 +95,21 @@ namespace OpenTK.Rewrite
Console.Error.WriteLine("No keyfile specified or keyfile missing."); Console.Error.WriteLine("No keyfile specified or keyfile missing.");
} }
if (Options.IsNetStandard)
{
DefaultAssemblyResolver resolver = new DefaultAssemblyResolver();
string searchPath = GetNetstandardRefPath();
if (!Directory.Exists(searchPath))
{
Console.Error.WriteLine(
"Could not locate .NET Standard reference assemblies. This is necessary for binary rewriting to proceed.");
return;
}
resolver.AddSearchDirectory(searchPath);
read_params.AssemblyResolver = resolver;
}
// Load assembly and process all modules // Load assembly and process all modules
try try
{ {
@ -108,7 +125,7 @@ namespace OpenTK.Rewrite
try try
{ {
var resolved = module.AssemblyResolver.Resolve(reference); var resolved = module.AssemblyResolver.Resolve(reference);
if (reference.Name == "mscorlib") if (reference.Name == GetCoreAssemblyName())
{ {
mscorlib = resolved; mscorlib = resolved;
} }
@ -122,7 +139,7 @@ namespace OpenTK.Rewrite
if (mscorlib == null) if (mscorlib == null)
{ {
Console.Error.WriteLine("Failed to locate mscorlib"); Console.Error.WriteLine("Failed to locate " + GetCoreAssemblyName());
return; return;
} }
TypeMarshal = mscorlib.MainModule.GetType("System.Runtime.InteropServices.Marshal"); TypeMarshal = mscorlib.MainModule.GetType("System.Runtime.InteropServices.Marshal");
@ -1073,5 +1090,18 @@ namespace OpenTK.Rewrite
{ {
il.Emit(OpCodes.Call, reference); il.Emit(OpCodes.Call, reference);
} }
private string GetNetstandardRefPath()
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
".nuget",
"packages",
"netstandard.library",
"2.0.1",
"build",
"netstandard2.0",
"ref");
}
} }
} }

View File

@ -340,7 +340,7 @@ namespace OpenTK.Graphics.ES20
{ {
GL.Viewport(0, 0, size.Width, size.Height); GL.Viewport(0, 0, size.Width, size.Height);
} }
#if !MINIMAL
public static void Viewport(Point location, Size size) public static void Viewport(Point location, Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);
@ -350,7 +350,7 @@ namespace OpenTK.Graphics.ES20
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }
#if MINIMAL #else
public static void Viewport(OpenTK.Point location, OpenTK.Size size) public static void Viewport(OpenTK.Point location, OpenTK.Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);

View File

@ -335,7 +335,7 @@ namespace OpenTK.Graphics.ES30
{ {
GL.Viewport(0, 0, size.Width, size.Height); GL.Viewport(0, 0, size.Width, size.Height);
} }
#if !MINIMAL
public static void Viewport(Point location, Size size) public static void Viewport(Point location, Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);
@ -345,7 +345,7 @@ namespace OpenTK.Graphics.ES30
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }
#if MINIMAL #else
public static void Viewport(OpenTK.Point location, OpenTK.Size size) public static void Viewport(OpenTK.Point location, OpenTK.Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);

View File

@ -2772,7 +2772,7 @@ namespace OpenTK.Graphics.OpenGL
} }
} }
} }
#if MINIMAL
/// <summary> /// <summary>
/// [requires: v1.0] /// [requires: v1.0]
/// Set the viewport. This function assumes a lower left corner of (0, 0). /// Set the viewport. This function assumes a lower left corner of (0, 0).
@ -2814,7 +2814,7 @@ namespace OpenTK.Graphics.OpenGL
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }
#if MINIMAL #else
/// <summary> /// <summary>
/// [requires: v1.0] /// [requires: v1.0]
/// Set the viewport. /// Set the viewport.

View File

@ -411,7 +411,7 @@ namespace OpenTK.Graphics.OpenGL4
{ {
GL.Viewport(0, 0, size.Width, size.Height); GL.Viewport(0, 0, size.Width, size.Height);
} }
#if !MINIMAL
public static void Viewport(Point location, Size size) public static void Viewport(Point location, Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);
@ -421,7 +421,7 @@ namespace OpenTK.Graphics.OpenGL4
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }
#if MINIMAL #else
public static void Viewport(OpenTK.Point location, OpenTK.Size size) public static void Viewport(OpenTK.Point location, OpenTK.Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);

View File

@ -0,0 +1,99 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>OpenTK</AssemblyName>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>OpenTK</RootNamespace>
<DefineConstants>$(DefineConstants);WIN32;CARBON;X11;SDL2;OPENGL;OPENGLES;MINIMAL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DocumentationFile>bin\Debug\OpenTK.xml</DocumentationFile>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DocumentationFile>bin\Release\OpenTK.xml</DocumentationFile>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<DebugSymbols>True</DebugSymbols>
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>True</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\OpenTK.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Graphics\ES31\**" />
<Compile Remove="Platform\Android\**" />
<Compile Remove="Platform\iPhoneOS\**" />
<Compile Remove="Resources\**" />
<EmbeddedResource Remove="Graphics\ES31\**" />
<EmbeddedResource Remove="Platform\Android\**" />
<EmbeddedResource Remove="Platform\iPhoneOS\**" />
<EmbeddedResource Remove="Resources\**" />
<None Remove="Graphics\ES31\**" />
<None Remove="Platform\Android\**" />
<None Remove="Platform\iPhoneOS\**" />
<None Remove="Resources\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
<AdditionalFiles Include="$(SolutionDir)\stylecop.ruleset">
<Link>stylecop.ruleset</Link>
</AdditionalFiles>
</ItemGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.1</Version>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="$(OutputPath)..\..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk -debug -netstandard" Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Debug'" />
<Exec Command="$(OutputPath)..\..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk -netstandard" Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Release'" />
<Exec Command="mono $(OutputPath)..\..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk -debug -netstandard" Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Debug'" />
<Exec Command="mono $(OutputPath)..\..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk -netstandard" Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Release'" />
</Target>
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
<CSharpFormattingPolicy IndentSwitchBody="True" AnonymousMethodBraceStyle="NextLine" PropertyBraceStyle="NextLine" PropertyGetBraceStyle="NextLine" PropertySetBraceStyle="NextLine" EventBraceStyle="NextLine" EventAddBraceStyle="NextLine" EventRemoveBraceStyle="NextLine" StatementBraceStyle="NextLine" ElseNewLinePlacement="NewLine" CatchNewLinePlacement="NewLine" FinallyNewLinePlacement="NewLine" WhileNewLinePlacement="NewLine" ArrayInitializerBraceStyle="NextLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" BlankLinesBeforeFirstDeclaration="1" AlignToFirstMethodDeclarationParameter="False" AlignToFirstIndexerDeclarationParameter="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<TextStylePolicy FileWidth="120" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
<StandardHeader Text="#region License&#xA;&#xA;${FileName}&#xA; &#xA;Author:&#xA; ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Copyright (c) 2006-${Year} ${CopyrightHolder}&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a copy&#xA;of this software and associated documentation files (the &quot;Software&quot;), to deal&#xA;in the Software without restriction, including without limitation the rights&#xA;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;copies of the Software, and to permit persons to whom the Software is&#xA;furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included in&#xA;all copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#xA;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&#xA;THE SOFTWARE.&#xA;&#xA;#endregion" IncludeInNewFiles="True" />
<TextStylePolicy TabWidth="2" IndentWidth="2" NoTabsAfterNonTabs="True" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
<XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@ -44,8 +44,11 @@ namespace OpenTK.Platform.Windows
{ {
private const ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow; private const ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow;
private const ExtendedWindowStyle ChildStyleEx = 0; private const ExtendedWindowStyle ChildStyleEx = 0;
#if NETSTANDARD
private readonly IntPtr Instance = Functions.GetModuleHandle(typeof(WinGLNative).Module.Name);
#else
private readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module); private readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module);
#endif
private readonly IntPtr ClassName = Marshal.StringToHGlobalAuto(Guid.NewGuid().ToString()); private readonly IntPtr ClassName = Marshal.StringToHGlobalAuto(Guid.NewGuid().ToString());
private readonly WindowProcedure WindowProcedureDelegate; private readonly WindowProcedure WindowProcedureDelegate;
@ -1240,11 +1243,15 @@ namespace OpenTK.Platform.Windows
} }
} }
} }
#if !NETSTANDARD
Debug.Assert(oldCursorHandle != IntPtr.Zero); Debug.Assert(oldCursorHandle != IntPtr.Zero);
Debug.Assert(oldCursorHandle != cursor_handle); Debug.Assert(oldCursorHandle != cursor_handle);
Debug.Assert(oldCursor != cursor); Debug.Assert(oldCursor != cursor);
#else
System.Diagnostics.Debug.Assert(oldCursorHandle != IntPtr.Zero);
System.Diagnostics.Debug.Assert(oldCursorHandle != cursor_handle);
System.Diagnostics.Debug.Assert(oldCursor != cursor);
#endif
// If we've replaced a custom (non-default) cursor we need to free the handle. // If we've replaced a custom (non-default) cursor we need to free the handle.
if (oldCursor != MouseCursor.Default) if (oldCursor != MouseCursor.Default)
{ {