Merge branch 'develop' of github.com:opentk/opentk into remove-bindings-from.git

This commit is contained in:
Jarl Gullberg 2017-12-27 19:48:33 +01:00
commit 9fdcdb17b2
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23
66 changed files with 124982 additions and 207288 deletions

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
### Purpose of this PR
* Description of feature/change.
* Which part of OpenTK does this affect (Math, OpenGL, Platform, Input, etc).
* Links to screenshots, design docs, user docs, etc.
### Testing status
* Explanation of whats tested, how tested and existing or new automation tests.
* Can include manual testing by self.
* Specify test plans.
* Rarely acceptable to have no testing.
### Comments
* Any other comments to help understand the change.

View file

@ -21,8 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLWidget", "src\Open
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1857BB8E-1A35-4EBF-9F6D-685F11DC025B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.API.Desktop", "tests\Test.API.Desktop\Test.API.Desktop.csproj", "{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{F1A57014-71CE-4032-A652-01B7E35E14DB}"
ProjectSection(SolutionItems) = preProject
paket.dependencies = paket.dependencies
@ -78,10 +76,6 @@ Global
{A625BE87-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Release|Any CPU.Build.0 = Release|Any CPU
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -95,7 +89,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
{522D9279-3ED6-475F-867A-6AE69A53C24A} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
EndGlobalSection

View file

@ -181,7 +181,7 @@ Requirements
Documentation
=============
Your favorite IDE will display inline documentation for all OpenTK APIs. Additional information can be found in the [OpenTK Manual](http://www.opentk.com/doc) and in the [opentk/Documentation/](https://github.com/opentk/opentk/tree/develop/Documentation) folder.
Your favorite IDE will display inline documentation for all OpenTK APIs. Additional information can be found in the [OpenTK Manual](http://web.archive.org/web/20150325224427/http://www.opentk.com/doc).
Technical documentation about the implementation of OpenTK can be found in the [Technical Wiki](https://github.com/opentk/opentk/wiki).

View file

@ -1,3 +1,4 @@
image: Visual Studio 2017
init:
- git config --global core.autocrlf input
build_script:

View file

@ -125,7 +125,8 @@ Target "AssemblyInfo" (fun _ ->
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
Attribute.CLSCompliant true
Attribute.Copyright copyright ]
Attribute.Copyright copyright
]
let getProjectDetails projectPath =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)

View file

@ -291,7 +291,7 @@ namespace Bind
sw.WriteLine("[CLSCompliant(false)]");
}
sw.WriteLine("public static {0} {{ throw new NotImplementedException(); }}", GetDeclarationString(f, Settings.Compatibility));
sw.WriteLine("public static {0} {{ throw new BindingsNotRewrittenException(); }}", GetDeclarationString(f, Settings.Compatibility));
}
private void WriteDocumentation(BindStreamWriter sw, Function f)

View file

@ -536,11 +536,16 @@ namespace Bind
d.Parameters[i].Flow = Parameter.GetFlowDirection((string)node.TypedValue);
break;
case "count":
d.Parameters[i].ComputeSize = node.Value.Trim();
int count;
if (Int32.TryParse(node.Value, out count))
if (Int32.TryParse(d.Parameters[i].ComputeSize, out count))
{
d.Parameters[i].ElementCount = count;
}
else
{
d.Parameters[i].ElementCount = 0;
}
break;
}
}
@ -648,6 +653,22 @@ namespace Bind
{
d.Parameters[i].WrapperType |= WrapperTypes.UncheckedParameter;
}
if (function_override != null)
{
XPathNavigator param_override = function_override.SelectSingleNode(String.Format(
"param[@name='{0}' or @index='{1}']",
d.Parameters[i].RawName,
i));
if (param_override != null)
{
var legacyArrayParameter = param_override.GetAttribute("legacyArrayParameter", String.Empty);
if (!String.IsNullOrEmpty(legacyArrayParameter))
{
d.Parameters[i].WrapperType |= WrapperTypes.LegacyArrayParameter;
}
}
}
}
}
@ -1097,6 +1118,17 @@ namespace Bind
// Generics are handled in a second pass.
if ((parameter.WrapperType & WrapperTypes.GenericParameter) == 0)
{
if ((parameter.WrapperType & WrapperTypes.LegacyArrayParameter) != 0)
{
foreach (var wrapper in GetWrapper(wrappers, WrapperTypes.LegacyArrayParameter, func))
{
wrapper.Obsolete = "Use out overload instead";
var p = wrapper.Parameters[i];
p.Array++;
p.Pointer--;
}
}
if ((parameter.WrapperType & WrapperTypes.ArrayParameter) != 0)
{
foreach (var wrapper in GetWrapper(wrappers, WrapperTypes.ArrayParameter, func))

View file

@ -214,7 +214,9 @@
</Compile>
<Compile Include="GL2\GL2Generator.cs" />
<Compile Include="Structures\Documentation.cs" />
<None Include="Specifications\GL2\overrides.xml" />
<None Include="Specifications\GL2\overrides.xml">
<SubType>Designer</SubType>
</None>
<None Include="Specifications\GL2\GL\4.5\ARB_direct_state_access.xml" />
<None Include="Specifications\GL2\ES\3.1\KHR_compute_shader.xml" />
<None Include="Specifications\GL2\ES\3.1\KHR_separate_shader_objects.xml" />

View file

@ -228,12 +228,6 @@
</param>
</function>
<function name="ShaderSource" extension="Core|Arb">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetActiveAttrib" extension="Core">
<param name="type">
<type>ActiveAttribType</type>
@ -1104,6 +1098,7 @@
<param name="identifier">
<type>ObjectLabelIdentifier</type>
</param>
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramInterfaceiv" extension="Core">
@ -1125,6 +1120,7 @@
<param name="programInterface">
<type>ProgramInterface</type>
</param>
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramResourceiv" extension="Core">
@ -1134,6 +1130,7 @@
<param name="props">
<type>ProgramProperty</type>
</param>
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramResourceLocation" extension="Core">
@ -1692,6 +1689,16 @@
</param>
</function>
<!-- For backwards compatibility -->
<function name="EdgeFlagv" extension="Core">
<param name="flag" legacyArrayParameter="true" />
</function>
<function name="GetObjectPtrLabel" extension="Core">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetObjectPtrLabel" extension="KHR">
<param name="length" legacyArrayParameter="true" />
</function>
</replace>
<overload name="glcore">
@ -1701,34 +1708,27 @@
<type>int</type>
</param>
</function>
<!-- For backwards compatibility -->
<function name="GetObjectLabel" extension="Core">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetObjectPtrLabel" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetProgramResourceiv" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetProgramResourceName" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetObjectPtrLabel" extension="KHR" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
</overload>
<!-- For backwards compatibility -->
<replace name="gl">
<function name="GetObjectLabel" extension="Ext">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetObjectPtrLabel" extension="Core">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetObjectPtrLabel" extension="KHR">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramPipelineInfoLog" extension="Core">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramPipelineInfoLog" extension="Ext">
<param name="length" legacyArrayParameter="true" />
</function>
</replace>
<overload name="gl">
<!-- generated from apitest -->
<function name="TessellationMode" extension="Amd" obsolete="Use AmdVertexShaderTessellator overload instead">
@ -1866,46 +1866,12 @@
<type>BeginMode</type>
</param>
</function>
<function name="EdgeFlagv" extension="Core" obsolete="Use ref overload instead">
<param name="flag">
<count>0</count>
</param>
</function>
<function name="GetObjectLabel" extension="Core">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetObjectPtrLabel" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetPointerv" extension="Core" obsolete="Use out overload instead">
<param name="params">
<count>0</count>
</param>
</function>
<function name="GetProgram" extension="Core" obsolete="Use GetProgramParameterName overload instead">
<param name="pname" index="1">
<type>ProgramParameter</type>
</param>
</function>
<function name="GetProgramPipelineInfoLog" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetProgramResourceiv" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetProgramResourceName" extension="Core" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetString" extension="Core" obsolete="Use StringNameIndexed overload instead">
<param name="name" index="0">
<type>StringName</type>
@ -2006,21 +1972,6 @@
<type>ExtDirectStateAccess</type>
</param>
</function>
<function name="GetObjectLabel" extension="Ext">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetPointerv" extension="Ext" obsolete="Use out overload instead">
<param name="params">
<count>0</count>
</param>
</function>
<function name="GetProgramPipelineInfoLog" extension="Ext" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="IsEnabledIndexed" extension="Ext" obsolete="Use IndexedEnableCap overload instead">
<param name="target" index="0">
<type>ExtDrawBuffers2</type>
@ -2071,16 +2022,6 @@
<type>IbmVertexArrayLists</type>
</param>
</function>
<function name="GetObjectPtrLabel" extension="KHR" obsolete="Use out overload instead">
<param name="length">
<count>0</count>
</param>
</function>
<function name="GetPointerv" extension="KHR" obsolete="Use out overload instead">
<param name="params">
<count>0</count>
</param>
</function>
<function name="DrawTransformFeedback" extension="NV" obsolete="Use PrimitiveType overload instead">
<param name="mode" index="0">
<type>NvTransformFeedback2</type>
@ -4999,21 +4940,6 @@
<function name="DrawElements" obsolete="Use PrimitiveType overload instead">
<param name="mode"><type>BeginMode</type></param>
</function>
<function name="ExtGetBuffersQCOM" extension="QCOM" obsolete="Use out overload instead">
<param name="numBuffers"><count>0</count></param>
</function>
<function name="ExtGetFramebuffersQCOM" extension="QCOM" obsolete="Use out overload instead">
<param name="numFramebuffers"><count>0</count></param>
</function>
<function name="ExtGetProgramsQCOM" extension="QCOM" obsolete="Use out overload instead">
<param name="numPrograms"><count>0</count></param>
</function>
<function name="ExtGetRenderbuffersQCOM" extension="QCOM" obsolete="Use out overload instead">
<param name="numRenderbuffers"><count>0</count></param>
</function>
<function name="ExtGetShadersQCOM" extension="QCOM" obsolete="Use out overload instead">
<param name="numShaders"><count>0</count></param>
</function>
</overload>
<replace name="gles1">
@ -5021,6 +4947,23 @@
<function name="DeletePerfMonitors" extension="AMD">
<param name="monitors"><flow>in</flow></param>
</function>
<!-- For backwards compatibility -->
<function name="ExtGetBuffersQCOM" extension="QCOM">
<param name="numBuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetFramebuffersQCOM" extension="QCOM">
<param name="numFramebuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetProgramsQCOM" extension="QCOM">
<param name="numPrograms" legacyArrayParameter="true" />
</function>
<function name="ExtGetRenderbuffersQCOM" extension="QCOM">
<param name="numRenderbuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetShadersQCOM" extension="QCOM">
<param name="numShaders" legacyArrayParameter="true" />
</function>
</replace>
<add name="gles1">
@ -5575,46 +5518,59 @@
</function>
<function name="GetObjectLabel">
<param name="identifier"><type>ObjectLabelIdentifier</type></param>
<param name="length" legacyArrayParameter="true" />
</function>
<function name="ObjectLabel">
<param name="identifier"><type>ObjectLabelIdentifier</type></param>
</function>
</replace>
<!-- gles2 overloads for backwards compatibility (2.0 and 3.0) -->
<overload name="gles2">
<!-- gles2 replacements for backwards compatibility -->
<replace name="gles2">
<function name="GetObjectLabel">
<param name="length"><count>0</count></param>
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetObjectPtrLabel" obsolete="Use out overload instead">
<param name="length"><count>0</count></param>
<function name="GetObjectPtrLabel">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetTranslatedShaderSource" extension="ANGLE" obsolete="Use out overload instead">
<param name="length"><count>0</count></param>
<function name="GetProgramPipelineInfoLog" extension="EXT">
<param name="length" legacyArrayParameter="true" />
</function>
<function name="GetProgramPipelineInfoLog" extension="EXT" obsolete="Use out overload instead">
<param name="length"><count>0</count></param>
<!-- GetTranslatedShaderSource is missing count attributes -->
<function name="GetTranslatedShaderSource" extension="ANGLE">
<param name="length" legacyArrayParameter="true" />
<param name="source">
<count>bufsize</count>
</param>
</function>
<function name="GetProgramBinary" extension="OES" obsolete="Use out overload instead">
<param name="length"><count>0</count></param>
<param name="binaryFormat"><count>0</count></param>
<function name="GetProgramBinary" extension="OES">
<param name="length" legacyArrayParameter="true" />
<param name="binaryFormat" legacyArrayParameter="true" />
</function>
<function name="ExtGetBuffers" extension="QCOM" obsolete="Use out overload instead">
<param name="numBuffers"><count>0</count></param>
<function name="ExtGetBuffers" extension="QCOM">
<param name="numBuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetFramebuffers" extension="QCOM" obsolete="Use out overload instead">
<param name="numFramebuffers"><count>0</count></param>
<function name="ExtGetFramebuffers" extension="QCOM">
<param name="numFramebuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetPrograms" extension="QCOM" obsolete="Use out overload instead">
<param name="numPrograms"><count>0</count></param>
<function name="ExtGetPrograms" extension="QCOM">
<param name="numPrograms" legacyArrayParameter="true" />
</function>
<function name="ExtGetRenderbuffers" extension="QCOM" obsolete="Use out overload instead">
<param name="numRenderbuffers"><count>0</count></param>
<function name="ExtGetRenderbuffers" extension="QCOM">
<param name="numRenderbuffers" legacyArrayParameter="true" />
</function>
<function name="ExtGetShaders" extension="QCOM" obsolete="Use out overload instead">
<param name="numShaders"><count>0</count></param>
<function name="ExtGetShaders" extension="QCOM">
<param name="numShaders" legacyArrayParameter="true" />
</function>
</overload>
</replace>
<!-- gles2 replacements for backwards compatibility (2.0 only) -->
<replace name="gles2" version="2.0">
<!-- Khronos added count="1" to VertexAttrib1fv -->
<function name="VertexAttrib1fv">
<param name="v" legacyArrayParameter="true" />
</function>
</replace>
<!-- gles2 overloads for backwards compatibility (2.0 only) -->
<overload name="gles2" version="2.0">
@ -5674,13 +5630,6 @@
<param name="format"><type>PixelFormat</type></param>
</function>
<!-- Khronos added count="1" to VertexAttrib1fv -->
<function name="VertexAttrib1fv">
<param name="v">
<count>0</count>
</param>
</function>
<!-- generated by apitest -->
<function name="FramebufferRenderbuffer" obsolete="Use FramebufferAttachment overload instead">
<param name="attachment">
@ -7495,4 +7444,40 @@
</add>
<!-- INTEL_performance_query -->
<replace name="gl|glcore|gles1|gles2">
<!-- GetPerfQueryIdByNameINTEL is not const-correct -->
<function name="GetPerfQueryIdByNameINTEL" extension="INTEL">
<param name="queryName">
<flow>in</flow>
</param>
</function>
<!-- GetPerfCounterInfoINTEL is missing count attributes -->
<function name="GetPerfCounterInfoINTEL" extension="INTEL">
<param name="counterName">
<count>counterNameLength</count>
</param>
<param name="counterDesc">
<count>counterDescLength</count>
</param>
</function>
<!-- GetPerfQueryInfoINTEL is missing count attributes -->
<function name="GetPerfQueryInfoINTEL" extension="INTEL">
<param name="queryName">
<count>queryNameLength</count>
</param>
</function>
</replace>
<!-- ExtGetProgramBinarySourceQCOM -->
<replace name="gl|glcore|gles1|gles2">
<!-- ExtGetProgramBinarySourceQCOM is missing count attributes -->
<function name="ExtGetProgramBinarySourceQCOM" extension="QCOM">
<param name="source">
<count>*length</count>
</param>
</function>
</replace>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -94,6 +94,10 @@ namespace Bind
/// Add an int32 overload for convenience.
/// </summary>
SizeParameter = 1 << 14,
/// <summary>
/// Function takes a ref but we emit a legacy array overload to maintain backwards compatability.
/// </summary>
LegacyArrayParameter = 1 << 15,
}
internal static class Utilities

View file

@ -304,21 +304,14 @@ namespace Bind
p.CurrentType = param.GetAttribute("type", String.Empty).Trim();
p.Name = param.GetAttribute("name", String.Empty).Trim();
string element_count = param.GetAttribute("elementcount", String.Empty).Trim();
if (String.IsNullOrEmpty(element_count))
p.ComputeSize = param.GetAttribute("count", String.Empty).Trim();
int elementCount;
if (Int32.TryParse(p.ComputeSize, out elementCount))
{
element_count = param.GetAttribute("count", String.Empty).Trim();
if (!String.IsNullOrEmpty(element_count))
{
int count;
if (Int32.TryParse(element_count, out count))
{
p.ElementCount = count;
}
}
p.ElementCount = elementCount;
}
p.ComputeSize = param.GetAttribute("count", String.Empty).Trim();
p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty).Trim());
d.Parameters.Add(p);

