diff --git a/build.fsx b/build.fsx index d6bec54e..639b13af 100644 --- a/build.fsx +++ b/build.fsx @@ -42,7 +42,7 @@ let tags = "OpenTK OpenGL OpenGLES GLES OpenAL C# F# VB .NET Mono Vector Math Ga let copyright = "Copyright (c) 2006 - 2016 Stefanos Apostolopoulos for the Open Toolkit library." -// File system information +// File system information let solutionFile = "OpenTK.sln" // Pattern specifying assemblies to be tested using NUnit @@ -50,7 +50,7 @@ let testAssemblies = "tests/**/bin/Release/*Tests*.dll" // Git configuration (used for publishing documentation in gh-pages branch) // The profile where the project is posted -let gitOwner = "opentk" +let gitOwner = "opentk" let gitHome = "https://github.com/" + gitOwner // The name of the project on GitHub @@ -70,7 +70,7 @@ let isXamarinPlatform = false //EnvironmentHelper.isMacOS || Environment.OSVersi // Helper active pattern for project types -let (|Fsproj|Csproj|Vbproj|) (projFileName:string) = +let (|Fsproj|Csproj|Vbproj|) (projFileName:string) = match projFileName with | f when f.EndsWith "fsproj" -> Fsproj | f when f.EndsWith "csproj" -> Csproj @@ -78,24 +78,23 @@ let (|Fsproj|Csproj|Vbproj|) (projFileName:string) = | _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName) -let activeProjects = - let xamarinFilter f = +let activeProjects = + let xamarinFilter f = if isXamarinPlatform then f else f -- "**/OpenTK.Android.csproj" -- "**/OpenTK.iOS.csproj" - + !! "src/**/*.??proj" ++ "tests/**/OpenTK.Tests.fsproj" - -- "**/OpenTK.GLWidget.csproj" |> xamarinFilter // Generate assembly info files with the right version & up-to-date information Target "AssemblyInfo" (fun _ -> let getAssemblyInfoAttributes (projectName:string) = - let projectName = + let projectName = if projectName.Contains(".iOS") || projectName.Contains(".Android") then projectName.Split('.').[0] else @@ -110,7 +109,7 @@ Target "AssemblyInfo" (fun _ -> let getProjectDetails projectPath = let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath) - ( projectPath, + ( projectPath, projectName, System.IO.Path.GetDirectoryName(projectPath), (getAssemblyInfoAttributes projectName) @@ -127,7 +126,7 @@ Target "AssemblyInfo" (fun _ -> ) // Copies binaries from default VS location to expected bin folder -// But keeps a subdirectory structure for each project in the +// But keeps a subdirectory structure for each project in the // src folder to support multiple project outputs Target "CopyBinaries" (fun _ -> activeProjects @@ -175,7 +174,7 @@ Target "NuGet" (fun _ -> "OpenTK.iOS" ] - Paket.Pack(fun p -> + Paket.Pack(fun p -> { p with OutputPath = "bin" ExcludedTemplates = "OpenTK.GLWidget" :: xamExcludes @@ -198,7 +197,7 @@ Target "All" DoNothing ==> "RunTests" ==> "All" -"All" +"All" ==> "NuGet" diff --git a/paket.dependencies b/paket.dependencies index 04eab810..60e3514c 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -9,4 +9,4 @@ nuget xunit.runner.console nuget xunit.assert nuget FAKE nuget Mono.Cecil >= 0.10.0-beta1 -nuget GtkSharp +nuget gtk-sharp3 diff --git a/paket.lock b/paket.lock index cf9d232f..785d4061 100644 --- a/paket.lock +++ b/paket.lock @@ -1,6 +1,6 @@ NUGET remote: https://www.nuget.org/api/v2 - FAKE (4.61.2) + FAKE (4.61.3) FsCheck (2.9) FSharp.Core (>= 4.1) - framework: >= net10, netstandard10, netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 FSharp.Core (>= 4.1.17) - framework: >= netstandard16 @@ -13,39 +13,39 @@ NUGET xunit.core (>= 2.2) - framework: >= netstandard16 xunit.extensibility.execution (>= 2.2 < 3.0) - framework: >= net10, netstandard10, netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 FSharp.Compiler.Service (2.0.0.6) - FSharp.Core (4.1.17) - framework: >= net10, >= netstandard10 - System.Collections (>= 4.0.11) - framework: >= netstandard16 - System.Console (>= 4.0) - framework: >= netstandard16 - System.Diagnostics.Debug (>= 4.0.11) - framework: >= netstandard16 - System.Diagnostics.Tools (>= 4.0.1) - framework: >= netstandard16 - System.Globalization (>= 4.0.11) - framework: >= netstandard16 - System.IO (>= 4.1) - framework: >= netstandard16 - System.Linq (>= 4.1) - framework: >= netstandard16 - System.Linq.Expressions (>= 4.1) - framework: >= netstandard16 - System.Linq.Queryable (>= 4.0.1) - framework: >= netstandard16 - System.Net.Requests (>= 4.0.11) - framework: >= netstandard16 - System.Reflection (>= 4.1) - framework: >= netstandard16 - System.Reflection.Extensions (>= 4.0.1) - framework: >= netstandard16 - System.Resources.ResourceManager (>= 4.0.1) - framework: >= netstandard16 - System.Runtime (>= 4.1) - framework: >= netstandard16 - System.Runtime.Extensions (>= 4.1) - framework: >= netstandard16 - System.Runtime.Numerics (>= 4.0.1) - framework: >= netstandard16 - System.Text.RegularExpressions (>= 4.1) - framework: >= netstandard16 - System.Threading (>= 4.0.11) - framework: >= netstandard16 - System.Threading.Tasks (>= 4.0.11) - framework: >= netstandard16 - System.Threading.Tasks.Parallel (>= 4.0.1) - framework: >= netstandard16 - System.Threading.Thread (>= 4.0) - framework: >= netstandard16 - System.Threading.ThreadPool (>= 4.0.10) - framework: >= netstandard16 - System.Threading.Timer (>= 4.0.1) - framework: >= netstandard16 + FSharp.Core (4.2.1) - framework: >= net10, >= netstandard10 + System.Collections (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.Console (>= 4.0) - framework: >= net463, >= netstandard16 + System.Diagnostics.Debug (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.Diagnostics.Tools (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Globalization (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.IO (>= 4.1) - framework: >= net463, >= netstandard16 + System.Linq (>= 4.1) - framework: >= net463, >= netstandard16 + System.Linq.Expressions (>= 4.1) - framework: >= net463, >= netstandard16 + System.Linq.Queryable (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Net.Requests (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.Reflection (>= 4.1) - framework: >= net463, >= netstandard16 + System.Reflection.Extensions (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Resources.ResourceManager (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Runtime (>= 4.1) - framework: >= net463, >= netstandard16 + System.Runtime.Extensions (>= 4.1) - framework: >= net463, >= netstandard16 + System.Runtime.Numerics (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Text.RegularExpressions (>= 4.1) - framework: >= net463, >= netstandard16 + System.Threading (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.Threading.Tasks (>= 4.0.11) - framework: >= net463, >= netstandard16 + System.Threading.Tasks.Parallel (>= 4.0.1) - framework: >= net463, >= netstandard16 + System.Threading.Thread (>= 4.0) - framework: >= net463, >= netstandard16 + System.Threading.ThreadPool (>= 4.0.10) - framework: >= net463, >= netstandard16 + System.Threading.Timer (>= 4.0.1) - framework: >= net463, >= netstandard16 FSharp.Formatting (2.14.4) FSharp.Compiler.Service (2.0.0.6) FSharpVSPowerTools.Core (>= 2.3 < 2.4) FSharpVSPowerTools.Core (2.3) FSharp.Compiler.Service (>= 2.0.0.3) - GtkSharp (3.1.3) + gtk-sharp3 (3.22) Microsoft.NETCore.Platforms (1.1) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Targets (1.1) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 - Microsoft.Win32.Primitives (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + Microsoft.Win32.Primitives (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 Microsoft.NETCore.Targets (>= 1.1) - framework: >= netstandard13 System.Runtime (>= 4.3) - framework: >= netstandard13 @@ -103,21 +103,21 @@ NUGET System.Threading.Timer (>= 4.3) - framework: >= net451, >= netstandard12 System.Xml.ReaderWriter (>= 4.3) - framework: >= netstandard10 System.Xml.XDocument (>= 4.3) - framework: >= netstandard10 - runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.native.System (4.3) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.native.System (4.3) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) - runtime.native.System.IO.Compression (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + runtime.native.System.IO.Compression (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) - runtime.native.System.Net.Http (4.3) - framework: >= net10, >= netstandard16 + runtime.native.System.Net.Http (4.3) - framework: >= net45, >= netstandard16 Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) - runtime.native.System.Security.Cryptography.Apple (4.3) - framework: >= net10, >= netstandard16 + runtime.native.System.Security.Cryptography.Apple (4.3) - framework: >= net45, >= netstandard16 runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple (>= 4.3) - runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) @@ -128,17 +128,17 @@ NUGET runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.1) - runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple (4.3) - framework: >= net10, >= netstandard16 - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 - runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple (4.3) - framework: >= net45, >= netstandard16 + runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 + runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.1) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 System.AppContext (4.3) - framework: >= net46, >= netstandard13, netstandard14, netstandard15 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard13, >= netstandard16 - System.Buffers (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + System.Buffers (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 System.Diagnostics.Debug (>= 4.3) - framework: >= netstandard11 System.Diagnostics.Tracing (>= 4.3) - framework: >= netstandard11 System.Resources.ResourceManager (>= 4.3) - framework: >= netstandard11 @@ -148,7 +148,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Collections.Concurrent (4.3) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + System.Collections.Concurrent (4.3) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Diagnostics.Tracing (>= 4.3) - framework: dnxcore50, >= netstandard13 @@ -159,7 +159,7 @@ NUGET System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Threading.Tasks (>= 4.3) - framework: dnxcore50, netstandard11, >= netstandard13 - System.Console (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + System.Console (4.3) - framework: >= net46, >= netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 Microsoft.NETCore.Targets (>= 1.1) - framework: >= netstandard13 System.IO (>= 4.3) - framework: >= netstandard13 @@ -169,7 +169,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Diagnostics.DiagnosticSource (4.3.1) - framework: >= net10, netstandard13, >= netstandard16 + System.Diagnostics.DiagnosticSource (4.3.1) - framework: >= net45, netstandard13, >= netstandard16 System.Collections (>= 4.3) - framework: netstandard11, >= netstandard13 System.Diagnostics.Tracing (>= 4.3) - framework: netstandard11, >= netstandard13 System.Reflection (>= 4.3) - framework: netstandard11, >= netstandard13 @@ -179,7 +179,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard10 Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, >= netstandard10 System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard10 - System.Diagnostics.Tracing (4.3) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + System.Diagnostics.Tracing (4.3) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard11, netstandard12, netstandard13, >= netstandard15 Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard11, netstandard12, netstandard13, >= netstandard15 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard11, netstandard12, netstandard13, >= netstandard15 @@ -192,7 +192,7 @@ NUGET Microsoft.NETCore.Targets (>= 1.1) - framework: >= netstandard13 System.Globalization (>= 4.3) - framework: >= netstandard13 System.Runtime (>= 4.3) - framework: >= netstandard13 - System.Globalization.Extensions (4.3) - framework: >= net10, >= netstandard16 + System.Globalization.Extensions (4.3) - framework: >= net45, >= netstandard16 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 System.Globalization (>= 4.3) - framework: >= netstandard13 System.Resources.ResourceManager (>= 4.3) - framework: >= netstandard13 @@ -205,7 +205,7 @@ NUGET System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 System.Text.Encoding (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 System.Threading.Tasks (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.IO.Compression (4.3) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + System.IO.Compression (4.3) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 runtime.native.System (>= 4.3) - framework: >= netstandard13 runtime.native.System.IO.Compression (>= 4.3) - framework: dnxcore50, >= netstandard13 @@ -266,7 +266,7 @@ NUGET System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16 System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard16 System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard16 - System.Linq.Queryable (4.3) - framework: >= net10, >= netstandard16 + System.Linq.Queryable (4.3) - framework: >= net463, >= netstandard16 System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Linq (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 @@ -275,7 +275,7 @@ NUGET System.Reflection.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Net.Http (4.3.2) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + System.Net.Http (4.3.2) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard13, >= netstandard16 Microsoft.Win32.Primitives (>= 4.3) - framework: netstandard13 runtime.native.System (>= 4.3) - framework: >= netstandard16 @@ -309,7 +309,7 @@ NUGET Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, netstandard11, >= netstandard13 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard11, >= netstandard13 System.Runtime.Handles (>= 4.3) - framework: dnxcore50, >= netstandard13 - System.Net.Requests (4.3) - framework: >= net10, >= netstandard16 + System.Net.Requests (4.3) - framework: >= net463, >= netstandard16 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard13 @@ -330,7 +330,7 @@ NUGET System.Net.Primitives (>= 4.3) - framework: >= netstandard13 System.Runtime (>= 4.3) - framework: >= netstandard13 System.Threading.Tasks (>= 4.3) - framework: >= netstandard13 - System.Net.WebHeaderCollection (4.3) - framework: >= net10, >= netstandard16 + System.Net.WebHeaderCollection (4.3) - framework: >= net463, >= netstandard16 System.Collections (>= 4.3) - framework: >= netstandard13 System.Resources.ResourceManager (>= 4.3) - framework: >= netstandard13 System.Runtime (>= 4.3) - framework: >= netstandard13 @@ -406,12 +406,12 @@ NUGET System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard11 System.Runtime.InteropServices (>= 4.3) - framework: >= netstandard11 System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard11 - System.Runtime.Numerics (4.3) - framework: >= net10, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 + System.Runtime.Numerics (4.3) - framework: >= net45, >= netstandard11, netstandard12, netstandard13, netstandard14, netstandard15 System.Globalization (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Runtime (>= 4.3) - framework: dnxcore50, netstandard11, >= netstandard13 System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard13 - System.Security.Cryptography.Algorithms (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + System.Security.Cryptography.Algorithms (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard16 runtime.native.System.Security.Cryptography.Apple (>= 4.3) - framework: >= netstandard16 runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3) - framework: >= netstandard16 @@ -452,7 +452,7 @@ NUGET System.Security.Cryptography.Primitives (>= 4.3) - framework: >= net46, >= netstandard13 System.Text.Encoding (>= 4.3) - framework: >= netstandard13 System.Threading (>= 4.3) - framework: >= netstandard13 - System.Security.Cryptography.Encoding (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + System.Security.Cryptography.Encoding (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: >= netstandard13 runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3) - framework: >= netstandard13 System.Collections (>= 4.3) - framework: >= netstandard13 @@ -465,7 +465,7 @@ NUGET System.Runtime.InteropServices (>= 4.3) - framework: >= netstandard13 System.Security.Cryptography.Primitives (>= 4.3) - framework: >= netstandard13 System.Text.Encoding (>= 4.3) - framework: >= netstandard13 - System.Security.Cryptography.OpenSsl (4.3) - framework: >= net10, >= netstandard16 + System.Security.Cryptography.OpenSsl (4.3) - framework: >= net45, >= netstandard16 runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3) - framework: >= net463, >= netstandard16, monoandroid, monotouch, xamarinios, xamarinmac System.Collections (>= 4.3) - framework: >= netstandard16 System.IO (>= 4.3) - framework: >= net463, >= netstandard16 @@ -479,7 +479,7 @@ NUGET System.Security.Cryptography.Encoding (>= 4.3) - framework: >= net463, >= netstandard16 System.Security.Cryptography.Primitives (>= 4.3) - framework: >= net463, >= netstandard16 System.Text.Encoding (>= 4.3) - framework: >= netstandard16 - System.Security.Cryptography.Primitives (4.3) - framework: >= net10, >= netstandard13, netstandard14, netstandard15 + System.Security.Cryptography.Primitives (4.3) - framework: >= net45, >= netstandard13, netstandard14, netstandard15 System.Diagnostics.Debug (>= 4.3) - framework: >= netstandard13 System.Globalization (>= 4.3) - framework: >= netstandard13 System.IO (>= 4.3) - framework: >= netstandard13 @@ -540,7 +540,7 @@ NUGET System.Collections (>= 4.3) - framework: >= netstandard10 System.Runtime (>= 4.3) - framework: >= netstandard10 System.Threading.Tasks (>= 4.3) - framework: >= netstandard10 - System.Threading.Tasks.Parallel (4.3) - framework: >= net10, >= netstandard16 + System.Threading.Tasks.Parallel (4.3) - framework: >= net463, >= netstandard16 System.Collections.Concurrent (>= 4.3) - framework: dnxcore50, netstandard11, >= netstandard13 System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Diagnostics.Tracing (>= 4.3) - framework: dnxcore50, >= netstandard13 @@ -549,12 +549,12 @@ NUGET System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard13 System.Threading.Tasks (>= 4.3) - framework: dnxcore50, netstandard11, >= netstandard13 - System.Threading.Thread (4.3) - framework: >= net10, >= netstandard16 + System.Threading.Thread (4.3) - framework: >= net463, >= netstandard16 System.Runtime (>= 4.3) - framework: >= netstandard13 - System.Threading.ThreadPool (4.3) - framework: >= net10, >= netstandard16 + System.Threading.ThreadPool (4.3) - framework: >= net463, >= netstandard16 System.Runtime (>= 4.3) - framework: >= netstandard13 System.Runtime.Handles (>= 4.3) - framework: >= netstandard13 - System.Threading.Timer (4.3) - framework: >= net10, >= netstandard12, netstandard13, netstandard14, netstandard15 + System.Threading.Timer (4.3) - framework: >= net451, >= netstandard12, netstandard13, netstandard14, netstandard15 Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard12 Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, >= netstandard12 System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard12 diff --git a/src/OpenTK.GLWidget/GLWidget.cs b/src/OpenTK.GLWidget/GLWidget.cs index 92274a30..ccf48873 100644 --- a/src/OpenTK.GLWidget/GLWidget.cs +++ b/src/OpenTK.GLWidget/GLWidget.cs @@ -1,104 +1,100 @@ -#region License -// -// The Open Toolkit Library License -// -// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -#endregion - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Security; +using System; using System.Threading; using System.ComponentModel; using OpenTK.Graphics; using OpenTK.Platform; -using OpenTK; using Gtk; +using OpenTK.OSX; +using OpenTK.Win; +using OpenTK.X11; namespace OpenTK { + /// + /// The is a GTK widget for which an OpenGL context can be used to draw arbitrary graphics. + /// [ToolboxItem(true)] - public class GLWidget: DrawingArea, IDisposable + public class GLWidget: DrawingArea { #region Static attrs. - static int _GraphicsContextCount; - static bool _SharedContextInitialized = false; + private static int _GraphicsContextCount; + private static bool _SharedContextInitialized = false; #endregion #region Attributes - IGraphicsContext _GraphicsContext; - IWindowInfo _WindowInfo; - GraphicsContextFlags _GraphicsContextFlags; - bool _Initialized = false; + private IGraphicsContext _GraphicsContext; + private IWindowInfo _WindowInfo; + private GraphicsContextFlags _GraphicsContextFlags; + private bool _Initialized = false; #endregion #region Properties - /// Use a single buffer versus a double buffer. + /// + /// Use a single buffer versus a double buffer. + /// [Browsable(true)] public bool SingleBuffer { get; set; } - /// Color Buffer Bits-Per-Pixel + /// + /// Color Buffer Bits-Per-Pixel + /// public int ColorBPP { get; set; } - /// Accumulation Buffer Bits-Per-Pixel + /// + /// Accumulation Buffer Bits-Per-Pixel + /// public int AccumulatorBPP { get; set; } - /// Depth Buffer Bits-Per-Pixel + /// + /// Depth Buffer Bits-Per-Pixel + /// public int DepthBPP { get; set; } - /// Stencil Buffer Bits-Per-Pixel + /// + /// Stencil Buffer Bits-Per-Pixel + /// public int StencilBPP { get; set; } - /// Number of samples + /// + /// Number of samples + /// public int Samples { get; set; } - /// Indicates if steropic renderering is enabled + /// + /// Indicates if steropic renderering is enabled + /// public bool Stereo { get; set; } - /// The major version of OpenGL to use. + /// + /// The major version of OpenGL to use. + /// public int GlVersionMajor { get; set; } - /// The minor version of OpenGL to use. + /// + /// The minor version of OpenGL to use. + /// public int GlVersionMinor { get; set; } + /// + /// The set for this widget. + /// public GraphicsContextFlags GraphicsContextFlags { get - { - return _GraphicsContextFlags; + { + return _GraphicsContextFlags; } set - { - _GraphicsContextFlags = value; + { + _GraphicsContextFlags = value; } } @@ -106,19 +102,29 @@ namespace OpenTK #region Construction/Destruction - /// Constructs a new GLWidget. + /// + /// Initializes a new instance of the class. + /// public GLWidget() : this(GraphicsMode.Default) - { + { } /// Constructs a new GLWidget using a given GraphicsMode public GLWidget(GraphicsMode graphicsMode) : this(graphicsMode, 1, 0, GraphicsContextFlags.Default) - { + { } - /// Constructs a new GLWidget + /// + /// Initializes a new instance of the class. + /// + /// The which the widget should be constructed with. + /// The major OpenGL version to attempt to initialize. + /// The minor OpenGL version to attempt to initialize. + /// + /// Any flags which should be used during initialization of the . + /// public GLWidget(GraphicsMode graphicsMode, int glVersionMajor, int glVersionMinor, GraphicsContextFlags graphicsContextFlags) { this.DoubleBuffered = false; @@ -136,28 +142,55 @@ namespace OpenTK GraphicsContextFlags = graphicsContextFlags; } + /// + /// Destructs this object. + /// ~GLWidget() - { - Dispose(false); + { + Dispose(false); } -#if GTK3 - public override void Destroy() { -#else - public override void Dispose() + /// + /// Destroys this , disposing it and destroying it in the context of GTK. + /// + public override void Destroy() { -#endif GC.SuppressFinalize(this); Dispose(true); -#if GTK3 + base.Destroy(); -#else - base.Dispose(); -#endif } +#if !GTK3 + /// + /// Disposes the current object, releasing any native resources it was using. + /// + /// + public override void Dispose() + { + GC.SuppressFinalize(this); + Dispose(true); + + base.Dispose(); + } +#endif + +#if GTK3 + /// + /// Disposes the current object, releasing any native resources it was using. + /// + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); +#else + /// + /// Disposes the current object, releasing any native resources it was using. + /// + /// public virtual void Dispose(bool disposing) { +#endif if (disposing) { _GraphicsContext.MakeCurrent(_WindowInfo); @@ -175,60 +208,94 @@ namespace OpenTK #region New Events - // Called when the first GraphicsContext is created in the case of GraphicsContext.ShareContexts == True; + /// + /// Called when the first is created in the case where + /// GraphicsContext.ShareContexts == true; + /// public static event EventHandler GraphicsContextInitialized; - static void OnGraphicsContextInitialized() + /// + /// Invokes the event. + /// + private static void OnGraphicsContextInitialized() { if (GraphicsContextInitialized != null) - GraphicsContextInitialized(null, EventArgs.Empty); + GraphicsContextInitialized(null, EventArgs.Empty); } - // Called when the first GraphicsContext is being destroyed in the case of GraphicsContext.ShareContexts == True; + /// + /// Called when the first is being destroyed in the case where + /// GraphicsContext.ShareContext == true; + /// public static event EventHandler GraphicsContextShuttingDown; - static void OnGraphicsContextShuttingDown() - { + /// + /// Invokes the event. + /// + private static void OnGraphicsContextShuttingDown() + { if (GraphicsContextShuttingDown != null) - GraphicsContextShuttingDown(null, EventArgs.Empty); + GraphicsContextShuttingDown(null, EventArgs.Empty); } - // Called when this GLWidget has a valid GraphicsContext + /// + /// Called when this has finished initializing and has a valid + /// . + /// public event EventHandler Initialized; + /// + /// Invokes the event. + /// protected virtual void OnInitialized() - { + { if (Initialized != null) - Initialized(this, EventArgs.Empty); + Initialized(this, EventArgs.Empty); } - // Called when this GLWidget needs to render a frame + /// + /// Called when this needs to render a frame. + /// public event EventHandler RenderFrame; + /// + /// Invokes the event. + /// protected virtual void OnRenderFrame() - { + { if (RenderFrame != null) - RenderFrame(this, EventArgs.Empty); + RenderFrame(this, EventArgs.Empty); } - // Called when this GLWidget is being Disposed + /// + /// Called when this is being disposed. + /// public event EventHandler ShuttingDown; + /// + /// Invokes the event. + /// protected virtual void OnShuttingDown() - { + { if (ShuttingDown != null) - ShuttingDown(this, EventArgs.Empty); + ShuttingDown(this, EventArgs.Empty); } #endregion - // Called when a widget is realized. (window handles and such are valid) - // protected override void OnRealized() { base.OnRealized(); } - - // Called when the widget needs to be (fully or partially) redrawn. #if GTK3 + /// + /// Called when the widget needs to be (fully or partially) redrawn. + /// + /// + /// protected override bool OnDrawn(Cairo.Context cr) #else + /// + /// Called when the widget is exposed. + /// + /// + /// protected override bool OnExposeEvent(Gdk.EventExpose evnt) #endif { @@ -254,7 +321,11 @@ namespace OpenTK return result; } - // Called on Resize + /// + /// Called whenever the widget is resized. + /// + /// + /// protected override bool OnConfigureEvent(Gdk.EventConfigure evnt) { bool result = base.OnConfigureEvent(evnt); @@ -265,7 +336,10 @@ namespace OpenTK return result; } - void Initialize() + /// + /// Initializes the with its given values and creates a . + /// + private void Initialize() { _Initialized = true; @@ -292,16 +366,22 @@ namespace OpenTK Console.WriteLine("OpenTK running on windows"); else if (Configuration.RunningOnMacOS) Console.WriteLine("OpenTK running on OSX"); - else + 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 = InitializeWindows(); + _WindowInfo = WinWindowsInfoInitializer.Initialize(widgetWindowHandle); else if (Configuration.RunningOnMacOS) - _WindowInfo = InitializeOSX(); + _WindowInfo = OSXWindowInfoInitializer.Initialize(widgetWindowHandle); else - _WindowInfo = InitializeX(graphicsMode); + _WindowInfo = XWindowInfoInitializer.Initialize(graphicsMode, this.Display.Handle, this.Screen.Number, widgetWindowHandle, this.Screen.RootWindow.Handle); // GraphicsContext _GraphicsContext = new GraphicsContext(graphicsMode, _WindowInfo, GlVersionMajor, GlVersionMinor, _GraphicsContextFlags); @@ -326,250 +406,5 @@ namespace OpenTK OnInitialized(); } - - #region Windows Specific initalization - - IWindowInfo InitializeWindows() - { - IntPtr windowHandle = gdk_win32_drawable_get_handle(GdkWindow.Handle); - return Utilities.CreateWindowsWindowInfo(windowHandle); - } - - [SuppressUnmanagedCodeSecurity, DllImport("libgdk-win32-2.0-0.dll")] - public static extern IntPtr gdk_win32_drawable_get_handle(IntPtr d); - - #endregion - - #region OSX Specific Initialization - - IWindowInfo InitializeOSX() - { - IntPtr windowHandle = gdk_quartz_window_get_nswindow(this.GdkWindow.Handle); - IntPtr viewHandle = gdk_quartz_window_get_nsview(this.GdkWindow.Handle); - return Utilities.CreateMacOSWindowInfo(windowHandle, viewHandle); - } - - [SuppressUnmanagedCodeSecurity, DllImport("libgdk-quartz-2.0.0.dylib")] - static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr handle); - - [SuppressUnmanagedCodeSecurity, DllImport("libgdk-quartz-2.0.0.dylib")] - static extern IntPtr gdk_quartz_window_get_nsview(IntPtr handle); - - #endregion - - #region X Specific Initialization - -#if GTK3 - const string UnixLibGdkName = "libgdk-3.so.0"; -#else - const string UnixLibGdkName = "libgdk-x11-2.0.so.0"; -#endif - const string UnixLibX11Name = "libX11.so.6"; - const string UnixLibGLName = "libGL.so.1"; - - const int GLX_NONE = 0; - const int GLX_USE_GL = 1; - const int GLX_BUFFER_SIZE = 2; - const int GLX_LEVEL = 3; - const int GLX_RGBA = 4; - const int GLX_DOUBLEBUFFER = 5; - const int GLX_STEREO = 6; - const int GLX_AUX_BUFFERS = 7; - const int GLX_RED_SIZE = 8; - const int GLX_GREEN_SIZE = 9; - const int GLX_BLUE_SIZE = 10; - const int GLX_ALPHA_SIZE = 11; - const int GLX_DEPTH_SIZE = 12; - const int GLX_STENCIL_SIZE = 13; - const int GLX_ACCUM_RED_SIZE = 14; - const int GLX_ACCUM_GREEN_SIZE = 15; - const int GLX_ACCUM_BLUE_SIZE = 16; - const int GLX_ACCUM_ALPHA_SIZE = 17; - - public enum XVisualClass - { - StaticGray = 0, - GrayScale = 1, - StaticColor = 2, - PseudoColor = 3, - TrueColor = 4, - DirectColor = 5, - } - - [StructLayout(LayoutKind.Sequential)] - struct XVisualInfo - { - public IntPtr Visual; - public IntPtr VisualID; - public int Screen; - public int Depth; - public XVisualClass Class; - public long RedMask; - public long GreenMask; - public long blueMask; - public int ColormapSize; - public int BitsPerRgb; - - public override string ToString() - { - return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})", - VisualID, Screen, Depth, Class); - } - } - - [Flags] - internal enum XVisualInfoMask - { - No = 0x0, - ID = 0x1, - Screen = 0x2, - Depth = 0x4, - Class = 0x8, - Red = 0x10, - Green = 0x20, - Blue = 0x40, - ColormapSize = 0x80, - BitsPerRGB = 0x100, - All = 0x1FF, - } - - IWindowInfo InitializeX(GraphicsMode mode) - { - IntPtr display = gdk_x11_display_get_xdisplay(Display.Handle); - int screen = Screen.Number; -#if GTK3 - IntPtr windowHandle = gdk_x11_window_get_xid(GdkWindow.Handle); - IntPtr rootWindow = gdk_x11_window_get_xid(RootWindow.Handle); -#else - IntPtr windowHandle = gdk_x11_drawable_get_xid(GdkWindow.Handle); - IntPtr rootWindow = gdk_x11_drawable_get_xid(RootWindow.Handle); -#endif - IWindowInfo retval; - - IntPtr visualInfo; - if (mode.Index.HasValue) - { - XVisualInfo info = new XVisualInfo(); - info.VisualID = mode.Index.Value; - int dummy; - visualInfo = XGetVisualInfo(display, XVisualInfoMask.ID, ref info, out dummy); - } - else - visualInfo = GetVisualInfo(display); - - retval = Utilities.CreateX11WindowInfo(display, screen, windowHandle, rootWindow, visualInfo); - XFree(visualInfo); - - return retval; - } - - static IntPtr XGetVisualInfo(IntPtr display, XVisualInfoMask vinfo_mask, ref XVisualInfo template, out int nitems) - { - return XGetVisualInfoInternal(display, (IntPtr)(int)vinfo_mask, ref template, out nitems); - } - - IntPtr GetVisualInfo(IntPtr display) - { - try - { - int[] attributes = AttributeList.ToArray(); - return glXChooseVisual(display, Screen.Number, attributes); - } - catch (DllNotFoundException e) - { - throw new DllNotFoundException("OpenGL dll not found!", e); - } - catch (EntryPointNotFoundException enf) - { - throw new EntryPointNotFoundException("Glx entry point not found!", enf); - } - } - - List AttributeList - { - get - { - List attributeList = new List(24); - - attributeList.Add(GLX_RGBA); - - if (!SingleBuffer) - attributeList.Add(GLX_DOUBLEBUFFER); - - if (Stereo) - attributeList.Add(GLX_STEREO); - - attributeList.Add(GLX_RED_SIZE); - attributeList.Add(ColorBPP / 4); // TODO support 16-bit - - attributeList.Add(GLX_GREEN_SIZE); - attributeList.Add(ColorBPP / 4); // TODO support 16-bit - - attributeList.Add(GLX_BLUE_SIZE); - attributeList.Add(ColorBPP / 4); // TODO support 16-bit - - attributeList.Add(GLX_ALPHA_SIZE); - attributeList.Add(ColorBPP / 4); // TODO support 16-bit - - attributeList.Add(GLX_DEPTH_SIZE); - attributeList.Add(DepthBPP); - - attributeList.Add(GLX_STENCIL_SIZE); - attributeList.Add(StencilBPP); - - //attributeList.Add(GLX_AUX_BUFFERS); - //attributeList.Add(Buffers); - - attributeList.Add(GLX_ACCUM_RED_SIZE); - attributeList.Add(AccumulatorBPP / 4);// TODO support 16-bit - - attributeList.Add(GLX_ACCUM_GREEN_SIZE); - attributeList.Add(AccumulatorBPP / 4);// TODO support 16-bit - - attributeList.Add(GLX_ACCUM_BLUE_SIZE); - attributeList.Add(AccumulatorBPP / 4);// TODO support 16-bit - - attributeList.Add(GLX_ACCUM_ALPHA_SIZE); - attributeList.Add(AccumulatorBPP / 4);// TODO support 16-bit - - attributeList.Add(GLX_NONE); - - return attributeList; - } - } - - [DllImport(UnixLibX11Name, EntryPoint = "XGetVisualInfo")] - static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr vinfo_mask, ref XVisualInfo template, out int nitems); - - [SuppressUnmanagedCodeSecurity, DllImport(UnixLibX11Name)] - static extern void XFree(IntPtr handle); - - /// Returns the X resource (window or pixmap) belonging to a GdkDrawable. - /// XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); - /// The GdkDrawable. - /// The ID of drawable's X resource. - [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)] - static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkDisplay); - - /// Returns the X resource (window or pixmap) belonging to a GdkDrawable. - /// XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); - /// The GdkDrawable. - /// The ID of drawable's X resource. - [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)] - static extern IntPtr gdk_x11_window_get_xid(IntPtr gdkDisplay); - - /// Returns the X display of a GdkDisplay. - /// Display* gdk_x11_display_get_xdisplay(GdkDisplay *display); - /// The GdkDrawable. - /// The X Display of the GdkDisplay. - [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)] - static extern IntPtr gdk_x11_display_get_xdisplay(IntPtr gdkDisplay); - - [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGLName)] - static extern IntPtr glXChooseVisual(IntPtr display, int screen, int[] attr); - - #endregion - } - -} +} \ No newline at end of file diff --git a/src/OpenTK.GLWidget/OSX/OSXWindowInfoInitializer.cs b/src/OpenTK.GLWidget/OSX/OSXWindowInfoInitializer.cs new file mode 100644 index 00000000..fd1c27ba --- /dev/null +++ b/src/OpenTK.GLWidget/OSX/OSXWindowInfoInitializer.cs @@ -0,0 +1,38 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; +using OpenTK.Platform; + +namespace OpenTK.OSX +{ + /// + /// Handler class for initializing objects under the OSX platform for both GTK2 and + /// GTK3. + /// + public static class OSXWindowInfoInitializer + { +#if GTK3 + const string OSXLibGdkName = "libgdk-3.dylib"; +#else + const string OSXLibGdkName = "libgdk-quartz-2.0.0.dylib"; +#endif + + /// + /// Initializes an under the OSX platform. + /// + /// + 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); + } +} \ No newline at end of file diff --git a/src/OpenTK.GLWidget/OpenTK.GLWidget.csproj b/src/OpenTK.GLWidget/OpenTK.GLWidget.csproj index 91e089ba..67028445 100644 --- a/src/OpenTK.GLWidget/OpenTK.GLWidget.csproj +++ b/src/OpenTK.GLWidget/OpenTK.GLWidget.csproj @@ -1,5 +1,5 @@  - + Local 8.0.30703 @@ -41,13 +41,14 @@ true v4.5 + 6 True 285212672 - DEBUG;TRACE; + DEBUG;TRACE;GTK3; bin\Debug\OpenTK.GLWidget.xml True 4096 @@ -65,7 +66,7 @@ 285212672 - TRACE; + TRACE;GTK3; bin\Release\OpenTK.GLWidget.xml 4096 True @@ -87,13 +88,47 @@ System - - - - - - + + + + + ..\..\packages\gtk-sharp3\lib\net40\atk-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\cairo-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\gdk-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\gio-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\glib-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\gtk-dotnet.dll + + + ..\..\packages\gtk-sharp3\lib\net40\gtk-sharp.dll + + + ..\..\packages\gtk-sharp3\lib\net40\pango-sharp.dll + + + + + + + + + + + + + + OpenTK @@ -102,44 +137,17 @@ + Code + + - - - - <__paket__GtkSharp_targets>net45\GtkSharp - - - - - - - - - - - - - - ..\..\packages\GtkSharp\lib\net45\cairo-sharp.dll - True - True - - - ..\..\packages\GtkSharp\lib\net45\gio-sharp.dll - True - True - - - - - \ No newline at end of file diff --git a/src/OpenTK.GLWidget/Win/WinWindowsInfoInitializer.cs b/src/OpenTK.GLWidget/Win/WinWindowsInfoInitializer.cs new file mode 100644 index 00000000..814267fa --- /dev/null +++ b/src/OpenTK.GLWidget/Win/WinWindowsInfoInitializer.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; +using OpenTK.Platform; + +namespace OpenTK.Win +{ + /// + /// Handler class for initializing objects under the Windows platform for both GTK2 and + /// GTK3. + /// + 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 + + /// + /// Initializes an under the Windows platform. + /// + /// + 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)] + 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 + + } +} \ No newline at end of file diff --git a/src/OpenTK.GLWidget/X11/XWindowInfoInitializer.cs b/src/OpenTK.GLWidget/X11/XWindowInfoInitializer.cs new file mode 100644 index 00000000..f81c8ccc --- /dev/null +++ b/src/OpenTK.GLWidget/X11/XWindowInfoInitializer.cs @@ -0,0 +1,175 @@ +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 +{ + /// + /// Handler class for initializing objects under the X11 platform for both GTK2 and GTK3. + /// + public static class XWindowInfoInitializer + { + +#if GTK3 + 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"; + + /// + /// Initializes an under the X11 platform. + /// + /// + /// + /// + /// + /// + /// + 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 CreateAttributeList(GraphicsMode mode) + { + List attributeList = new List(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 + /// Returns the X resource (window or pixmap) belonging to a GdkWindow. + /// XID gdk_x11_window_get_xid(GdkWindow *drawable); + /// The GdkDrawable. + /// The ID of window's X resource. + [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)] + private static extern IntPtr gdk_x11_window_get_xid(IntPtr gdkDisplay); +#else + /// Returns the X resource (window or pixmap) belonging to a GdkDrawable. + /// XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); + /// The GdkDrawable. + /// The ID of drawable's X resource. + [SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)] + static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkDisplay); +#endif + /// Returns the X display of a GdkDisplay. + /// Display* gdk_x11_display_get_xdisplay(GdkDisplay *display); + /// The GdkDrawable. + /// The X Display of the GdkDisplay. + [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); + } +} \ No newline at end of file diff --git a/src/OpenTK.GLWidget/paket.references b/src/OpenTK.GLWidget/paket.references index 0a38793d..f1b428b5 100644 --- a/src/OpenTK.GLWidget/paket.references +++ b/src/OpenTK.GLWidget/paket.references @@ -1 +1 @@ -GtkSharp \ No newline at end of file +gtk-sharp3 diff --git a/src/OpenTK/Platform/X11/API.cs b/src/OpenTK/Platform/X11/API.cs index 9626e617..952a80e3 100644 --- a/src/OpenTK/Platform/X11/API.cs +++ b/src/OpenTK/Platform/X11/API.cs @@ -70,7 +70,7 @@ namespace OpenTK.Platform.X11 static int DefaultScreen { get { return defaultScreen; } } //internal static Window RootWindow { get { return rootWindow; } } internal static int ScreenCount { get { return screenCount; } } - + internal static object Lock = new object(); #endregion @@ -79,9 +79,9 @@ namespace OpenTK.Platform.X11 { int has_threaded_x = Functions.XInitThreads(); Debug.Print("Initializing threaded X11: {0}.", has_threaded_x.ToString()); - + defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero); - + if (defaultDisplay == IntPtr.Zero) throw new PlatformException("Could not establish connection to the X-Server."); @@ -202,7 +202,7 @@ namespace OpenTK.Platform.X11 /// If a window is not interested in a device event, /// it usually propagates to the closest ancestor that is interested, /// unless the do_not_propagate mask prohibits it. - /// Setting the event-mask attribute of a window overrides any previous call for the same window but not for other clients. Multiple clients can select for the same events on the same window with the following restrictions: + /// Setting the event-mask attribute of a window overrides any previous call for the same window but not for other clients. Multiple clients can select for the same events on the same window with the following restrictions: /// Multiple clients can select events on the same window because their event masks are disjoint. When the X server generates an event, it reports it to all interested clients. /// Only one client at a time can select CirculateRequest, ConfigureRequest, or MapRequest events, which are associated with the event mask SubstructureRedirectMask. /// Only one client at a time can select a ResizeRequest event, which is associated with the event mask ResizeRedirectMask. @@ -343,7 +343,7 @@ namespace OpenTK.Platform.X11 public short htotal; /// - /// + /// /// public short hskew; @@ -368,7 +368,7 @@ namespace OpenTK.Platform.X11 public short vtotal; /// - /// + /// /// public short vskew; @@ -580,26 +580,26 @@ XF86VidModeGetGammaRampSize( public XcursorUInt delay; public XcursorPixel* pixels; } - + [StructLayout(LayoutKind.Sequential)] - unsafe struct XcursorImages + unsafe struct XcursorImages { public int nimage; public XcursorImage **images; public char *name; } - + [StructLayout(LayoutKind.Sequential)] - unsafe struct XcursorCursors + unsafe struct XcursorCursors { public Display dpy; public int refcount; public int ncursor; public Cursor *cursors; } - + [StructLayout(LayoutKind.Sequential)] - unsafe struct XcursorAnimate + unsafe struct XcursorAnimate { public XcursorCursors *cursors; public int sequence; @@ -607,10 +607,10 @@ XF86VidModeGetGammaRampSize( #endregion - #region internal class XVisualInfo + #region public class XVisualInfo [StructLayout(LayoutKind.Sequential)] - struct XVisualInfo + public struct XVisualInfo { public IntPtr Visual; public VisualID VisualID; @@ -755,7 +755,7 @@ XF86VidModeGetGammaRampSize( UIntPtr black_pixel; /* White and Black pixel values */ // unsigned long int max_maps, min_maps; /* max and min color maps */ int backing_store; /* Never, WhenMapped, Always */ - Bool save_unders; + Bool save_unders; long root_input_mask; /* initial root input mask */ } @@ -773,9 +773,9 @@ XF86VidModeGetGammaRampSize( }; #endregion - + #region Motif - + [StructLayout(LayoutKind.Sequential)] internal struct MotifWmHints { @@ -790,7 +790,7 @@ XF86VidModeGetGammaRampSize( return string.Format("MotifWmHints Specifies the structure from which the values (as specified by the value mask) are to be taken. The value mask should have the appropriate bits set to indicate which attributes have been set in the structure. /// The window ID of the created window. /// - /// The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. Each window and pixmap has its own coordinate system. For a window, the origin is inside the border at the inside, upper-left corner. + /// The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. Each window and pixmap has its own coordinate system. For a window, the origin is inside the border at the inside, upper-left corner. /// The border_width for an InputOnly window must be zero, or a BadMatch error results. For class InputOutput, the visual type and depth must be a combination supported for the screen, or a BadMatch error results. The depth need not be the same as the parent, but the parent must not be a window of class InputOnly, or a BadMatch error results. For an InputOnly window, the depth must be zero, and the visual must be one supported by the screen. If either condition is not met, a BadMatch error results. The parent window, however, may have any depth and class. If you specify any invalid window attribute for a window, a BadMatch error results. /// The created window is not yet displayed (mapped) on the user's display. To display the window, call XMapWindow(). The new window initially uses the same cursor as its parent. A new cursor can be defined for the new window by calling XDefineCursor(). The window will not be visible on the screen unless it and all of its ancestors are mapped and it is not obscured by any of its ancestors. /// XCreateWindow can generate BadAlloc BadColor, BadCursor, BadMatch, BadPixmap, BadValue, and BadWindow errors. @@ -1488,7 +1488,7 @@ XF86VidModeGetGammaRampSize( internal static unsafe extern void XcursorImageDestroy(XcursorImage* image); [DllImport(XcursorLibrary)] - internal static unsafe extern Cursor XcursorImageLoadCursor(Display dpy, XcursorImage* image); + internal static unsafe extern Cursor XcursorImageLoadCursor(Display dpy, XcursorImage* image); #endregion @@ -1538,7 +1538,7 @@ XF86VidModeGetGammaRampSize( /// Specifies the event. [DllImport(X11Library, EntryPoint = "XPutBackEvent")] public static extern void XPutBackEvent(IntPtr display, ref XEvent @event); - + #endregion #region Xrandr diff --git a/src/OpenTK/Platform/X11/Bindings/Glx.cs b/src/OpenTK/Platform/X11/Bindings/Glx.cs index aa03e91d..4bc2e0aa 100644 --- a/src/OpenTK/Platform/X11/Bindings/Glx.cs +++ b/src/OpenTK/Platform/X11/Bindings/Glx.cs @@ -17,7 +17,7 @@ namespace OpenTK.Platform.X11 { #region Enums - enum GLXAttribute : int + public enum GLXAttribute : int { TRANSPARENT_BLUE_VALUE_EXT = 0x27, GRAY_SCALE = 0x8006, @@ -364,7 +364,7 @@ namespace OpenTK.Platform.X11 [DllImport(Library, EntryPoint = "glXCreateContext")] public static extern IntPtr CreateContext(IntPtr dpy, ref XVisualInfo vis, IntPtr shareList, bool direct); - + [DllImport(Library, EntryPoint = "glXDestroyContext")] public static extern void DestroyContext(IntPtr dpy, IntPtr context); diff --git a/tests/OpenTK.Tests/OpenTK.Tests.fsproj b/tests/OpenTK.Tests/OpenTK.Tests.fsproj index d269e1c3..37a2a330 100644 --- a/tests/OpenTK.Tests/OpenTK.Tests.fsproj +++ b/tests/OpenTK.Tests/OpenTK.Tests.fsproj @@ -147,24 +147,6 @@ - - - - ..\..\packages\FSharp.Core\lib\net20\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll - True - True - - - @@ -183,24 +165,6 @@ - - - - ..\..\packages\FSharp.Core\lib\portable-net45+netcore45\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8\FSharp.Core.dll - True - True - - - @@ -1437,7 +1401,7 @@ - + ..\..\packages\System.Threading.Thread\lib\net46\System.Threading.Thread.dll @@ -1457,7 +1421,7 @@ - + ..\..\packages\System.Threading.ThreadPool\lib\net46\System.Threading.ThreadPool.dll