diff --git a/.gitignore b/.gitignore index 2d9d04435..6d257cb58 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.userprefs +obj +bin \ No newline at end of file diff --git a/Projects/OpenTK.Android/OpenTK.Android.csproj b/Projects/OpenTK.Android/OpenTK.Android.csproj index 0f9f06a2c..013807121 100644 --- a/Projects/OpenTK.Android/OpenTK.Android.csproj +++ b/Projects/OpenTK.Android/OpenTK.Android.csproj @@ -1,541 +1,56 @@ - + - Debug - AnyCPU - {9BBB96AB-86BA-45CC-9D9A-16A1432671EE} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - OpenTKA - Assets - Resources - OpenTKA - - - true - full - false - bin\Debug - MONODROID;MINIMAL;MOBILE;OPENTK_1;LOGGING - prompt - 4 - false - None - true - - - none - true - bin\Release - prompt - 4 - false - false + OpenTK1.0 + monoandroid11.0;net6.0-android + ..\..\OpenTK.snk true - MONODROID;MINIMAL;MOBILE;OPENTK_1 + false - ..\..\OpenTK.snk + MONODROID + IPHONE;XAMCORE_2_0 + $(DefineConstants);MINIMAL;MOBILE;OPENTK_1 + $(DefineConstants);LOGGING - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - DisplayDevice.cs - - - WindowBorder.cs - - - ContextHandle.cs - - - WindowState.cs - - - IGameWindow.cs - - - GameWindowFlags.cs - - - KeyPressEventArgs.cs - - - AutoGeneratedAttribute.cs - - - NativeWindow.cs - - - DisplayResolution.cs - - - BindingBase.cs - - - Toolkit.cs - - - FrameEventArgs.cs - - - BlittableValueType.cs - - - Minimal.cs - - - Configuration.cs - - - Exceptions.cs - - - INativeWindow.cs - - - Properties\AssemblyInfo.cs - - - Platform\IDisplayDeviceDriver.cs - - - Platform\IWindowInfo.cs - - - Platform\DesktopGraphicsContext.cs - - - Platform\EmbeddedGraphicsContext.cs - - - Platform\PlatformException.cs - - - Platform\IPlatformFactory.cs - - - Platform\DisplayDevice.cs - - - Platform\Utilities.cs - - - Platform\INativeGLWindow.cs - - - Platform\Dummy\DummyWindowInfo.cs - - - Platform\Dummy\DummyGLContext.cs - - - Platform\Egl\EglGraphicsMode.cs - - - Platform\Egl\EglWindowInfo.cs - - - Platform\Egl\Egl.cs - - - Platform\Egl\EglContext.cs - - - Graphics\IGraphicsMode.cs - - - Graphics\GraphicsExceptions.cs - - - Graphics\GraphicsErrorException.cs - - - Graphics\Color4.cs - - - Graphics\GraphicsContextVersion.cs - - - Graphics\IGraphicsContext.cs - - - Graphics\GraphicsMode.cs - - - Graphics\GraphicsModeException.cs - - - Graphics\GraphicsContextFlags.cs - - - Graphics\GraphicsContextMissingException.cs - - - Graphics\GraphicsContext.cs - - - Graphics\GraphicsContextException.cs - - - Graphics\GraphicsContextBase.cs - - - Graphics\GraphicsBindingBase.cs - - - Graphics\ColorFormat.cs - - - Input\Keyboard.cs - - - Input\GamePad.cs - - - Input\MouseDevice.cs - - - Input\Key.cs - - - Input\IJoystickDriver.cs - - - Input\IMouseDriver.cs - - - Input\IInputDriver.cs - - - Input\KeyboardDevice.cs - - - Input\KeyboardState.cs - - - Input\MouseButton.cs - - - Input\JoystickDevice.cs - - - Input\IKeyboardDriver.cs - - - Input\KeyboardKeyEventArgs.cs - - - Input\Mouse.cs - - - Input\MouseState.cs - - - Input\GamePadState.cs - - - Input\IInputDevice.cs - - - Math\Quaternion.cs - - - Math\Matrix3d.cs - - - Math\Vector4.cs - - - Math\BezierCurve.cs - - - Math\Vector3.cs - - - Math\Functions.cs - - - Math\Matrix4d.cs - - - Math\Vector2d.cs - - - Math\Vector2h.cs - - - Math\Vector3h.cs - - - Math\Point.cs - - - Math\Box2.cs - - - Math\Matrix4.cs - - - Math\Half.cs - - - Math\Vector4d.cs - - - Math\Rectangle.cs - - - Math\Vector2.cs - - - Math\BezierCurveQuadric.cs - - - Math\MathHelper.cs - - - Math\Quaterniond.cs - - - Math\Vector4h.cs - - - MAth\Size.cs - - - MAth\Vector3d.cs - - - MAth\BezierCurveCubic.cs - - - Compute\Memory.cs - - - Compute\Device.cs - - - Compute\Platform.cs - - - Compute\Sampler.cs - - - Compute\Kernel.cs - - - Compute\Profiler.cs - - - Compute\Program.cs - - - Compute\Enums.cs - - - Compute\CommandQueue.cs - - - Compute\CLHelper.cs - - - Compute\Event.cs - - - Compute\Structs.cs - - - Compute\Configuration.cs - - - Compute\ComputeContext.cs - - - Compute\CL10\Enums.cs - - - Compute\CL10\ErrorHelper.cs - - - Compute\CL10\Delegates.cs - - - Compute\CL10\Core.cs - - - Compute\CL10\CLHelper.cs - - - Compute\CL10\CL.cs - - - Compute\CL10\ImageFormat.cs - - - Audio\AudioDeviceException.cs - - - Audio\AudioContextException.cs - - - Audio\AudioValueException.cs - - - Audio\AudioException.cs - - - Audio\AudioDeviceEnumerator.cs - - - Audio\AudioDeviceErrorChecker.cs - - - Audio\AudioContext.cs - - - Audio\AudioCapture.cs - - - Audio\OpenAL\Alc\AlcEnums.cs - - - Audio\OpenAL\Alc\Alc.cs - - - Audio\OpenAL\AL\EffectsExtensionPresets.cs - - - Audio\OpenAL\AL\EffectsExtensionEnums.cs - - - Audio\OpenAL\AL\XRamExtension.cs - - - Audio\OpenAL\AL\EffectExtension.cs - - - Audio\OpenAL\AL\AL.cs - - - Audio\OpenAL\AL\ALEnums.cs - - - Graphics\EL10.Android\Enums.cs - - - Graphics\EL10.Android\Core.cs - - - Graphics\EL10.Android\ES.cs - - - Graphics\EL10.Android\ES.Obsolete.cs - - - Graphics\EL10.Android\Helper.cs - - - Graphics\EL11.Android\Enums.cs - - - Graphics\EL11.Android\Core.cs - - - Graphics\EL11.Android\ES.cs - - - Graphics\EL11.Android\ES.Obsolete.cs - - - Graphics\EL11.Android\Helper.cs - - - Graphics\EL20.Android\Enums.cs - - - Graphics\EL20.Android\Core.cs - - - Graphics\EL20.Android\ES.cs - - - Graphics\EL20.Android\ES.Obsolete.cs - - - Graphics\EL20.Android\Helper.cs - - - Graphics\EL30.Android\Enums.cs - - - Graphics\EL30.Android\Core.cs - - - Graphics\EL30.Android\ES.cs - - - Graphics\EL30.Android\ES.Obsolete.cs - - - Graphics\EL30.Android\Helper.cs - - - Math\Matrix3.cs - - - DisplayIndex.cs - - - Input\IKeyboardDriver2.cs - - - Input\IMouseDriver2.cs - - - Input\ButtonState.cs - - - Platform\Android\AndroidGameView.cs - - - Platform\Android\AndroidGraphicsContext.cs - - - Platform\Android\AndroidGraphicsMode.cs - - - Platform\Android\GLCalls.cs - - - Platform\Android\GameViewBase.cs - - - Platform\Android\1.0\AndroidDisplayDeviceDriver.cs - - - Platform\Android\1.0\AndroidFactory.cs - - - Platform\Android\1.0\EglAndroidPlatformFactory.cs - - - Platform\Android\1.0\Enums.cs - - - Graphics\ES10\ErrorHelper.cs - - - Graphics\ES11\ErrorHelper.cs - - - Graphics\ES20\ErrorHelper.cs - + - + \ No newline at end of file diff --git a/Source/OpenTK/Graphics/ES30/ErrorHelper.cs b/Source/OpenTK/Graphics/ES30/ErrorHelper.cs new file mode 100644 index 000000000..eaaa44fbd --- /dev/null +++ b/Source/OpenTK/Graphics/ES30/ErrorHelper.cs @@ -0,0 +1,134 @@ +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2009 the Open Toolkit library. +// +// 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.Text; +using System.Diagnostics; + +namespace OpenTK.Graphics.ES30 +{ + // Used in debug-mode only, for automatic OpenGL error-checking. + // + // Works like this: an instance is created before each OpenGL function is called. + // The constructor resets the OpenGL error state. Once the native function returns, + // the error state is checked again, raising the relevant exceptions. + // + // A using-region is used to ensure Dispose() is called. + // + // Make sure that no error checking is added to the GetError function, + // as that would cause infinite recursion! + struct ErrorHelper : IDisposable + { + #region Fields + + static readonly object SyncRoot = new object(); + static readonly Dictionary> ContextErrors = + new Dictionary>(); + readonly GraphicsContext Context; + + #endregion + + #region Constructors + + public ErrorHelper(IGraphicsContext context) + { + if (context == null) + throw new GraphicsContextMissingException(); + + Context = (GraphicsContext)context; + lock (SyncRoot) + { + if (!ContextErrors.ContainsKey(Context)) + ContextErrors.Add(Context, new List()); + } + ResetErrors(); + } + + #endregion + + #region Public Members + + // Retrieve all OpenGL errors to clear the error list. + // See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html + [Conditional("DEBUG")] + internal void ResetErrors() + { + if (Context.ErrorChecking) + { + while ((ErrorCode)GL.GetError() != ErrorCode.NoError) + { } + } + } + + // Retrieve all OpenGL errors and throw an exception if anything other than NoError is returned. + [Conditional("DEBUG")] + internal void CheckErrors() + { + if (Context.ErrorChecking) + { + List error_list = ContextErrors[Context]; + error_list.Clear(); + ErrorCode error; + do + { + error = (ErrorCode)GL.GetError(); + error_list.Add(error); + } while (error != ErrorCode.NoError); + + if (error_list.Count != 1) + { + StringBuilder sb = new StringBuilder(); + foreach (ErrorCode e in error_list) + { + if (e != ErrorCode.NoError) + { + sb.Append(e.ToString()); + sb.Append(", "); + } + else + break; + } + sb.Remove(sb.Length - 2, 2); // Remove the last comma + + throw new GraphicsErrorException(sb.ToString()); + } + } + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + CheckErrors(); + } + + #endregion + } +} diff --git a/Source/OpenTK/Graphics/ES31/ErrorHelper.cs b/Source/OpenTK/Graphics/ES31/ErrorHelper.cs new file mode 100644 index 000000000..1199cbde2 --- /dev/null +++ b/Source/OpenTK/Graphics/ES31/ErrorHelper.cs @@ -0,0 +1,134 @@ +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2009 the Open Toolkit library. +// +// 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.Text; +using System.Diagnostics; + +namespace OpenTK.Graphics.ES31 +{ + // Used in debug-mode only, for automatic OpenGL error-checking. + // + // Works like this: an instance is created before each OpenGL function is called. + // The constructor resets the OpenGL error state. Once the native function returns, + // the error state is checked again, raising the relevant exceptions. + // + // A using-region is used to ensure Dispose() is called. + // + // Make sure that no error checking is added to the GetError function, + // as that would cause infinite recursion! + struct ErrorHelper : IDisposable + { + #region Fields + + static readonly object SyncRoot = new object(); + static readonly Dictionary> ContextErrors = + new Dictionary>(); + readonly GraphicsContext Context; + + #endregion + + #region Constructors + + public ErrorHelper(IGraphicsContext context) + { + if (context == null) + throw new GraphicsContextMissingException(); + + Context = (GraphicsContext)context; + lock (SyncRoot) + { + if (!ContextErrors.ContainsKey(Context)) + ContextErrors.Add(Context, new List()); + } + ResetErrors(); + } + + #endregion + + #region Public Members + + // Retrieve all OpenGL errors to clear the error list. + // See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html + [Conditional("DEBUG")] + internal void ResetErrors() + { + if (Context.ErrorChecking) + { + while ((ErrorCode)GL.GetError() != ErrorCode.NoError) + { } + } + } + + // Retrieve all OpenGL errors and throw an exception if anything other than NoError is returned. + [Conditional("DEBUG")] + internal void CheckErrors() + { + if (Context.ErrorChecking) + { + List error_list = ContextErrors[Context]; + error_list.Clear(); + ErrorCode error; + do + { + error = (ErrorCode)GL.GetError(); + error_list.Add(error); + } while (error != ErrorCode.NoError); + + if (error_list.Count != 1) + { + StringBuilder sb = new StringBuilder(); + foreach (ErrorCode e in error_list) + { + if (e != ErrorCode.NoError) + { + sb.Append(e.ToString()); + sb.Append(", "); + } + else + break; + } + sb.Remove(sb.Length - 2, 2); // Remove the last comma + + throw new GraphicsErrorException(sb.ToString()); + } + } + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + CheckErrors(); + } + + #endregion + } +} diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..d1c1a7972 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,50 @@ +trigger: + branches: + include: + - master + - refs/tags/* +resources: + repositories: + - repository: internal-templates + type: github + name: xamarin/yaml-templates + endpoint: xamarin + ref: refs/heads/main +variables: + - group: Xamarin-Secrets + - name: Configuration + value: Release + DotNetVersion: 6.0.100-preview.1.21103.13 + DotNet.Cli.Telemetry.OptOut: true + Android.Msi: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4451481/master/05bb8e0eae11ae6a73838b13cf91ee2433169dff/Microsoft.NET.Workload.Android.11.0.200.85.msi + Android.Pkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4451481/master/05bb8e0eae11ae6a73838b13cf91ee2433169dff/Microsoft.NET.Workload.Android-11.0.200-ci.master.85.pkg + iOS.Msi: https://bosstoragemirror.azureedge.net/wrench/main/f01fde5cd9a7ffffcdc8d241200c35988700fa00/4449408/package/Microsoft.NET.Workload.iOS.14.3.100-ci.main.1079.msi + iOS.Pkg: https://bosstoragemirror.azureedge.net/wrench/main/f01fde5cd9a7ffffcdc8d241200c35988700fa00/4449408/package/notarized/Microsoft.iOS.Bundle.14.3.100-ci.main.1079.pkg + +stages: + - stage: Build + jobs: + - job: buildWindows + pool: + vmImage: windows-latest + variables: + LogDirectory: $(Build.ArtifactStagingDirectory)\logs + steps: + - powershell: | + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1 + & .\dotnet-install.ps1 -Version $(DotNetVersion) -InstallDir "$env:ProgramFiles\dotnet\" -Verbose + & dotnet --list-sdks + displayName: install .NET $(DotNetVersion) + errorActionPreference: stop + - powershell: | + & dotnet tool install --global boots + & boots $(Android.Msi) + & boots $(iOS.Msi) + displayName: install .NET workloads + errorActionPreference: stop + - powershell: | + & dotnet build Projects\OpenTK.Android\OpenTK.Android.csproj -c Debug -bl:$(LogDirectory)\Debug.binlog + & dotnet build Projects\OpenTK.Android\OpenTK.Android.csproj -c Release -bl:$(LogDirectory)\Release.binlog + displayName: build samples + errorActionPreference: stop \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 000000000..94efed88e --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "Xamarin.Legacy.Sdk": "0.1.0-alpha2" + } +} \ No newline at end of file