View file

@ -7,7 +7,7 @@ This is a simple tool to convert Khronos XML to OpenTK XML files.
Converting local files:
Convert.exe --input-files gl.xml --output-file signatures.xml --prefix gl
Converting latest remote specification:
Convert.exe --input-files https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml --output-file signatures.xml --prefix gl
Convert.exe --input-files https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml --output-file signatures.xml --prefix gl
-p, --prefix Required. (Default: gl) The prefix to remove from parsed functions and constants.

View file

@ -27,7 +27,7 @@
<DocumentationFile>bin\Debug\Rewrite.xml</DocumentationFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Commandlineparameters>../../OpenTK/Debug/OpenTK.dll ../../../OpenTK.snk -debug</Commandlineparameters>
<Commandlineparameters>--assembly ../../OpenTK/Debug/OpenTK.dll --signing-key ../../../OpenTK.snk --debug</Commandlineparameters>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -38,7 +38,7 @@
<DocumentationFile>bin\Release\Rewrite.xml</DocumentationFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Commandlineparameters>../../OpenTK/Release/OpenTK.dll ../../../OpenTK.snk</Commandlineparameters>
<Commandlineparameters>--assembly ../../OpenTK/Release/OpenTK.dll --signing-key ../../../OpenTK.snk</Commandlineparameters>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@ -59,6 +59,7 @@
<ItemGroup>
<Compile Include="CountAttribute.cs" />
<Compile Include="GeneratedVariableIdentifier.cs" />
<Compile Include="Options.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@ -98,6 +99,35 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.0.3')">
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\..\packages\CommandLineParser\lib\net40\CommandLine.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\..\packages\CommandLineParser\lib\net45\CommandLine.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1')) Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == 'Xamarin.tvOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.watchOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac')">
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\..\packages\CommandLineParser\lib\netstandard1.5\CommandLine.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<ItemGroup>
@ -229,6 +259,29 @@
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
<Reference Include="mscorlib">
<Paket>True</Paket>
</Reference>
<Reference Include="System.Console">
<HintPath>..\..\packages\System.Console\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Console">
<HintPath>..\..\packages\System.Console\ref\netstandard1.3\System.Console.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2')">
<ItemGroup>
@ -310,9 +363,6 @@
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
<Reference Include="mscorlib">
<Paket>True</Paket>
</Reference>
<Reference Include="System.IO">
<HintPath>..\..\packages\System.IO\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
@ -417,6 +467,82 @@
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\..\packages\System.Linq.Expressions\lib\net463\System.Linq.Expressions.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2')">
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\..\packages\System.Linq.Expressions\ref\netstandard1.0\System.Linq.Expressions.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5')">
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\..\packages\System.Linq.Expressions\ref\netstandard1.3\System.Linq.Expressions.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\..\packages\System.Linq.Expressions\lib\netstandard1.6\System.Linq.Expressions.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\..\packages\System.Linq.Expressions\ref\netstandard1.6\System.Linq.Expressions.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2')">
<ItemGroup>
<Reference Include="System.ObjectModel">
<HintPath>..\..\packages\System.ObjectModel\ref\netstandard1.0\System.ObjectModel.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.ObjectModel">
<HintPath>..\..\packages\System.ObjectModel\lib\netstandard1.3\System.ObjectModel.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.ObjectModel">
<HintPath>..\..\packages\System.ObjectModel\ref\netstandard1.3\System.ObjectModel.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
@ -455,6 +581,77 @@
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit">
<HintPath>..\..\packages\System.Reflection.Emit\ref\netstandard1.1\System.Reflection.Emit.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit">
<HintPath>..\..\packages\System.Reflection.Emit\lib\netstandard1.3\System.Reflection.Emit.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit.ILGeneration">
<HintPath>..\..\packages\System.Reflection.Emit.ILGeneration\ref\netstandard1.0\System.Reflection.Emit.ILGeneration.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit.ILGeneration">
<HintPath>..\..\packages\System.Reflection.Emit.ILGeneration\lib\netstandard1.3\System.Reflection.Emit.ILGeneration.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit.Lightweight">
<HintPath>..\..\packages\System.Reflection.Emit.Lightweight\ref\netstandard1.0\System.Reflection.Emit.Lightweight.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.Reflection.Emit.Lightweight">
<HintPath>..\..\packages\System.Reflection.Emit.Lightweight\lib\netstandard1.3\System.Reflection.Emit.Lightweight.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Reflection.Extensions">
<HintPath>..\..\packages\System.Reflection.Extensions\ref\netstandard1.0\System.Reflection.Extensions.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
@ -466,6 +663,35 @@
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
<ItemGroup>
<Reference Include="System.Reflection.TypeExtensions">
<HintPath>..\..\packages\System.Reflection.TypeExtensions\lib\net462\System.Reflection.TypeExtensions.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1'))">
<ItemGroup>
<Reference Include="System.Reflection.TypeExtensions">
<HintPath>..\..\packages\System.Reflection.TypeExtensions\lib\netstandard1.5\System.Reflection.TypeExtensions.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>
<Reference Include="System.Reflection.TypeExtensions">
<HintPath>..\..\packages\System.Reflection.TypeExtensions\ref\netstandard1.5\System.Reflection.TypeExtensions.dll</HintPath>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6' Or $(TargetFrameworkVersion) == 'v2.0')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v2.0'))">
<ItemGroup>

View file

@ -0,0 +1,39 @@
using CommandLine;
using CommandLine.Text;
namespace OpenTK.Rewrite
{
/// <summary>
/// A container class used by <see cref="CommandLine.Parser"/> to parse command line arguments.
/// </summary>
public class Options
{
/// <summary>
/// Gets or sets the path to the target assembly that should be rewritten.
/// </summary>
[Option('a', "assembly", Required = true,
HelpText = "The path to the target assembly that should be rewritten.")]
public string TargetAssembly { get; set; }
/// <summary>
/// Get or sets the path to the strong name key which should be used to sign or resign the assembly.
/// </summary>
[Option('k', "signing-key",
HelpText = "The path to the strong name key which should be used to sign or resign the assembly.")]
public string StrongNameKey { get; set; }
/// <summary>
/// Gets or sets a value indicating whether calls to GL.GetError() are wrapped around each native call.
/// </summary>
[Option('d', "debug", Default = false,
HelpText = "Enable calls to GL.GetError(), wrapped around each native call.")]
public bool EnableDebugCalls { get; set; }
/// <summary>
/// Gets or sets a value indicating whether native calls are forced to use DllImport instead of GetProcAddress.
/// </summary>
[Option("dllimport", Default = false,
HelpText = "Force native calls to use DllImport instead of GetProcAddress.")]
public bool UseDLLImport { get; set; }
}
}

View file

@ -18,7 +18,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CommandLine;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
@ -29,22 +29,29 @@ namespace OpenTK.Rewrite
// with the s IL instructions.
internal class Program
{
private static Options Options;
private static void Main(string[] args)
{
if (args.Length == 0)
Parser.Default.ParseArguments<Options>(args)
.WithParsed(result => Options = result)
.WithNotParsed(error => Environment.Exit(-1));
// Argument error checking
if (!File.Exists(Options.TargetAssembly))
{
Console.WriteLine("Usage: rewrite [file.dll] [file.snk] [options]");
Console.WriteLine("[options] is:");
Console.WriteLine(" -debug (enable calls to GL.GetError())");
Console.WriteLine(" -dllimport (force calls to use DllImport instead of GetProcAddress)");
return;
Console.Error.WriteLine($"Target assembly not found. \n" +
$"Please check the given path ({Options.TargetAssembly}).");
}
if (!File.Exists(Path.ChangeExtension(Options.TargetAssembly, "pdb")))
{
Console.Error.WriteLine("Debugging symbols for target assembly not found. \n" +
"Please make sure that debugging symbols are being generated.");
}
var program = new Program();
var file = args[0];
var key = args[1];
var options = args.Where(a => a.StartsWith("-") || a.StartsWith("/"));
program.Rewrite(file, key, options);
program.Rewrite();
}
// mscorlib types
@ -58,13 +65,8 @@ namespace OpenTK.Rewrite
// OpenTK.BindingsBase
private static TypeDefinition TypeBindingsBase;
private static bool dllimport;
private void Rewrite(string file, string keyfile, IEnumerable<string> options)
private void Rewrite()
{
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
dllimport = optionsEnumerated.Contains("-dllimport");
// Specify assembly read and write parameters
// We want to keep a valid symbols file (pdb or mdb)
var read_params = new ReaderParameters();
@ -74,11 +76,11 @@ namespace OpenTK.Rewrite
read_params.ReadWrite = true;
write_params.WriteSymbols = true;
if (!String.IsNullOrEmpty(keyfile) && File.Exists(keyfile))
if (!String.IsNullOrEmpty(Options.StrongNameKey) && File.Exists(Options.StrongNameKey))
{
keyfile = Path.GetFullPath(keyfile);
string absoluteKeyFilePath = Path.GetFullPath(Options.StrongNameKey);
using (var fs = new FileStream(keyfile, FileMode.Open, FileAccess.Read))
using (var fs = new FileStream(absoluteKeyFilePath, FileMode.Open, FileAccess.Read))
{
var keypair = new System.Reflection.StrongNameKeyPair(fs);
write_params.StrongNameKeyPair = keypair;
@ -92,7 +94,7 @@ namespace OpenTK.Rewrite
// Load assembly and process all modules
try
{
using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(file, read_params))
using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(Options.TargetAssembly, read_params))
{
var rewritten = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name == "RewrittenAttribute");
if (rewritten == null)
@ -132,7 +134,7 @@ namespace OpenTK.Rewrite
{
foreach (var type in module.Types)
{
Rewrite(type, optionsEnumerated);
Rewrite(type);
}
}
}
@ -152,7 +154,7 @@ namespace OpenTK.Rewrite
}
}
private void Rewrite(TypeDefinition type, IEnumerable<string> options)
private void Rewrite(TypeDefinition type)
{
var entry_points = type.Fields.FirstOrDefault(f => f.Name == "EntryPoints");
if (entry_points != null)
@ -162,7 +164,7 @@ namespace OpenTK.Rewrite
entry_signatures.AddRange(type.Methods
.Where(t => t.CustomAttributes.Any(a => a.AttributeType.Name == "SlotAttribute")));
Rewrite(type, entry_points, entry_signatures, options);
Rewrite(type, entry_points, entry_signatures);
RemoveNativeSignatures(type, entry_signatures);
}
@ -180,7 +182,7 @@ namespace OpenTK.Rewrite
private static int GetSlot(MethodDefinition signature)
{
// Pretend there is no slots if we want to force everything to work through DllImport (Android & iOS)
if (dllimport)
if (Options.UseDLLImport)
{
return -1;
}
@ -196,14 +198,13 @@ namespace OpenTK.Rewrite
}
private void Rewrite(TypeDefinition type, FieldDefinition entry_points,
List<MethodDefinition> entry_signatures, IEnumerable<string> options)
List<MethodDefinition> entry_signatures)
{
// Rewrite all wrapper methods
var wrapper_signatures = new List<MethodDefinition>();
wrapper_signatures.AddRange(type.Methods
.Where(m => m.IsPublic && m.CustomAttributes.Any(a => a.AttributeType.Name == "AutoGeneratedAttribute")));
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
foreach (var wrapper in wrapper_signatures)
{
var autogenerated = wrapper.CustomAttributes
@ -215,7 +216,7 @@ namespace OpenTK.Rewrite
var signature = entry_signatures.FirstOrDefault(s => s.Name == signature_name);
int slot = GetSlot(signature);
ProcessMethod(wrapper, signature, slot, entry_points, optionsEnumerated);
ProcessMethod(wrapper, signature, slot, entry_points);
}
}
@ -225,7 +226,7 @@ namespace OpenTK.Rewrite
{
foreach (var nested_type in type.NestedTypes)
{
Rewrite(nested_type, entry_points, entry_signatures, optionsEnumerated);
Rewrite(nested_type, entry_points, entry_signatures);
}
}
}
@ -272,7 +273,7 @@ namespace OpenTK.Rewrite
// Create body for method
private static void ProcessMethod(MethodDefinition wrapper, MethodDefinition native, int slot,
FieldDefinition entry_points, IEnumerable<string> options)
FieldDefinition entry_points)
{
var body = wrapper.Body;
var il = body.GetILProcessor();
@ -283,8 +284,7 @@ namespace OpenTK.Rewrite
// and push each parameter on the stack
DebugVariables vars = null;
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
if (optionsEnumerated.Contains("-debug"))
if (Options.EnableDebugCalls)
{
vars = EmitDebugPrologue(wrapper, il);
}
@ -301,7 +301,12 @@ namespace OpenTK.Rewrite
generatedVariables = EmitConvenienceWrapper(wrapper, native, difference, body, il);
}
if (slot != -1)
if (slot == -1 || Options.UseDLLImport)
{
// issue DllImport call
EmitCall(il, native);
}
else
{
// push the entry point address on the stack
EmitEntryPoint(entry_points, il, slot);
@ -309,11 +314,6 @@ namespace OpenTK.Rewrite
// issue calli
EmitCalli(il, native);
}
else
{
// issue DllImport call
EmitCall(il, native);
}
if (wrapper.ReturnType.Name != "Void")
{
@ -322,7 +322,7 @@ namespace OpenTK.Rewrite
EmitParameterEpilogues(wrapper, native, body, il, generatedVariables);
if (optionsEnumerated.Contains("-debug"))
if (Options.EnableDebugCalls)
{
EmitDebugEpilogue(wrapper, il, vars);
}
@ -863,9 +863,10 @@ namespace OpenTK.Rewrite
var attribute = parameter.CustomAttributes
.FirstOrDefault(a => a.AttributeType.Name == "CountAttribute");
var count = new CountAttribute();
CountAttribute count = null;
if (attribute != null)
{
count = new CountAttribute();
count.Count = (int)(GetAttributeField(attribute, "Count") ?? 0);
count.Parameter = (string)(GetAttributeField(attribute, "Parameter"));
count.Computed = (string)(GetAttributeField(attribute, "Computed"));
@ -879,8 +880,8 @@ namespace OpenTK.Rewrite
var countVariable = new VariableDefinition(TypeInt32);
body.Variables.Add(countVariable);
// Parameter will either by a simple name or an
// expression like "name*5"
// Parameter will either by a simple name, a dereference of a name
// like "*name" or an expression like "name*5"
var parameter = method.Parameters.FirstOrDefault(
param => param.Name == countParameter);
if (parameter != null)
@ -888,6 +889,14 @@ namespace OpenTK.Rewrite
il.Emit(OpCodes.Ldarg, parameter.Index);
il.Emit(OpCodes.Stloc, countVariable.Index);
}
else if (countParameter[0] == '*')
{
var pointerParam = method.Parameters.FirstOrDefault(
param => param.Name == countParameter.Substring(1));
il.Emit(OpCodes.Ldarg, pointerParam.Index);
il.Emit(OpCodes.Ldind_I4);
}
else
{
var operands = countParameter.Split('*');

View file

@ -1,2 +1,3 @@
Mono.Cecil
StyleCop.Analyzers
CommandLineParser

View file

@ -1,14 +1,9 @@
using System;
using System.Threading;
using System.ComponentModel;
using Gdk;
using OpenTK.Graphics;
using OpenTK.Platform;
using Gtk;
using OpenTK.OSX;
using OpenTK.Win;
using OpenTK.X11;
namespace OpenTK
{
@ -17,66 +12,28 @@ namespace OpenTK
/// </summary>
[CLSCompliant(false)]
[ToolboxItem(true)]
public class GLWidget: DrawingArea
public class GLWidget : GLArea
{
private static int _GraphicsContextCount;
private static bool _SharedContextInitialized = false;
private IGraphicsContext _GraphicsContext;
private IWindowInfo _WindowInfo;
private bool _Initialized = false;
/// <summary>
/// Use a single buffer versus a double buffer.
/// The previous frame time reported by GTK.
/// </summary>
[Browsable(true)]
public bool SingleBuffer { get; set; }
private double? _PreviousFrameTime;
/// <summary>
/// Color Buffer Bits-Per-Pixel
/// Gets the time taken to render the last frame (in seconds).
/// </summary>
public int ColorBPP { get; set; }
public double DeltaTime { get; private set; }
/// <summary>
/// Accumulation Buffer Bits-Per-Pixel
/// The set <see cref="ContextFlags"/> for this widget.
/// </summary>
public int AccumulatorBPP { get; set; }
/// <summary>
/// Depth Buffer Bits-Per-Pixel
/// </summary>
public int DepthBPP { get; set; }
/// <summary>
/// Stencil Buffer Bits-Per-Pixel
/// </summary>
public int StencilBPP { get; set; }
/// <summary>
/// Number of samples
/// </summary>
public int Samples { get; set; }
/// <summary>
/// Indicates if steropic renderering is enabled
/// </summary>
public bool Stereo { get; set; }
/// <summary>
/// The major version of OpenGL to use.
/// </summary>
public int GlVersionMajor { get; set; }
/// <summary>
/// The minor version of OpenGL to use.
/// </summary>
public int GlVersionMinor { get; set; }
/// <summary>
/// The set <see cref="GraphicsContextFlags"/> for this widget.
/// </summary>
public GraphicsContextFlags GraphicsContextFlags { get; set; }
public GraphicsContextFlags ContextFlags { get; }
/// <summary>
/// Initializes a new instance of the <see cref="GLWidget"/> class.
@ -98,24 +55,71 @@ namespace OpenTK
/// <param name="graphicsMode">The <see cref="GraphicsMode"/> which the widget should be constructed with.</param>
/// <param name="glVersionMajor">The major OpenGL version to attempt to initialize.</param>
/// <param name="glVersionMinor">The minor OpenGL version to attempt to initialize.</param>
/// <param name="graphicsContextFlags">
/// <param name="contextFlags">
/// Any flags which should be used during initialization of the <see cref="GraphicsContext"/>.
/// </param>
public GLWidget(GraphicsMode graphicsMode, int glVersionMajor, int glVersionMinor, GraphicsContextFlags graphicsContextFlags)
public GLWidget(GraphicsMode graphicsMode, int glVersionMajor, int glVersionMinor, GraphicsContextFlags contextFlags)
{
this.DoubleBuffered = false;
ContextFlags = contextFlags;
SingleBuffer = graphicsMode.Buffers == 1;
ColorBPP = graphicsMode.ColorFormat.BitsPerPixel;
AccumulatorBPP = graphicsMode.AccumulatorFormat.BitsPerPixel;
DepthBPP = graphicsMode.Depth;
StencilBPP = graphicsMode.Stencil;
Samples = graphicsMode.Samples;
Stereo = graphicsMode.Stereo;
AddTickCallback(UpdateFrameTime);
SetRequiredVersion(glVersionMajor, glVersionMinor);
GlVersionMajor = glVersionMajor;
GlVersionMinor = glVersionMinor;
GraphicsContextFlags = graphicsContextFlags;
if (graphicsMode.Depth > 0)
{
HasDepthBuffer = true;
}
if (graphicsMode.Stencil > 0)
{
HasStencilBuffer = true;
}
if (graphicsMode.ColorFormat.Alpha > 0)
{
HasAlpha = true;
}
}
/// <summary>
/// Updates the time delta with a new value from the last frame.
/// </summary>
/// <param name="widget">The sending widget.</param>
/// <param name="frameClock">The relevant frame clock.</param>
/// <returns>true if the callback should be called again; otherwise, false.</returns>
private bool UpdateFrameTime(Widget widget, FrameClock frameClock)
{
var frameTimeµSeconds = frameClock.FrameTime;
if (!_PreviousFrameTime.HasValue)
{
_PreviousFrameTime = frameTimeµSeconds;
return true;
}
var frameTimeSeconds = (frameTimeµSeconds - _PreviousFrameTime) / 10e6;
DeltaTime = (float)frameTimeSeconds;
_PreviousFrameTime = frameTimeµSeconds;
return true;
}
/// <inheritdoc />
protected override GLContext OnCreateContext()
{
var gdkGLContext = Window.CreateGlContext();
GetRequiredVersion(out var major, out var minor);
gdkGLContext.SetRequiredVersion(major, minor);
gdkGLContext.DebugEnabled = ContextFlags.HasFlag(GraphicsContextFlags.Debug);
gdkGLContext.ForwardCompatible = ContextFlags.HasFlag(GraphicsContextFlags.ForwardCompatible);
gdkGLContext.Realize();
return gdkGLContext;
}
/// <summary>
@ -137,39 +141,15 @@ namespace OpenTK
base.Destroy();
}
#if !GTK3
/// <summary>
/// Disposes the current object, releasing any native resources it was using.
/// </summary>
/// <param name="disposing"></param>
public override void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
base.Dispose();
}
#endif
#if GTK3
/// <summary>
/// Disposes the current object, releasing any native resources it was using.
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
#else
/// <summary>
/// Disposes the current object, releasing any native resources it was using.
/// </summary>
/// <param name="disposing"></param>
public virtual void Dispose(bool disposing)
{
#endif
if (disposing)
{
_GraphicsContext.MakeCurrent(_WindowInfo);
MakeCurrent();
OnShuttingDown();
if (GraphicsContext.ShareContexts && (Interlocked.Decrement(ref _GraphicsContextCount) == 0))
{
@ -231,22 +211,6 @@ namespace OpenTK
}
}
/// <summary>
/// Called when this <see cref="GLWidget"/> needs to render a frame.
/// </summary>
public event EventHandler RenderFrame;
/// <summary>
/// Invokes the <see cref="RenderFrame"/> event.
/// </summary>
protected virtual void OnRenderFrame()
{
if (RenderFrame != null)
{
RenderFrame(this, EventArgs.Empty);
}
}
/// <summary>
/// Called when this <see cref="GLWidget"/> is being disposed.
/// </summary>
@ -263,62 +227,19 @@ namespace OpenTK
}
}
#if GTK3
/// <summary>
/// Called when the widget needs to be (fully or partially) redrawn.
/// </summary>
/// <param name="cr"></param>
/// <returns></returns>
protected override bool OnDrawn(Cairo.Context cr)
#else
/// <summary>
/// Called when the widget is exposed.
/// </summary>
/// <param name="cr"></param>
/// <returns></returns>
protected override bool OnExposeEvent(Gdk.EventExpose evnt)
#endif
{
if (!_Initialized)
{
Initialize();
}
else
{
_GraphicsContext.MakeCurrent(_WindowInfo);
}
#if GTK3
var result = base.OnDrawn(cr);
#else
bool result = base.OnExposeEvent(evnt);
#endif
OnRenderFrame();
#if !GTK3
evnt.Window.Display.Sync(); // Add Sync call to fix resize rendering problem (Jay L. T. Cornwall) - How does this affect VSync?
#endif
_GraphicsContext.SwapBuffers();
return result;
}
/// <summary>
/// Called whenever the widget is resized.
/// </summary>
/// <param name="evnt"></param>
/// <returns></returns>
protected override bool OnConfigureEvent(Gdk.EventConfigure evnt)
{
bool result = base.OnConfigureEvent(evnt);
if (_GraphicsContext != null)
{
_GraphicsContext.Update(_WindowInfo);
}
return result;
}
@ -329,66 +250,17 @@ namespace OpenTK
{
_Initialized = true;
// If this looks uninitialized... initialize.
if (ColorBPP == 0)
// Make the GDK GL context current
MakeCurrent();
// Create a dummy context that will grab the GdkGLContext that is current on the thread
_GraphicsContext = new GraphicsContext(ContextHandle.Zero, null);
if (ContextFlags.HasFlag(GraphicsContextFlags.Debug))
{
ColorBPP = 32;
if (DepthBPP == 0)
{
DepthBPP = 16;
}
_GraphicsContext.ErrorChecking = true;
}
ColorFormat colorBufferColorFormat = new ColorFormat(ColorBPP);
ColorFormat accumulationColorFormat = new ColorFormat(AccumulatorBPP);
int buffers = 2;
if (SingleBuffer)
{
buffers--;
}
GraphicsMode graphicsMode = new GraphicsMode(colorBufferColorFormat, DepthBPP, StencilBPP, Samples, accumulationColorFormat, buffers, Stereo);
if (Configuration.RunningOnWindows)
{
Console.WriteLine("OpenTK running on windows");
}
else if (Configuration.RunningOnMacOS)
{
Console.WriteLine("OpenTK running on OSX");
}
else
{
Console.WriteLine("OpenTK running on X11");
}
#if GTK3
IntPtr widgetWindowHandle = this.Window.Handle;
#else
IntPtr widgetWindowHandle = this.GdkWindow.Handle;
#endif
// IWindowInfo
if (Configuration.RunningOnWindows)
{
_WindowInfo = WinWindowsInfoInitializer.Initialize(widgetWindowHandle);
}
else if (Configuration.RunningOnMacOS)
{
_WindowInfo = OSXWindowInfoInitializer.Initialize(widgetWindowHandle);
}
else
{
_WindowInfo = XWindowInfoInitializer.Initialize(graphicsMode, this.Display.Handle, this.Screen.Number, widgetWindowHandle, this.Screen.RootWindow.Handle);
}
// GraphicsContext
_GraphicsContext = new GraphicsContext(graphicsMode, _WindowInfo, GlVersionMajor, GlVersionMinor, GraphicsContextFlags);
_GraphicsContext.MakeCurrent(_WindowInfo);
if (GraphicsContext.ShareContexts)
{
Interlocked.Increment(ref _GraphicsContextCount);

View file

@ -1,38 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using OpenTK.Platform;
namespace OpenTK.OSX
{
/// <summary>
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the OSX platform for both GTK2 and
/// GTK3.
/// </summary>
public static class OSXWindowInfoInitializer
{
#if GTK3
private const string OSXLibGdkName = "libgdk-3.dylib";
#else
const string OSXLibGdkName = "libgdk-quartz-2.0.0.dylib";
#endif
/// <summary>
/// Initializes an <see cref="IWindowInfo"/> under the OSX platform.
/// </summary>
/// <param name="gdkWindowHandle"></param>
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
{
IntPtr windowHandle = gdk_quartz_window_get_nswindow(gdkWindowHandle);
IntPtr viewHandle = gdk_quartz_window_get_nsview(gdkWindowHandle);
return Utilities.CreateMacOSWindowInfo(windowHandle, viewHandle);
}
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
private static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr handle);
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
private static extern IntPtr gdk_quartz_window_get_nsview(IntPtr handle);
}
}

View file

@ -42,7 +42,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<Deterministic>true</Deterministic>
<LangVersion>6</LangVersion>
<LangVersion>7</LangVersion>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>..\..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@ -98,13 +98,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="OSX\OSXWindowInfoInitializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GLWidget.cs" />
<Compile Include="Win\WinWindowsInfoInitializer.cs" />
<Compile Include="X11\XWindowInfoInitializer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="paket.references" />
@ -120,8 +117,7 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Choose>
<When
Condition="($(DefineConstants.Contains('GTK3')) And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.0.3' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7'))">
<When Condition="($(DefineConstants.Contains('GTK3')) And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.0.3' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7'))">
<ItemGroup>
<Reference Include="cairo-sharp">
<HintPath>..\..\packages\gtk-sharp3\lib\net40\cairo-sharp.dll</HintPath>

View file

@ -1,43 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using OpenTK.Platform;
namespace OpenTK.Win
{
/// <summary>
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the Windows platform for both GTK2 and
/// GTK3.
/// </summary>
public static class WinWindowsInfoInitializer
{
#if GTK3
private const string WinLibGDKName = "libgdk-3-0.dll";
#else
private const string WinLibGDKName = "libgdk-win32-2.0-0.dll";
#endif
/// <summary>
/// Initializes an <see cref="IWindowInfo"/> under the Windows platform.
/// </summary>
/// <param name="gdkWindowHandle"></param>
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
{
#if GTK3
IntPtr windowHandle = gdk_win32_window_get_handle(gdkWindowHandle);
#else
IntPtr windowHandle = gdk_win32_drawable_get_handle(gdkWindowHandle);
#endif
return Utilities.CreateWindowsWindowInfo(windowHandle);
}
#if GTK3
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr gdk_win32_window_get_handle(IntPtr w);
#else
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gdk_win32_drawable_get_handle(IntPtr d);
#endif
}
}

View file

@ -1,175 +0,0 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using OpenTK.Graphics;
using OpenTK.Platform;
using OpenTK.Platform.X11;
namespace OpenTK.X11
{
/// <summary>
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the X11 platform for both GTK2 and GTK3.
/// </summary>
public static class XWindowInfoInitializer
{
#if GTK3
private const string UnixLibGdkName = "libgdk-3.so.0";
#else
const string UnixLibGdkName = "libgdk-x11-2.0.so.0";
#endif
private const string UnixLibX11Name = "libX11.so.6";
private const string UnixLibGLName = "libGL.so.1";
/// <summary>
/// Initializes an <see cref="IWindowInfo"/> under the X11 platform.
/// </summary>
/// <param name="mode"></param>
/// <param name="displayHandle"></param>
/// <param name="screenNumber"></param>
/// <param name="gdkWindowHandle"></param>
/// <param name="gdkRootWindowHandle"></param>
/// <returns></returns>
public static IWindowInfo Initialize(GraphicsMode mode, IntPtr displayHandle, int screenNumber, IntPtr gdkWindowHandle, IntPtr gdkRootWindowHandle)
{
IntPtr display = gdk_x11_display_get_xdisplay(displayHandle);
#if GTK3
IntPtr windowXid = gdk_x11_window_get_xid(gdkWindowHandle);
IntPtr rootWindowXid = gdk_x11_window_get_xid(gdkRootWindowHandle);
#else
IntPtr windowXid = gdk_x11_drawable_get_xid(gdkWindowHandle);
IntPtr rootWindowXid = gdk_x11_drawable_get_xid(gdkRootWindowHandle);
#endif
IntPtr visualInfo;
if (mode.Index.HasValue)
{
XVisualInfo info = new XVisualInfo
{
VisualID = mode.Index.Value
};
int dummy;
visualInfo = XGetVisualInfo(display, XVisualInfoMask.ID, ref info, out dummy);
}
else
{
visualInfo = GetVisualInfo(mode, display, screenNumber);
}
IWindowInfo retval = Utilities.CreateX11WindowInfo(display, screenNumber, windowXid, rootWindowXid, visualInfo);
XFree(visualInfo);
return retval;
}
private static IntPtr XGetVisualInfo(IntPtr display, XVisualInfoMask infoMask, ref XVisualInfo template, out int nitems)
{
return XGetVisualInfoInternal(display, (IntPtr)(int)infoMask, ref template, out nitems);
}
private static IntPtr GetVisualInfo(GraphicsMode mode, IntPtr display, int screenNumber)
{
try
{
int[] attributes = CreateAttributeList(mode).ToArray();
return glXChooseVisual(display, screenNumber, attributes);
}
catch (DllNotFoundException e)
{
throw new DllNotFoundException("OpenGL dll not found!", e);
}
catch (EntryPointNotFoundException enf)
{
throw new EntryPointNotFoundException("Glx entry point not found!", enf);
}
}
private static List<int> CreateAttributeList(GraphicsMode mode)
{
List<int> attributeList = new List<int>(24);
attributeList.Add((int)GLXAttribute.RGBA);
if (mode.Buffers > 1)
{
attributeList.Add((int)GLXAttribute.DOUBLEBUFFER);
}
if (mode.Stereo)
{
attributeList.Add((int)GLXAttribute.STEREO);
}
attributeList.Add((int)GLXAttribute.RED_SIZE);
attributeList.Add(mode.ColorFormat.Red / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.GREEN_SIZE);
attributeList.Add(mode.ColorFormat.Green / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.BLUE_SIZE);
attributeList.Add(mode.ColorFormat.Blue / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.ALPHA_SIZE);
attributeList.Add(mode.ColorFormat.Alpha / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.DEPTH_SIZE);
attributeList.Add(mode.Depth);
attributeList.Add((int)GLXAttribute.STENCIL_SIZE);
attributeList.Add(mode.Stencil);
//attributeList.Add(GLX_AUX_BUFFERS);
//attributeList.Add(Buffers);
attributeList.Add((int)GLXAttribute.ACCUM_RED_SIZE);
attributeList.Add(mode.AccumulatorFormat.Red / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.ACCUM_GREEN_SIZE);
attributeList.Add(mode.AccumulatorFormat.Green / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.ACCUM_BLUE_SIZE);
attributeList.Add(mode.AccumulatorFormat.Blue / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.ACCUM_ALPHA_SIZE);
attributeList.Add(mode.AccumulatorFormat.Alpha / 4); // TODO support 16-bit
attributeList.Add((int)GLXAttribute.NONE);
return attributeList;
}
[DllImport(UnixLibX11Name, EntryPoint = "XGetVisualInfo")]
private static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr infoMask, ref XVisualInfo template, out int nitems);
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibX11Name)]
private static extern void XFree(IntPtr handle);
#if GTK3
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkWindow. </summary>
/// <remarks> XID gdk_x11_window_get_xid(GdkWindow *drawable); </remarks>
/// <param name="gdkDisplay"> The GdkDrawable. </param>
/// <returns> The ID of window's X resource. </returns>
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
private static extern IntPtr gdk_x11_window_get_xid(IntPtr gdkDisplay);
#else
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkDrawable. </summary>
/// <remarks> XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); </remarks>
/// <param name="gdkDisplay"> The GdkDrawable. </param>
/// <returns> The ID of drawable's X resource. </returns>
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkDisplay);
#endif
/// <summary> Returns the X display of a GdkDisplay. </summary>
/// <remarks> Display* gdk_x11_display_get_xdisplay(GdkDisplay *display); </remarks>
/// <param name="gdkDisplay"> The GdkDrawable. </param>
/// <returns> The X Display of the GdkDisplay. </returns>
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
private static extern IntPtr gdk_x11_display_get_xdisplay(IntPtr gdkDisplay);
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGLName)]
private static extern IntPtr glXChooseVisual(IntPtr display, int screen, int[] attr);
}
}

View file

@ -72,10 +72,13 @@ namespace OpenTK
protected abstract object SyncRoot { get; }
/// <summary>
/// Marshals a pointer to a null-terminated byte array to the specified <c>StringBuilder</c>.
/// Marshals a pointer to a null-terminated byte array to a new <c>System.String</c>.
/// This method supports OpenTK and is not intended to be called by user code.
/// </summary>
/// <param name="ptr">A pointer to a null-terminated byte array.</param>
/// <returns>
/// A <c>System.String</c> with the data from <paramref name="ptr"/>.
/// </returns>
protected static string MarshalPtrToString(IntPtr ptr)
{
if (ptr == IntPtr.Zero)
@ -93,13 +96,13 @@ namespace OpenTK
++str;
}
return new string((sbyte*)ptr, 0, len, null);
return new string((sbyte*)ptr, 0, len, Encoding.UTF8);
}
}
/// <summary>
/// Marshal a <c>System.String</c> to unmanaged memory.
/// The resulting string is encoded in ASCII and must be freed
/// The resulting string is encoded in UTF8 and must be freed
/// with <c>FreeStringPtr</c>.
/// </summary>
/// <param name="str">The <c>System.String</c> to marshal.</param>
@ -118,20 +121,20 @@ namespace OpenTK
// GetMaxByteCount() appears to allocate space for the final NUL
// character, but allocate an extra one just in case (who knows
// what old Mono version would do here.)
int max_count = Encoding.ASCII.GetMaxByteCount(str.Length) + 1;
int max_count = Encoding.UTF8.GetMaxByteCount(str.Length) + 1;
IntPtr ptr = Marshal.AllocHGlobal(max_count);
if (ptr == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
// Pin the managed string and convert it to ASCII using
// the pointer overload of System.Encoding.ASCII.GetBytes().
// Pin the managed string and convert it to UTF8 using
// the pointer overload of System.Encoding.UTF8.GetBytes().
unsafe
{
fixed (char* pstr = str)
{
int actual_count = Encoding.ASCII.GetBytes(pstr, str.Length, (byte*)ptr, max_count);
int actual_count = Encoding.UTF8.GetBytes(pstr, str.Length, (byte*)ptr, max_count);
Marshal.WriteByte(ptr, actual_count, 0); // Append '\0' at the end of the string
return ptr;
}

View file

@ -47,4 +47,15 @@ namespace OpenTK
/// </summary>
public override string Message { get; }
}
/// <summary>
/// This exception is thown when a binding method is called and the bindings have not been rewritten by Rewrite.exe.
/// </summary>
public class BindingsNotRewrittenException : Exception
{
/// <summary>
/// Constructs a new BindingsNotRewrittenException instance.
/// </summary>
public BindingsNotRewrittenException() : base("Rewrite.exe has not been run.") { }
}
}

View file

@ -25,6 +25,7 @@
using System;
using System.Diagnostics;
using System.Threading;
using OpenTK.Graphics;
using OpenTK.Platform;
@ -66,7 +67,11 @@ namespace OpenTK
{
private const double MaxFrequency = 500.0; // Frequency cap for Update/RenderFrame events
private readonly Stopwatch watch = new Stopwatch();
private readonly Stopwatch watchRender = new Stopwatch();
private readonly Stopwatch watchUpdate = new Stopwatch();
private Thread updateThread;
private readonly bool isSingleThreaded;
private IGraphicsContext glContext;
@ -161,12 +166,30 @@ namespace OpenTK
/// <param name="sharedContext">An IGraphicsContext to share resources with.</param>
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device,
int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext)
: this(width, height, mode, title, options, device, major, minor, flags, sharedContext, true)
{}
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
/// <param name="title">The title of the GameWindow.</param>
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
/// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
/// <param name="major">The major version for the OpenGL GraphicsContext.</param>
/// <param name="minor">The minor version for the OpenGL GraphicsContext.</param>
/// <param name="flags">The GraphicsContextFlags version for the OpenGL GraphicsContext.</param>
/// <param name="sharedContext">An IGraphicsContext to share resources with.</param>
/// <param name="isSingleThreaded">Should the update and render frames be fired on the same thread? If false, render and update events will be fired from separate threads.</param>
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device,
int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext, bool isSingleThreaded)
: base(width, height, title, options,
mode == null ? GraphicsMode.Default : mode,
device == null ? DisplayDevice.Default : device)
{
try
{
this.isSingleThreaded = isSingleThreaded;
glContext = new GraphicsContext(mode == null ? GraphicsMode.Default : mode, WindowInfo, major, minor, flags);
glContext.MakeCurrent(WindowInfo);
(glContext as IGraphicsContextInternal).LoadAll();
@ -334,13 +357,22 @@ namespace OpenTK
//Resize += DispatchUpdateAndRenderFrame;
Debug.Print("Entering main loop.");
watch.Start();
if (!isSingleThreaded)
{
updateThread = new Thread(UpdateThread);
updateThread.Start();
}
watchRender.Start();
while (true)
{
ProcessEvents();
if (Exists && !IsExiting)
{
DispatchUpdateAndRenderFrame(this, EventArgs.Empty);
if (isSingleThreaded)
{
DispatchUpdateFrame(watchRender);
}
DispatchRenderFrame();
}
else
{
@ -350,9 +382,6 @@ namespace OpenTK
}
finally
{
Move -= DispatchUpdateAndRenderFrame;
Resize -= DispatchUpdateAndRenderFrame;
if (Exists)
{
// TODO: Should similar behaviour be retained, possibly on native window level?
@ -362,21 +391,30 @@ namespace OpenTK
}
}
private void UpdateThread()
{
OnUpdateThreadStarted(this, new EventArgs());
watchUpdate.Start();
while (Exists && !IsExiting)
{
DispatchUpdateFrame(watchUpdate);
}
}
private double ClampElapsed(double elapsed)
{
return MathHelper.Clamp(elapsed, 0.0, 1.0);
}
private void DispatchUpdateAndRenderFrame(object sender, EventArgs e)
private void DispatchUpdateFrame(Stopwatch watch)
{
int is_running_slowly_retries = 4;
double timestamp = watch.Elapsed.TotalSeconds;
double elapsed = 0;
double elapsed = ClampElapsed(timestamp - update_timestamp);
elapsed = ClampElapsed(timestamp - update_timestamp);
while (elapsed > 0 && elapsed + update_epsilon >= TargetUpdatePeriod)
{
RaiseUpdateFrame(elapsed, ref timestamp);
RaiseUpdateFrame(watch, elapsed, ref timestamp);
// Calculate difference (positive or negative) between
// actual elapsed time and target elapsed time. We must
@ -403,15 +441,19 @@ namespace OpenTK
break;
}
}
}
elapsed = ClampElapsed(timestamp - render_timestamp);
private void DispatchRenderFrame()
{
double timestamp = watchRender.Elapsed.TotalSeconds;
double elapsed = ClampElapsed(timestamp - render_timestamp);
if (elapsed > 0 && elapsed >= TargetRenderPeriod)
{
RaiseRenderFrame(elapsed, ref timestamp);
}
}
private void RaiseUpdateFrame(double elapsed, ref double timestamp)
private void RaiseUpdateFrame(Stopwatch watch, double elapsed, ref double timestamp)
{
// Raise UpdateFrame event
update_args.Time = elapsed;
@ -438,7 +480,7 @@ namespace OpenTK
// Update RenderTime property
render_timestamp = timestamp;
timestamp = watch.Elapsed.TotalSeconds;
timestamp = watchRender.Elapsed.TotalSeconds;
render_time = timestamp - render_timestamp;
}
@ -790,6 +832,12 @@ namespace OpenTK
/// </summary>
public event EventHandler<FrameEventArgs> UpdateFrame = delegate { };
/// <summary>
/// If game window is configured to run with a dedicated update thread (by passing isSingleThreaded = false in the constructor),
/// occurs when the update thread has started. This would be a good place to initialize thread specific stuff (like setting a synchronization context).
/// </summary>
public event EventHandler OnUpdateThreadStarted = delegate { };
/// <summary>
/// Override to add custom cleanup logic.
/// </summary>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -42,7 +42,7 @@ namespace OpenTK.Graphics.ES11
[AutoGenerated(Category = "VERSION_ES_CM_1_0", Version = "1.0", EntryPoint = "glGetClipPlanef")]
[CLSCompliant(false)]
[Obsolete("Use GetClipPlane(..., float[]) instead. This method will return incorrect results.")]
public static Single GetClipPlane(OpenTK.Graphics.ES11.All plane) { throw new NotImplementedException(); }
public static Single GetClipPlane(OpenTK.Graphics.ES11.All plane) { throw new BindingsNotRewrittenException(); }
/// <summary>[requires: v1.0]
/// Return the coefficients of the specified clipping plane
@ -55,7 +55,7 @@ namespace OpenTK.Graphics.ES11
[AutoGenerated(Category = "VERSION_ES_CM_1_0", Version = "1.0", EntryPoint = "glGetClipPlanex")]
[CLSCompliant(false)]
[Obsolete("Use GetClipPlane(..., int[]) instead. This method will return incorrect results.")]
public static int GetClipPlanex(OpenTK.Graphics.ES11.All plane) { throw new NotImplementedException(); }
public static int GetClipPlanex(OpenTK.Graphics.ES11.All plane) { throw new BindingsNotRewrittenException(); }
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.InteropServices;
namespace OpenTK.Graphics.ES11
{
@ -38,4 +39,38 @@ namespace OpenTK.Graphics.ES11
}
}
/// <summary>
/// Defines the signature of a debug callback for
/// <see cref="GL.DebugMessageCallback"/>.
/// </summary>
/// <param name="source">The <see cref="DebugSource"/> for this debug message.</param>
/// <param name="type">The <see cref="DebugType"/> for this debug message.</param>
/// <param name="id">The id of this debug message.</param>
/// <param name="severity">The <see cref="DebugSeverity"/> for this debug message.</param>
/// <param name="length">The length of this debug message.</param>
/// <param name="message">A pointer to a null-terminated ASCII C string, representing the content of this debug message.</param>
/// <param name="userParam">A pointer to a user-specified parameter.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void DebugProc(
DebugSource source, DebugType type, int id,
DebugSeverity severity, int length, IntPtr message,
IntPtr userParam);
/// <summary>
/// Defines the signature of a debug callback for
/// <see cref="GL.Khr.DebugMessageCallback"/>.
/// </summary>
/// <param name="source">The <see cref="DebugSource"/> for this debug message.</param>
/// <param name="type">The <see cref="DebugType"/> for this debug message.</param>
/// <param name="id">The id of this debug message.</param>
/// <param name="severity">The <see cref="DebugSeverity"/> for this debug message.</param>
/// <param name="length">The length of this debug message.</param>
/// <param name="message">A pointer to a null-terminated ASCII C string, representing the content of this debug message.</param>
/// <param name="userParam">A pointer to a user-specified parameter.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void DebugProcKhr(
DebugSource source, DebugType type, int id,
DebugSeverity severity, int length, IntPtr message,
IntPtr userParam);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -31,152 +31,152 @@ namespace OpenTK
{
public static void Call(IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0>(T0 arg0, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1>(T0 arg0, T1 arg1, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2>(T0 arg0, T1 arg1, T2 arg2, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static void Call<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet>(IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0>(T0 arg0, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1>(T0 arg0, T1 arg1, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2>(T0 arg0, T1 arg1, T2 arg2, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2, T3>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2, T3, T4>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2, T3, T4, T5>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2, T3, T4, T5, T6>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static TRet CallReturn<TRet, T0, T1, T2, T3, T4, T5, T6, T7>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, IntPtr address)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static IntPtr Pin<T>(T[] arg)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static IntPtr Pin<T>(T[,] arg)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static IntPtr Pin<T>(T[,,] arg)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
public static IntPtr Pin<T>(ref T arg)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}
}

View file

@ -239,7 +239,8 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector2 a, ref Vector2 b, out Vector2 result)
{
result = new Vector2(a.X + b.X, a.Y + b.Y);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
}
/// <summary>
@ -262,7 +263,8 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector2 a, ref Vector2 b, out Vector2 result)
{
result = new Vector2(a.X - b.X, a.Y - b.Y);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
}
/// <summary>
@ -285,7 +287,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector2 vector, float scale, out Vector2 result)
{
result = new Vector2(vector.X * scale, vector.Y * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
}
/// <summary>
@ -308,7 +311,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector2 vector, ref Vector2 scale, out Vector2 result)
{
result = new Vector2(vector.X * scale.X, vector.Y * scale.Y);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
}
/// <summary>
@ -355,7 +359,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector2 vector, ref Vector2 scale, out Vector2 result)
{
result = new Vector2(vector.X / scale.X, vector.Y / scale.Y);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
}
/// <summary>
@ -509,6 +514,54 @@ namespace OpenTK
result.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The distance</returns>
public static float Distance(Vector2 vec1, Vector2 vec2)
{
float result;
Distance(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The distance</param>
public static void Distance(ref Vector2 vec1, ref Vector2 vec2, out float result)
{
result = (float)Math.Sqrt((vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y));
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The squared distance</returns>
public static float DistanceSquared(Vector2 vec1, Vector2 vec2)
{
float result;
DistanceSquared(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The squared distance</param>
public static void DistanceSquared(ref Vector2 vec1, ref Vector2 vec2, out float result)
{
result = (vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y);
}
/// <summary>
/// Scale a vector to unit length
/// </summary>
@ -692,7 +745,8 @@ namespace OpenTK
Quaternion.Multiply(ref quat, ref v, out t);
Quaternion.Multiply(ref t, ref i, out v);
result = new Vector2(v.X, v.Y);
result.X = v.X;
result.Y = v.Y;
}
/// <summary>

View file

@ -202,7 +202,8 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector2d a, ref Vector2d b, out Vector2d result)
{
result = new Vector2d(a.X + b.X, a.Y + b.Y);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
}
/// <summary>
@ -225,7 +226,8 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector2d a, ref Vector2d b, out Vector2d result)
{
result = new Vector2d(a.X - b.X, a.Y - b.Y);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
}
/// <summary>
@ -248,7 +250,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector2d vector, double scale, out Vector2d result)
{
result = new Vector2d(vector.X * scale, vector.Y * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
}
/// <summary>
@ -271,7 +274,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector2d vector, ref Vector2d scale, out Vector2d result)
{
result = new Vector2d(vector.X * scale.X, vector.Y * scale.Y);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
}
/// <summary>
@ -318,7 +322,8 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector2d vector, ref Vector2d scale, out Vector2d result)
{
result = new Vector2d(vector.X / scale.X, vector.Y / scale.Y);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
}
/// <summary>
@ -502,6 +507,54 @@ namespace OpenTK
result.Y = vec.Y < min.Y ? min.Y : vec.Y > max.Y ? max.Y : vec.Y;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The distance</returns>
public static double Distance(Vector2d vec1, Vector2d vec2)
{
double result;
Distance(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The distance</param>
public static void Distance(ref Vector2d vec1, ref Vector2d vec2, out double result)
{
result = Math.Sqrt((vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y));
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The squared distance</returns>
public static double DistanceSquared(Vector2d vec1, Vector2d vec2)
{
double result;
DistanceSquared(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The squared distance</param>
public static void DistanceSquared(ref Vector2d vec1, ref Vector2d vec2, out double result)
{
result = (vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y);
}
/// <summary>
/// Scale a vector to unit length
/// </summary>
@ -663,7 +716,8 @@ namespace OpenTK
Quaterniond.Multiply(ref quat, ref v, out t);
Quaterniond.Multiply(ref t, ref i, out v);
result = new Vector2d(v.X, v.Y);
result.X = v.X;
result.Y = v.Y;
}
/// <summary>

View file

@ -315,10 +315,9 @@ namespace OpenTK
/// <returns>A new Half2 instance.</returns>
public static Vector2h FromBytes(byte[] value, int startIndex)
{
Vector2h h2 = new Vector2h();
h2.X = Half.FromBytes(value, startIndex);
h2.Y = Half.FromBytes(value, startIndex + 2);
return h2;
return new Vector2h(
Half.FromBytes(value, startIndex),
Half.FromBytes(value, startIndex + 2));
}
}
}

View file

@ -237,7 +237,7 @@ namespace OpenTK
public static readonly Vector3 UnitY = new Vector3(0, 1, 0);
/// <summary>
/// /// Defines a unit-length Vector3 that points towards the Z-axis.
/// Defines a unit-length Vector3 that points towards the Z-axis.
/// </summary>
public static readonly Vector3 UnitZ = new Vector3(0, 0, 1);
@ -276,7 +276,9 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector3 a, ref Vector3 b, out Vector3 result)
{
result = new Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
result.Z = a.Z + b.Z;
}
/// <summary>
@ -299,7 +301,9 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector3 a, ref Vector3 b, out Vector3 result)
{
result = new Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
result.Z = a.Z - b.Z;
}
/// <summary>
@ -322,7 +326,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector3 vector, float scale, out Vector3 result)
{
result = new Vector3(vector.X * scale, vector.Y * scale, vector.Z * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
result.Z = vector.Z * scale;
}
/// <summary>
@ -345,7 +351,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector3 vector, ref Vector3 scale, out Vector3 result)
{
result = new Vector3(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
result.Z = vector.Z * scale.Z;
}
/// <summary>
@ -393,7 +401,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector3 vector, ref Vector3 scale, out Vector3 result)
{
result = new Vector3(vector.X / scale.X, vector.Y / scale.Y, vector.Z / scale.Z);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
result.Z = vector.Z / scale.Z;
}
/// <summary>
@ -553,6 +563,54 @@ namespace OpenTK
result.Z = vec.Z < min.Z ? min.Z : vec.Z > max.Z ? max.Z : vec.Z;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The distance</returns>
public static float Distance(Vector3 vec1, Vector3 vec2)
{
float result;
Distance(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The distance</param>
public static void Distance(ref Vector3 vec1, ref Vector3 vec2, out float result)
{
result = (float)Math.Sqrt((vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y) + (vec2.Z - vec1.Z) * (vec2.Z - vec1.Z));
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The squared distance</returns>
public static float DistanceSquared(Vector3 vec1, Vector3 vec2)
{
float result;
DistanceSquared(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The squared distance</param>
public static void DistanceSquared(ref Vector3 vec1, ref Vector3 vec2, out float result)
{
result = (vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y) + (vec2.Z - vec1.Z) * (vec2.Z - vec1.Z);
}
/// <summary>
/// Scale a vector to unit length
/// </summary>
@ -645,15 +703,20 @@ namespace OpenTK
/// <summary>
/// Caclulate the cross (vector) product of two vectors
/// </summary>
/// <remarks>
/// It is incorrect to call this method passing the same variable for
/// <paramref name="result"/> as for <paramref name="left"/> or
/// <paramref name="right"/>.
/// </remarks>
/// <param name="left">First operand</param>
/// <param name="right">Second operand</param>
/// <returns>The cross product of the two inputs</returns>
/// <param name="result">The cross product of the two inputs</param>
public static void Cross(ref Vector3 left, ref Vector3 right, out Vector3 result)
{
result = new Vector3(left.Y * right.Z - left.Z * right.Y,
left.Z * right.X - left.X * right.Z,
left.X * right.Y - left.Y * right.X);
result.X = left.Y * right.Z - left.Z * right.Y;
result.Y = left.Z * right.X - left.X * right.Z;
result.Z = left.X * right.Y - left.Y * right.X;
}
/// <summary>
@ -729,16 +792,18 @@ namespace OpenTK
/// <returns>The transformed vector</returns>
public static Vector3 TransformVector(Vector3 vec, Matrix4 mat)
{
Vector3 v;
v.X = Vector3.Dot(vec, new Vector3(mat.Column0));
v.Y = Vector3.Dot(vec, new Vector3(mat.Column1));
v.Z = Vector3.Dot(vec, new Vector3(mat.Column2));
return v;
Vector3 result;
TransformVector(ref vec, ref mat, out result);
return result;
}
/// <summary>Transform a direction vector by the given Matrix
/// Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
/// </summary>
/// <remarks>
/// It is incorrect to call this method passing the same variable for
/// <paramref name="result"/> as for <paramref name="vec"/>.
/// </remarks>
/// <param name="vec">The vector to transform</param>
/// <param name="mat">The desired transformation</param>
/// <param name="result">The transformed vector</param>
@ -767,8 +832,9 @@ namespace OpenTK
/// <returns>The transformed normal</returns>
public static Vector3 TransformNormal(Vector3 norm, Matrix4 mat)
{
mat.Invert();
return TransformNormalInverse(norm, mat);
Vector3 result;
TransformNormal(ref norm, ref mat, out result);
return result;
}
/// <summary>Transform a Normal by the given Matrix</summary>
@ -795,11 +861,9 @@ namespace OpenTK
/// <returns>The transformed normal</returns>
public static Vector3 TransformNormalInverse(Vector3 norm, Matrix4 invMat)
{
Vector3 n;
n.X = Vector3.Dot(norm, new Vector3(invMat.Row0));
n.Y = Vector3.Dot(norm, new Vector3(invMat.Row1));
n.Z = Vector3.Dot(norm, new Vector3(invMat.Row2));
return n;
Vector3 result;
TransformNormalInverse(ref norm, ref invMat, out result);
return result;
}
/// <summary>Transform a Normal by the (transpose of the) given Matrix</summary>
@ -831,11 +895,9 @@ namespace OpenTK
/// <returns>The transformed position</returns>
public static Vector3 TransformPosition(Vector3 pos, Matrix4 mat)
{
Vector3 p;
p.X = Vector3.Dot(pos, new Vector3(mat.Column0)) + mat.Row3.X;
p.Y = Vector3.Dot(pos, new Vector3(mat.Column1)) + mat.Row3.Y;
p.Z = Vector3.Dot(pos, new Vector3(mat.Column2)) + mat.Row3.Z;
return p;
Vector3 result;
TransformPosition(ref pos, ref mat, out result);
return result;
}
/// <summary>Transform a Position by the given Matrix</summary>
@ -877,10 +939,9 @@ namespace OpenTK
/// <param name="result">The transformed vector</param>
public static void Transform(ref Vector3 vec, ref Matrix3 mat, out Vector3 result)
{
result = new Vector3(
vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X,
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y,
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z);
result.X = vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X;
result.Y = vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y;
result.Z = vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z;
}
/// <summary>
@ -931,10 +992,9 @@ namespace OpenTK
/// <param name="result">The transformed vector</param>
public static void Transform(ref Matrix3 mat, ref Vector3 vec, out Vector3 result)
{
result = new Vector3(
mat.Row0.X * vec.X + mat.Row0.Y * vec.Y + mat.Row0.Z * vec.Z,
mat.Row1.X * vec.X + mat.Row1.Y * vec.Y + mat.Row1.Z * vec.Z,
mat.Row2.X * vec.X + mat.Row2.Y * vec.Y + mat.Row2.Z * vec.Z);
result.X = mat.Row0.X * vec.X + mat.Row0.Y * vec.Y + mat.Row0.Z * vec.Z;
result.Y = mat.Row1.X * vec.X + mat.Row1.Y * vec.Y + mat.Row1.Z * vec.Z;
result.Z = mat.Row2.X * vec.X + mat.Row2.Y * vec.Y + mat.Row2.Z * vec.Z;
}
/// <summary>Transform a Vector3 by the given Matrix, and project the resulting Vector4 back to a Vector3</summary>
@ -954,7 +1014,7 @@ namespace OpenTK
/// <param name="result">The transformed vector</param>
public static void TransformPerspective(ref Vector3 vec, ref Matrix4 mat, out Vector3 result)
{
Vector4 v = new Vector4(vec, 1);
Vector4 v = new Vector4(vec.X, vec.Y, vec.Z, 1);
Vector4.Transform(ref v, ref mat, out v);
result.X = v.X / v.W;
result.Y = v.Y / v.W;

View file

@ -235,7 +235,7 @@ namespace OpenTK
public static readonly Vector3d UnitY = new Vector3d(0, 1, 0);
/// <summary>
/// /// Defines a unit-length Vector3d that points towards the Z-axis.
/// Defines a unit-length Vector3d that points towards the Z-axis.
/// </summary>
public static readonly Vector3d UnitZ = new Vector3d(0, 0, 1);
@ -274,7 +274,9 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector3d a, ref Vector3d b, out Vector3d result)
{
result = new Vector3d(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
result.Z = a.Z + b.Z;
}
/// <summary>
@ -297,7 +299,9 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector3d a, ref Vector3d b, out Vector3d result)
{
result = new Vector3d(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
result.Z = a.Z - b.Z;
}
/// <summary>
@ -320,7 +324,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector3d vector, double scale, out Vector3d result)
{
result = new Vector3d(vector.X * scale, vector.Y * scale, vector.Z * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
result.Z = vector.Z * scale;
}
/// <summary>
@ -343,7 +349,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector3d vector, ref Vector3d scale, out Vector3d result)
{
result = new Vector3d(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
result.Z = vector.Z * scale.Z;
}
/// <summary>
@ -391,7 +399,9 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector3d vector, ref Vector3d scale, out Vector3d result)
{
result = new Vector3d(vector.X / scale.X, vector.Y / scale.Y, vector.Z / scale.Z);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
result.Z = vector.Z / scale.Z;
}
/// <summary>
@ -547,6 +557,54 @@ namespace OpenTK
result.Z = vec.Z < min.Z ? min.Z : vec.Z > max.Z ? max.Z : vec.Z;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The distance</returns>
public static double Distance(Vector3d vec1, Vector3d vec2)
{
double result;
Distance(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The distance</param>
public static void Distance(ref Vector3d vec1, ref Vector3d vec2, out double result)
{
result = Math.Sqrt((vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y) + (vec2.Z - vec1.Z) * (vec2.Z - vec1.Z));
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <returns>The squared distance</returns>
public static double DistanceSquared(Vector3d vec1, Vector3d vec2)
{
double result;
DistanceSquared(ref vec1, ref vec2, out result);
return result;
}
/// <summary>
/// Compute the squared euclidean distance between two vectors.
/// </summary>
/// <param name="vec1">The first vector</param>
/// <param name="vec2">The second vector</param>
/// <param name="result">The squared distance</param>
public static void DistanceSquared(ref Vector3d vec1, ref Vector3d vec2, out double result)
{
result = (vec2.X - vec1.X) * (vec2.X - vec1.X) + (vec2.Y - vec1.Y) * (vec2.Y - vec1.Y) + (vec2.Z - vec1.Z) * (vec2.Z - vec1.Z);
}
/// <summary>
/// Scale a vector to unit length
/// </summary>
@ -639,15 +697,20 @@ namespace OpenTK
/// <summary>
/// Caclulate the cross (vector) product of two vectors
/// </summary>
/// <remarks>
/// It is incorrect to call this method passing the same variable for
/// <paramref name="result"/> as for <paramref name="left"/> or
/// <paramref name="right"/>.
/// </remarks>
/// <param name="left">First operand</param>
/// <param name="right">Second operand</param>
/// <returns>The cross product of the two inputs</returns>
/// <param name="result">The cross product of the two inputs</param>
public static void Cross(ref Vector3d left, ref Vector3d right, out Vector3d result)
{
result = new Vector3d(left.Y * right.Z - left.Z * right.Y,
left.Z * right.X - left.X * right.Z,
left.X * right.Y - left.Y * right.X);
result.X = left.Y * right.Z - left.Z * right.Y;
result.Y = left.Z * right.X - left.X * right.Z;
result.Z = left.X * right.Y - left.Y * right.X;
}
/// <summary>
@ -723,15 +786,18 @@ namespace OpenTK
/// <returns>The transformed vector</returns>
public static Vector3d TransformVector(Vector3d vec, Matrix4d mat)
{
return new Vector3d(
Vector3d.Dot(vec, new Vector3d(mat.Column0)),
Vector3d.Dot(vec, new Vector3d(mat.Column1)),
Vector3d.Dot(vec, new Vector3d(mat.Column2)));
Vector3d result;
TransformVector(ref vec, ref mat, out result);
return result;
}
/// <summary>Transform a direction vector by the given Matrix
/// Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
/// </summary>
/// <remarks>
/// It is incorrect to call this method passing the same variable for
/// <paramref name="result"/> as for <paramref name="vec"/>.
/// </remarks>
/// <param name="vec">The vector to transform</param>
/// <param name="mat">The desired transformation</param>
/// <param name="result">The transformed vector</param>
@ -788,10 +854,9 @@ namespace OpenTK
/// <returns>The transformed normal</returns>
public static Vector3d TransformNormalInverse(Vector3d norm, Matrix4d invMat)
{
return new Vector3d(
Vector3d.Dot(norm, new Vector3d(invMat.Row0)),
Vector3d.Dot(norm, new Vector3d(invMat.Row1)),
Vector3d.Dot(norm, new Vector3d(invMat.Row2)));
Vector3d result;
TransformNormalInverse(ref norm, ref invMat, out result);
return result;
}
/// <summary>Transform a Normal by the (transpose of the) given Matrix</summary>
@ -823,10 +888,9 @@ namespace OpenTK
/// <returns>The transformed position</returns>
public static Vector3d TransformPosition(Vector3d pos, Matrix4d mat)
{
return new Vector3d(
Vector3d.Dot(pos, new Vector3d(mat.Column0)) + mat.Row3.X,
Vector3d.Dot(pos, new Vector3d(mat.Column1)) + mat.Row3.Y,
Vector3d.Dot(pos, new Vector3d(mat.Column2)) + mat.Row3.Z);
Vector3d result;
TransformPosition(ref pos, ref mat, out result);
return result;
}
/// <summary>Transform a Position by the given Matrix</summary>
@ -863,6 +927,11 @@ namespace OpenTK
}
/// <summary>Transform a Vector by the given Matrix</summary>
/// <remarks>
/// It is incorrect to call this method passing the same variable for
/// <paramref name="result"/> as for <paramref name="left"/> or
/// <paramref name="right"/>.
/// </remarks>
/// <param name="vec">The vector to transform</param>
/// <param name="mat">The desired transformation</param>
/// <param name="result">The transformed vector</param>
@ -870,7 +939,9 @@ namespace OpenTK
{
Vector4d v4 = new Vector4d(vec.X, vec.Y, vec.Z, 1.0);
Vector4d.Transform(ref v4, ref mat, out v4);
result = v4.Xyz;
result.X = v4.X;
result.Y = v4.Y;
result.Z = v4.Z;
}
/// <summary>
@ -924,7 +995,7 @@ namespace OpenTK
/// <param name="result">The transformed vector</param>
public static void TransformPerspective(ref Vector3d vec, ref Matrix4d mat, out Vector3d result)
{
Vector4d v = new Vector4d(vec, 1);
Vector4d v = new Vector4d(vec.X, vec.Y, vec.Z, 1);
Vector4d.Transform(ref v, ref mat, out v);
result.X = v.X / v.W;
result.Y = v.Y / v.W;

View file

@ -310,11 +310,10 @@ namespace OpenTK
/// <returns>The resulting Vector3.</returns>
public static explicit operator Vector3(Vector3h h3)
{
Vector3 result = new Vector3();
result.X = h3.X.ToSingle();
result.Y = h3.Y.ToSingle();
result.Z = h3.Z.ToSingle();
return result;
return new Vector3(
h3.X.ToSingle(),
h3.Y.ToSingle(),
h3.Z.ToSingle());
}
/// <summary>Converts OpenTK.Half3 to OpenTK.Vector3d.</summary>
@ -322,11 +321,10 @@ namespace OpenTK
/// <returns>The resulting Vector3d.</returns>
public static explicit operator Vector3d(Vector3h h3)
{
Vector3d result = new Vector3d();
result.X = h3.X.ToSingle();
result.Y = h3.Y.ToSingle();
result.Z = h3.Z.ToSingle();
return result;
return new Vector3d(
h3.X.ToSingle(),
h3.Y.ToSingle(),
h3.Z.ToSingle());
}
/// <summary>The size in bytes for an instance of the Half3 struct is 6.</summary>
@ -411,11 +409,10 @@ namespace OpenTK
/// <returns>A new Half3 instance.</returns>
public static Vector3h FromBytes(byte[] value, int startIndex)
{
Vector3h h3 = new Vector3h();
h3.X = Half.FromBytes(value, startIndex);
h3.Y = Half.FromBytes(value, startIndex + 2);
h3.Z = Half.FromBytes(value, startIndex + 4);
return h3;
return new Vector3h(
Half.FromBytes(value, startIndex),
Half.FromBytes(value, startIndex + 2),
Half.FromBytes(value, startIndex + 4));
}
}
}

View file

@ -314,7 +314,10 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector4 a, ref Vector4 b, out Vector4 result)
{
result = new Vector4(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
result.Z = a.Z + b.Z;
result.W = a.W + b.W;
}
/// <summary>
@ -337,7 +340,10 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector4 a, ref Vector4 b, out Vector4 result)
{
result = new Vector4(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
result.Z = a.Z - b.Z;
result.W = a.W - b.W;
}
/// <summary>
@ -360,7 +366,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector4 vector, float scale, out Vector4 result)
{
result = new Vector4(vector.X * scale, vector.Y * scale, vector.Z * scale, vector.W * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
result.Z = vector.Z * scale;
result.W = vector.W * scale;
}
/// <summary>
@ -383,7 +392,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector4 vector, ref Vector4 scale, out Vector4 result)
{
result = new Vector4(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z, vector.W * scale.W);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
result.Z = vector.Z * scale.Z;
result.W = vector.W * scale.W;
}
/// <summary>
@ -432,7 +444,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector4 vector, ref Vector4 scale, out Vector4 result)
{
result = new Vector4(vector.X / scale.X, vector.Y / scale.Y, vector.Z / scale.Z, vector.W / scale.W);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
result.Z = vector.Z / scale.Z;
result.W = vector.W / scale.W;
}
/// <summary>
@ -833,7 +848,10 @@ namespace OpenTK
Quaternion.Multiply(ref quat, ref v, out t);
Quaternion.Multiply(ref t, ref i, out v);
result = new Vector4(v.X, v.Y, v.Z, v.W);
result.X = v.X;
result.Y = v.Y;
result.Z = v.Z;
result.W = v.W;
}
/// <summary>Transform a Vector by the given Matrix using right-handed notation</summary>

View file

@ -310,7 +310,10 @@ namespace OpenTK
/// <param name="result">Result of operation.</param>
public static void Add(ref Vector4d a, ref Vector4d b, out Vector4d result)
{
result = new Vector4d(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
result.Z = a.Z + b.Z;
result.W = a.W + b.W;
}
/// <summary>
@ -333,7 +336,10 @@ namespace OpenTK
/// <param name="result">Result of subtraction</param>
public static void Subtract(ref Vector4d a, ref Vector4d b, out Vector4d result)
{
result = new Vector4d(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
result.Z = a.Z - b.Z;
result.W = a.W - b.W;
}
/// <summary>
@ -356,7 +362,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector4d vector, double scale, out Vector4d result)
{
result = new Vector4d(vector.X * scale, vector.Y * scale, vector.Z * scale, vector.W * scale);
result.X = vector.X * scale;
result.Y = vector.Y * scale;
result.Z = vector.Z * scale;
result.W = vector.W * scale;
}
/// <summary>
@ -379,7 +388,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Multiply(ref Vector4d vector, ref Vector4d scale, out Vector4d result)
{
result = new Vector4d(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z, vector.W * scale.W);
result.X = vector.X * scale.X;
result.Y = vector.Y * scale.Y;
result.Z = vector.Z * scale.Z;
result.W = vector.W * scale.W;
}
/// <summary>
@ -428,7 +440,10 @@ namespace OpenTK
/// <param name="result">Result of the operation.</param>
public static void Divide(ref Vector4d vector, ref Vector4d scale, out Vector4d result)
{
result = new Vector4d(vector.X / scale.X, vector.Y / scale.Y, vector.Z / scale.Z, vector.W / scale.W);
result.X = vector.X / scale.X;
result.Y = vector.Y / scale.Y;
result.Z = vector.Z / scale.Z;
result.W = vector.W / scale.W;
}
/// <summary>
@ -825,7 +840,10 @@ namespace OpenTK
Quaterniond.Multiply(ref quat, ref v, out t);
Quaterniond.Multiply(ref t, ref i, out v);
result = new Vector4d(v.X, v.Y, v.Z, v.W);
result.X = v.X;
result.Y = v.Y;
result.Z = v.Z;
result.W = v.W;
}
/// <summary>

View file

@ -640,12 +640,11 @@ namespace OpenTK
/// <returns>The resulting Vector4.</returns>
public static explicit operator Vector4(Vector4h h4)
{
Vector4 result = new Vector4();
result.X = h4.X.ToSingle();
result.Y = h4.Y.ToSingle();
result.Z = h4.Z.ToSingle();
result.W = h4.W.ToSingle();
return result;
return new Vector4(
h4.X.ToSingle(),
h4.Y.ToSingle(),
h4.Z.ToSingle(),
h4.W.ToSingle());
}
/// <summary>Converts OpenTK.Half4 to OpenTK.Vector4d.</summary>
@ -653,12 +652,11 @@ namespace OpenTK
/// <returns>The resulting Vector4d.</returns>
public static explicit operator Vector4d(Vector4h h4)
{
Vector4d result = new Vector4d();
result.X = h4.X.ToSingle();
result.Y = h4.Y.ToSingle();
result.Z = h4.Z.ToSingle();
result.W = h4.W.ToSingle();
return result;
return new Vector4d(
h4.X.ToSingle(),
h4.Y.ToSingle(),
h4.Z.ToSingle(),
h4.W.ToSingle());
}
/// <summary>The size in bytes for an instance of the Half4 struct is 8.</summary>
@ -750,12 +748,11 @@ namespace OpenTK
/// <returns>A new Half4 instance.</returns>
public static Vector4h FromBytes(byte[] value, int startIndex)
{
Vector4h h4 = new Vector4h();
h4.X = Half.FromBytes(value, startIndex);
h4.Y = Half.FromBytes(value, startIndex + 2);
h4.Z = Half.FromBytes(value, startIndex + 4);
h4.W = Half.FromBytes(value, startIndex + 6);
return h4;
return new Vector4h(
Half.FromBytes(value, startIndex),
Half.FromBytes(value, startIndex + 2),
Half.FromBytes(value, startIndex + 4),
Half.FromBytes(value, startIndex + 6));
}
}
}

View file

@ -798,10 +798,18 @@
</PostBuildEvent>
</PropertyGroup>
<Target Name="AfterBuild">
<Exec Command="$(OutputPath)..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe $(OutputPath)OpenTK.dll ..\..\OpenTK.snk -debug" Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Debug'" />
<Exec Command="$(OutputPath)..\..\..\Generator.Rewrite\bin\Release\Rewrite.exe $(OutputPath)OpenTK.dll ..\..\OpenTK.snk" Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Release'" />
<Exec Command="mono $(OutputPath)../../../Generator.Rewrite/bin/Debug/Rewrite.exe $(OutputPath)OpenTK.dll ../../OpenTK.snk -debug" Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Debug'" />
<Exec Command="mono $(OutputPath)../../../Generator.Rewrite/bin/Release/Rewrite.exe $(OutputPath)OpenTK.dll ../../OpenTK.snk" Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Release'" />
<Exec
Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Debug'"
Command="$(OutputPath)..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk --debug" />
<Exec
Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Release'"
Command="$(OutputPath)..\..\..\Generator.Rewrite\bin\Release\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk" />
<Exec
Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Debug'"
Command="mono $(OutputPath)../../../Generator.Rewrite/bin/Debug/Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ../../OpenTK.snk --debug" />
<Exec
Condition="$(OS) != 'Windows_NT' and $(Configuration) == 'Release'"
Command="mono $(OutputPath)../../../Generator.Rewrite/bin/Release/Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ../../OpenTK.snk" />
</Target>
<ProjectExtensions>
<MonoDevelop>

View file

@ -25,6 +25,7 @@
// THE SOFTWARE.
//
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
@ -38,23 +39,70 @@ namespace OpenTK.Platform
// that is added.
internal class DeviceCollection<T> : IEnumerable<T>
{
internal struct Enumerator : IEnumerator<T>
{
private int Index;
private DeviceCollection<T> Collection;
internal Enumerator(DeviceCollection<T> collection)
{
Collection = collection;
Index = -1;
Current = default(T);
}
public T Current { get; private set; }
object IEnumerator.Current
{
get
{
return Current;
}
}
public void Dispose()
{
}
public bool MoveNext()
{
do
{
++Index;
if (Index < Collection.Devices.Count)
{
Current = Collection.Devices[Index];
}
} while (Index < Collection.Devices.Count && Collection.Devices[Index] == null);
return Index < Collection.Devices.Count;
}
public void Reset()
{
Index = -1;
Current = default(T);
}
}
private readonly Dictionary<long, int> Map = new Dictionary<long, int>();
private readonly List<T> Devices = new List<T>();
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return Devices.GetEnumerator();
return new Enumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
return new Enumerator(this);
}
// This avoids boxing when using foreach loops
public List<T>.Enumerator GetEnumerator()
public Enumerator GetEnumerator()
{
return Devices.GetEnumerator();
return new Enumerator(this);
}
public T this[int index]

View file

@ -182,7 +182,7 @@ namespace OpenTK.Platform
#if WIN32
if (Configuration.RunningOnWindows)
{
return Platform.Windows.Wgl.GetProcAddress;
return Platform.Windows.Wgl.GetAddress;
}
#endif
#if X11

View file

@ -106,28 +106,28 @@ namespace OpenTK.Platform.Windows
public static
IntPtr CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, int[] attribList)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetExtensionsStringARB")]
public static
string GetExtensionsString(IntPtr hdc)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribivARB")]
public static
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int[] piAttributes, [Out] int[] piValues)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribivARB")]
public static
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out int piValues)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribfvARB")]
@ -135,119 +135,119 @@ namespace OpenTK.Platform.Windows
public static
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, int nAttributes, int[] piAttributes, [Out] Single[] pfValues)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribfvARB")]
public static
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out Single pfValues)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglChoosePixelFormatARB")]
public static
Boolean ChoosePixelFormat(IntPtr hdc, int[] piAttribIList, Single[] pfAttribFList, Int32 nMaxFormats, [Out] int[] piFormats, out int nNumFormats)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglChoosePixelFormatARB")]
public static
Boolean ChoosePixelFormat(IntPtr hdc, ref int piAttribIList, ref Single pfAttribFList, Int32 nMaxFormats, [Out] out int piFormats, [Out] out Int32 nNumFormats)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglMakeContextCurrentARB")]
public static
Boolean MakeContextCurrent(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetCurrentReadDCARB")]
public static
IntPtr GetCurrentReadDC()
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglCreatePbufferARB")]
public static
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int[] piAttribList)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglCreatePbufferARB")]
public static
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, ref int piAttribList)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetPbufferDCARB")]
public static
IntPtr GetPbufferDC(IntPtr hPbuffer)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglReleasePbufferDCARB")]
public static
int ReleasePbufferDC(IntPtr hPbuffer, IntPtr hDC)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglDestroyPbufferARB")]
public static
Boolean DestroyPbuffer(IntPtr hPbuffer)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglQueryPbufferARB")]
public static
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] int[] piValue)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglQueryPbufferARB")]
public static
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] out int piValue)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglBindTexImageARB")]
public static
Boolean BindTexImage(IntPtr hPbuffer, int iBuffer)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglReleaseTexImageARB")]
public static
Boolean ReleaseTexImage(IntPtr hPbuffer, int iBuffer)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglSetPbufferAttribARB")]
public static
Boolean SetPbufferAttrib(IntPtr hPbuffer, int[] piAttribList)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglSetPbufferAttribARB")]
public static
Boolean SetPbufferAttrib(IntPtr hPbuffer, ref int piAttribList)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}
@ -257,21 +257,21 @@ namespace OpenTK.Platform.Windows
public static
string GetExtensionsString()
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglSwapIntervalEXT")]
public static
Boolean SwapInterval(int interval)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "wglGetSwapIntervalEXT")]
public static
int GetSwapInterval()
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}

View file

@ -94,7 +94,7 @@ namespace OpenTK.Platform.Windows
get { return sync; }
}
private IntPtr GetAddress(string function_string)
internal static IntPtr GetAddress(string function_string)
{
IntPtr address = Wgl.GetProcAddress(function_string);
if (!IsValid(address))

View file

@ -381,7 +381,8 @@ namespace OpenTK.Platform.Windows
}
if (dll == IntPtr.Zero)
{
throw new NotSupportedException("XInput was not found on this platform");
Debug.Print("XInput was not found on this platform");
return;
}
// Load the entry points we are interested in from that dll

View file

@ -416,13 +416,13 @@ namespace OpenTK.Platform.X11
[AutoGenerated(EntryPoint = "glXCreateContextAttribsARB")]
unsafe public static IntPtr CreateContextAttribs(IntPtr display, IntPtr fbconfig, IntPtr share_context, bool direct, int* attribs)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "glXCreateContextAttribsARB")]
public static IntPtr CreateContextAttribs(IntPtr display, IntPtr fbconfig, IntPtr share_context, bool direct, int[] attribs)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
// The linux OpenGL ABI 3.6 (1999) requires
@ -443,7 +443,7 @@ namespace OpenTK.Platform.X11
[AutoGenerated(EntryPoint = "glXSwapIntervalEXT")]
public static ErrorCode SwapInterval(IntPtr display, IntPtr drawable, int interval)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}
@ -452,13 +452,13 @@ namespace OpenTK.Platform.X11
[AutoGenerated(EntryPoint = "glXSwapIntervalMESA")]
public static ErrorCode SwapInterval(int interval)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
[AutoGenerated(EntryPoint = "glXGetSwapIntervalMESA")]
public static int GetSwapInterval()
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}
@ -467,7 +467,7 @@ namespace OpenTK.Platform.X11
[AutoGenerated(EntryPoint = "glXSwapIntervalSGI")]
public static ErrorCode SwapInterval(int interval)
{
throw new NotImplementedException();
throw new BindingsNotRewrittenException();
}
}

View file

@ -319,14 +319,12 @@ namespace OpenTK.Platform.X11
Handle, System.Threading.Thread.CurrentThread.ManagedThreadId, Display));
bool result;
using (new XLock(Display))
result = Glx.MakeCurrent(Display, IntPtr.Zero, IntPtr.Zero);
if (result)
{
result = Glx.MakeCurrent(Display, IntPtr.Zero, IntPtr.Zero);
if (result)
{
currentWindow = null;
}
currentWindow = null;
}
Debug.Print("{0}", result ? "done!" : "failed.");
}
else
@ -342,13 +340,10 @@ namespace OpenTK.Platform.X11
throw new InvalidOperationException("Invalid display, window or context.");
}
using (new XLock(Display))
result = Glx.MakeCurrent(Display, w.Handle, Handle);
if (result)
{
result = Glx.MakeCurrent(Display, w.Handle, Handle);
if (result)
{
currentWindow = w;
}
currentWindow = w;
}
if (!result)
@ -368,10 +363,7 @@ namespace OpenTK.Platform.X11
{
get
{
using (new XLock(Display))
{
return Glx.GetCurrentContext() == Handle.Handle;
}
return Glx.GetCurrentContext() == Handle.Handle;
}
}
@ -488,10 +480,7 @@ namespace OpenTK.Platform.X11
if (IsCurrent)
{
using (new XLock(display))
{
Glx.MakeCurrent(display, IntPtr.Zero, IntPtr.Zero);
}
Glx.MakeCurrent(display, IntPtr.Zero, IntPtr.Zero);
}
using (new XLock(display))
{

View file

@ -1,6 +1,7 @@
// <auto-generated/>
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitleAttribute("OpenTK")]
[assembly: AssemblyProductAttribute("OpenTK")]
@ -9,6 +10,7 @@ using System.Reflection;
[assembly: AssemblyFileVersionAttribute("3.0.0")]
[assembly: CLSCompliantAttribute(true)]
[assembly: AssemblyCopyrightAttribute("Copyright (c) 2006 - 2016 Stefanos Apostolopoulos <stapostol@gmail.com> for the Open Toolkit library.")]
[assembly: InternalsVisibleToAttribute("OpenTK.GLWidget, PublicKey=0024000004800000940000000602000000240000525341310004000011000000a3e05aafb87f71fb8fd02b512707f289c12341de98c6ce2ec1494b71c20cb2032cbd65d091b447df3ec772257efb9fa3591201937890e067da1d29a339948a12b29c2847a787cc9fbef2a3bf78267026e85f36aab827228df4bb580e3ae0599ade036f0a97a0e6982f5406d98d114455f332350f6d8369db655e9c3e7976c2c8")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "OpenTK";
@ -18,5 +20,6 @@ namespace System {
internal const System.String AssemblyFileVersion = "3.0.0";
internal const System.Boolean CLSCompliant = true;
internal const System.String AssemblyCopyright = "Copyright (c) 2006 - 2016 Stefanos Apostolopoulos <stapostol@gmail.com> for the Open Toolkit library.";
internal const System.String InternalsVisibleTo = "OpenTK.GLWidget, PublicKey=0024000004800000940000000602000000240000525341310004000011000000a3e05aafb87f71fb8fd02b512707f289c12341de98c6ce2ec1494b71c20cb2032cbd65d091b447df3ec772257efb9fa3591201937890e067da1d29a339948a12b29c2847a787cc9fbef2a3bf78267026e85f36aab827228df4bb580e3ae0599ade036f0a97a0e6982f5406d98d114455f332350f6d8369db655e9c3e7976c2c8";
}
}

View file

@ -16,7 +16,7 @@ module private AssertHelpers =
let approxEq a b = MathHelper.ApproximatelyEquivalent(a, b, EquivalenceTolerance)
let approxEqDelta a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy)
let approxEqDelta a b = MathHelper.ApproximatelyEqual(a, b, BitAccuracy)
let approxEqSingleEpsilon a b = MathHelper.ApproximatelyEqualEpsilon(a, b, 0.00001f)
let approxEqDoubleEpsilon a b = MathHelper.ApproximatelyEqualEpsilon(a, b, 0.00001)
@ -74,3 +74,6 @@ type internal Assert =
if approxEqDoubleEpsilonWithError(a, b, c) then raise <| new Xunit.Sdk.EqualException(a,b)
static member ThrowsIndexExn(f:unit -> unit) = Assert.Throws<IndexOutOfRangeException>(f) |> ignore
static member ApproximatelyEqual(a : float32, b : float32) =
if not <| approxEqDelta a b then raise <| new Xunit.Sdk.EqualException(a, b)

View file

@ -0,0 +1,40 @@
namespace OpenTK.Tests
open Xunit
open FsCheck
open FsCheck.Xunit
open System
open System.Runtime.InteropServices
open OpenTK
module Half =
[<Fact>]
let ``Casting Half to Single and back to Half is lossless`` () =
for bits = int System.Int16.MinValue to int System.Int16.MaxValue do
let bytes = System.BitConverter.GetBytes(int16 bits)
let half = Half.FromBytes(bytes, 0)
let single = float32 half
let roundtrip = Half single
Assert.True((half.IsNaN && roundtrip.IsNaN) || half = roundtrip)
[<Fact>]
let ``Half.ToString and Single.ToString return same string for same value`` () =
for bits = int System.Int16.MinValue to int System.Int16.MaxValue do
let bytes = System.BitConverter.GetBytes(int16 bits)
let half = Half.FromBytes(bytes, 0)
let single = float32 half
Assert.Equal(half.ToString(), single.ToString())
[<Fact>]
let ``Half can represent all integers from -2048 to 2048 exactly`` () =
for i = -2048 to 2048 do
let single = float32 i
let half = Half single
Assert.Equal(single, float32 half)
[<Fact>]
let ``Single NaN and inifnity can be cast to Half NaN and infinity`` () =
Assert.True((Half System.Single.NaN).IsNaN)
Assert.True((Half System.Single.PositiveInfinity).IsPositiveInfinity)
Assert.True((Half System.Single.NegativeInfinity).IsNegativeInfinity)

View file

@ -69,6 +69,7 @@
<Compile Include="Vector2Tests.fs" />
<Compile Include="Vector3Tests.fs" />
<Compile Include="Vector4Tests.fs" />
<Compile Include="HalfTests.fs" />
<Content Include="App.config" />
<None Include="paket.references" />
</ItemGroup>

View file

@ -75,6 +75,16 @@ module Vector2 =
Assert.Equal(lsq, v.LengthSquared)
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Distance =
[<Property>]
let ``Distance(a, b) = (b - a).Length`` (a : Vector2, b : Vector2) =
Assert.ApproximatelyEqual(Vector2.Distance(a, b), (b - a).Length)
[<Property>]
let ``DistanceSquared(a, b) = (b - a).LengthSquared`` (a : Vector2, b : Vector2) =
Assert.ApproximatelyEqual(Vector2.DistanceSquared(a, b), (b - a).LengthSquared)
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Unit vectors and perpendicularity`` =
//

View file

@ -124,6 +124,16 @@ module Vector3 =
Assert.Equal(lsq, v.LengthSquared)
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Distance =
[<Property>]
let ``Distance(a, b) = (b - a).Length`` (a : Vector3, b : Vector3) =
Assert.ApproximatelyEqual(Vector3.Distance(a, b), (b - a).Length)
[<Property>]
let ``DistanceSquared(a, b) = (b - a).LengthSquared`` (a : Vector3, b : Vector3) =
Assert.ApproximatelyEqual(Vector3.DistanceSquared(a, b), (b - a).LengthSquared)
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Normalization =
//

View file

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Test.API.Desktop</RootNamespace>
<AssemblyName>Test.API.Desktop</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\Binaries\Tests\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\Binaries\Tests\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\src\OpenTK\OpenTK.csproj">
<Project>{A37A7E14-0000-0000-0000-000000000000}</Project>
<Name>OpenTK</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="api.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Drawing" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load diff