diff --git a/ClassicalSharp/Game/Game.Init.cs b/ClassicalSharp/Game/Game.Init.cs index 29b854f12..92d15ea1f 100644 --- a/ClassicalSharp/Game/Game.Init.cs +++ b/ClassicalSharp/Game/Game.Init.cs @@ -93,7 +93,9 @@ namespace ClassicalSharp { World = new World(this); LocalPlayer = new LocalPlayer(this); Components.Add(LocalPlayer); Entities.List[EntityList.SelfID] = LocalPlayer; - Width = window.Width; Height = window.Height; + + Size size = window.ClientSize; + Width = size.Width; Height = size.Height; MapRenderer = new MapRenderer(this); ChunkUpdater = new ChunkUpdater(this); diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 2c1766593..fe1e399b6 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -212,7 +212,9 @@ namespace ClassicalSharp { } internal void OnResize() { - Width = window.Width; Height = window.Height; + Size size = window.ClientSize; + Width = size.Width; Height = size.Height; + Graphics.OnWindowResize(this); UpdateProjection(); Gui.OnResize(); diff --git a/ClassicalSharp/GraphicsAPI/Direct3D9Api.cs b/ClassicalSharp/GraphicsAPI/Direct3D9Api.cs index 6356e35c0..9a83d096c 100644 --- a/ClassicalSharp/GraphicsAPI/Direct3D9Api.cs +++ b/ClassicalSharp/GraphicsAPI/Direct3D9Api.cs @@ -35,7 +35,7 @@ namespace ClassicalSharp.GraphicsAPI { MinZNear = 0.05f; IntPtr windowHandle = game.window.WindowInfo.WinHandle; d3d = new Direct3D(); - int adapter = d3d.Adapters[0].Adapter; + const int adapter = 0; // default adapter InitFields(); FindCompatibleFormat(adapter); diff --git a/ClassicalSharp/Platform/DesktopWindow.cs b/ClassicalSharp/Platform/DesktopWindow.cs index bb074b231..c13e8c09b 100644 --- a/ClassicalSharp/Platform/DesktopWindow.cs +++ b/ClassicalSharp/Platform/DesktopWindow.cs @@ -1,19 +1,14 @@ // Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 -using System; -using System.Drawing; -using System.IO; -using OpenTK; -using OpenTK.Graphics; -using Clipboard = System.Windows.Forms.Clipboard; +using System; +using System.Drawing; +using OpenTK; +using OpenTK.Graphics; namespace ClassicalSharp { /// Implementation of a native window and native input handling mechanism on Windows, OSX, and Linux. public sealed class DesktopWindow : GameWindow { - public int Width { get { return ClientSize.Width; } } - public int Height { get { return ClientSize.Height; } } - Game game; public DesktopWindow(Game game, string username, bool nullContext, int width, int height) : base(width, height, GraphicsMode.Default, Program.AppName + " (" + username + ")", nullContext, 0, DisplayDevice.Primary) { diff --git a/OpenTK/Graphics/GraphicsContextBase.cs b/OpenTK/Graphics/GraphicsContextBase.cs index 1cd7460fc..a3b2267aa 100644 --- a/OpenTK/Graphics/GraphicsContextBase.cs +++ b/OpenTK/Graphics/GraphicsContextBase.cs @@ -1,75 +1,73 @@ -#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 OpenTK.Platform; - -namespace OpenTK.Graphics { - - // Provides the foundation for all IGraphicsContext implementations. - abstract class GraphicsContextBase : IGraphicsContext { - - bool disposed; - - protected IntPtr ContextHandle; - protected GraphicsMode Mode; - - public abstract void SwapBuffers(); - - public abstract void MakeCurrent(IWindowInfo window); - - public abstract bool IsCurrent { get; } - - public bool IsDisposed { - get { return disposed; } - protected set { disposed = value; } - } - - public abstract bool VSync { get; set; } - - public virtual void Update(IWindowInfo window) { } - - public GraphicsMode GraphicsMode { get { return Mode; } } - - public abstract void LoadAll(); - - public IntPtr Context { get { return ContextHandle; } } - - public abstract IntPtr GetAddress(string function); - - public void Dispose() { - Dispose( true ); - GC.SuppressFinalize( this ); - } - - protected abstract void Dispose( bool calledManually ); - - ~GraphicsContextBase() { - Dispose(false); - } - } -} +#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 OpenTK.Platform; + +namespace OpenTK.Graphics { + + // Provides the foundation for all IGraphicsContext implementations. + abstract class GraphicsContextBase : IGraphicsContext { + + bool disposed; + + protected IntPtr ContextHandle; + protected GraphicsMode Mode; + + public abstract void SwapBuffers(); + + public abstract void MakeCurrent(IWindowInfo window); + + public abstract bool IsCurrent { get; } + + public bool IsDisposed { + get { return disposed; } + protected set { disposed = value; } + } + + public abstract bool VSync { get; set; } + + public virtual void Update(IWindowInfo window) { } + + public GraphicsMode GraphicsMode { get { return Mode; } } + + public abstract void LoadAll(); + + public IntPtr Context { get { return ContextHandle; } } + + public abstract IntPtr GetAddress(string function); + + public void Dispose() { + Dispose(true); + GC.SuppressFinalize( this ); + } + + protected abstract void Dispose(bool calledManually); + + ~GraphicsContextBase() { Dispose(false); } + } +} diff --git a/OpenTK/OpenTK.csproj b/OpenTK/OpenTK.csproj index 49985d5a2..181c7403d 100644 --- a/OpenTK/OpenTK.csproj +++ b/OpenTK/OpenTK.csproj @@ -1,155 +1,154 @@ - - - - {35FEE071-2DE6-48A1-9343-B5C1F202A12B} - Debug - AnyCPU - Library - OpenTK - OpenTK - v2.0 - - - Properties - False - True - False - False - obj\$(Configuration)\ - 4 - - - AnyCPU - 4194304 - False - Auto - 4096 - - - ..\output\debug\ - True - None - True - False - DEBUG;TRACE - obj\ - - - ..\output\release\ - False - None - True - False - TRACE - obj\ - Project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {4A4110EE-21CA-4715-AF67-0C8B7CE0642F} - InteropPatcher - - - - - - - - - - - + + + + {35FEE071-2DE6-48A1-9343-B5C1F202A12B} + Debug + AnyCPU + Library + OpenTK + OpenTK + v2.0 + + + Properties + False + True + False + False + obj\$(Configuration)\ + 4 + + + AnyCPU + 4194304 + False + Auto + 4096 + + + ..\output\debug\ + True + None + True + False + DEBUG;TRACE + obj\ + + + ..\output\release\ + False + None + True + False + TRACE + obj\ + Project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {4A4110EE-21CA-4715-AF67-0C8B7CE0642F} + InteropPatcher + + + + + + + + + + + \ No newline at end of file diff --git a/OpenTK/SharpDX.Direct3D/AdapterDetails.cs b/OpenTK/SharpDX.Direct3D/AdapterDetails.cs index 98778e8f5..c37c9d66d 100644 --- a/OpenTK/SharpDX.Direct3D/AdapterDetails.cs +++ b/OpenTK/SharpDX.Direct3D/AdapterDetails.cs @@ -23,18 +23,7 @@ using System.Runtime.InteropServices; namespace SharpDX.Direct3D9 { public class AdapterInformation { - readonly Direct3D d3d; - - internal AdapterInformation(Direct3D direct3D, int adapter) { - d3d = direct3D; - Adapter = adapter; - Details = direct3D.GetAdapterIdentifier(adapter); - } - - /// Gets the adapter ordinal. public int Adapter; - - /// Gets the details. public AdapterDetails Details; } diff --git a/OpenTK/SharpDX.Direct3D/Direct3D.cs b/OpenTK/SharpDX.Direct3D/Direct3D.cs index ea9fc1c0c..367a38407 100644 --- a/OpenTK/SharpDX.Direct3D/Direct3D.cs +++ b/OpenTK/SharpDX.Direct3D/Direct3D.cs @@ -27,12 +27,15 @@ namespace SharpDX.Direct3D9 { public unsafe class Direct3D : ComObject { public Direct3D() { - comPointer = Direct3DCreate9( SdkVersion ); - + comPointer = Direct3DCreate9(SdkVersion); int count = GetAdapterCount(); Adapters = new AdapterInformation[count]; - for( int i = 0; i < count; i++ ) { - Adapters[i] = new AdapterInformation( this, i ); + + for (int i = 0; i < count; i++) { + AdapterInformation info = new AdapterInformation(); + info.Adapter = i; + info.Details = GetAdapterIdentifier(i); + Adapters[i] = info; } } @@ -40,7 +43,7 @@ namespace SharpDX.Direct3D9 { const int SdkVersion = 32; [DllImport( "d3d9.dll" )] - static extern IntPtr Direct3DCreate9( int sdkVersion ); + static extern IntPtr Direct3DCreate9(int sdkVersion); public int GetAdapterCount() { return Interop.Calli(comPointer,(*(IntPtr**)comPointer)[4]); @@ -52,7 +55,7 @@ namespace SharpDX.Direct3D9 { if( res < 0 ) { throw new SharpDXException( res ); } AdapterDetails identifier = new AdapterDetails(); - identifier.MarshalFrom(ref identifierNative); + identifier.MarshalFrom(ref identifierNative); return identifier; } diff --git a/OpenTK/SharpDX.Direct3D/PresentParameters.cs b/OpenTK/SharpDX.Direct3D/PresentParameters.cs deleted file mode 100644 index 1d9640ac1..000000000 --- a/OpenTK/SharpDX.Direct3D/PresentParameters.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel -// -// 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. -using System; -using System.Runtime.InteropServices; - -namespace SharpDX.Direct3D9 { - - [StructLayout(LayoutKind.Sequential)] - public struct PresentParameters { - public int BackBufferWidth; - public int BackBufferHeight; - public Format BackBufferFormat; - public int BackBufferCount; - public int MultiSampleType; - public int MultiSampleQuality; - public SwapEffect SwapEffect; - public IntPtr DeviceWindowHandle; - public RawBool Windowed; - public RawBool EnableAutoDepthStencil; - public Format AutoDepthStencilFormat; - public PresentFlags PresentFlags; - public int FullScreenRefreshRateInHz; - public PresentInterval PresentationInterval; - - public void InitDefaults() { - AutoDepthStencilFormat = Format.D24X8; - BackBufferWidth = 800; - BackBufferHeight = 600; - BackBufferFormat = Format.X8R8G8B8; - BackBufferCount = 1; - DeviceWindowHandle = IntPtr.Zero; - EnableAutoDepthStencil = true; - PresentFlags = PresentFlags.None; - PresentationInterval = PresentInterval.Immediate; - SwapEffect = SwapEffect.Discard; - Windowed = true; - } - } -} diff --git a/OpenTK/SharpDX.Direct3D/Structures.cs b/OpenTK/SharpDX.Direct3D/Structures.cs index 8bc31bdc9..93f09a7e9 100644 --- a/OpenTK/SharpDX.Direct3D/Structures.cs +++ b/OpenTK/SharpDX.Direct3D/Structures.cs @@ -1,105 +1,123 @@ -// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel -// -// 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. - -using System; -using System.Runtime.InteropServices; - -namespace SharpDX.Direct3D9 { - - [StructLayout(LayoutKind.Sequential)] - public struct Capabilities { - public DeviceType DeviceType; - public int AdapterOrdinal; - public int Caps; - public Caps2 Caps2; - public Caps3 Caps3; - public PresentInterval PresentationIntervals; - public int CursorCaps; - public DeviceCaps DeviceCaps; - public PrimitiveMiscCaps PrimitiveMiscCaps; - public RasterCaps RasterCaps; - public CompareCaps DepthCompareCaps; - public BlendCaps SourceBlendCaps; - public BlendCaps DestinationBlendCaps; - public CompareCaps AlpaCompareCaps; - public ShadeCaps ShadeCaps; - public TextureCaps TextureCaps; - public int TextureFilterCaps; - public int CubeTextureFilterCaps; - public int VolumeTextureFilterCaps; - public TextureAddressCaps TextureAddressCaps; - public TextureAddressCaps VolumeTextureAddressCaps; - public LineCaps LineCaps; - public int MaxTextureWidth; - public int MaxTextureHeight; - public int MaxVolumeExtent; - public int MaxTextureRepeat; - public int MaxTextureAspectRatio; - public int MaxAnisotropy; - public float MaxVertexW; - public float GuardBandLeft; - public float GuardBandTop; - public float GuardBandRight; - public float GuardBandBottom; - public float ExtentsAdjust; - public int StencilCaps; - public VertexFormatCaps FVFCaps; - public int TextureOperationCaps; - public int MaxTextureBlendStages; - public int MaxSimultaneousTextures; - public int VertexProcessingCaps; - public int MaxActiveLights; - public int MaxUserClipPlanes; - public int MaxVertexBlendMatrices; - public int MaxVertexBlendMatrixIndex; - public float MaxPointSize; - public int MaxPrimitiveCount; - public int MaxVertexIndex; - public int MaxStreams; - public int MaxStreamStride; - internal int VertexShaderVersion_; - public int MaxVertexShaderConst; - internal int PixelShaderVersion_; - public float PixelShader1xMaxValue; - public DeviceCaps2 DeviceCaps2; - public float MaxNpatchTessellationLevel; - internal int Reserved5; - public int MasterAdapterOrdinal; - public int AdapterOrdinalInGroup; - public int NumberOfAdaptersInGroup; - public int DeclarationTypes; - public int SimultaneousRTCount; - public int StretchRectFilterCaps; - public int VS20Caps; - public int VS20DynamicFlowControlDepth; - public int VS20NumTemps; - public int VS20StaticFlowControlDepth; - public int PS20Caps; - public int PS20DynamicFlowControlDepth; - public int PS20NumTemps; - public int PS20StaticFlowControlDepth; - public int PS20NumInstructionSlots; - public int VertexTextureFilterCaps; - public int MaxVShaderInstructionsExecuted; - public int MaxPShaderInstructionsExecuted; - public int MaxVertexShader30InstructionSlots; - public int MaxPixelShader30InstructionSlots; - } +// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel +// +// 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. + +using System; +using System.Runtime.InteropServices; + +namespace SharpDX.Direct3D9 { + + [StructLayout(LayoutKind.Sequential)] + public struct PresentParameters { + public int BackBufferWidth; + public int BackBufferHeight; + public Format BackBufferFormat; + public int BackBufferCount; + public int MultiSampleType; + public int MultiSampleQuality; + public SwapEffect SwapEffect; + public IntPtr DeviceWindowHandle; + public RawBool Windowed; + public RawBool EnableAutoDepthStencil; + public Format AutoDepthStencilFormat; + public PresentFlags PresentFlags; + public int FullScreenRefreshRateInHz; + public PresentInterval PresentationInterval; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Capabilities { + public DeviceType DeviceType; + public int AdapterOrdinal; + public int Caps; + public Caps2 Caps2; + public Caps3 Caps3; + public PresentInterval PresentationIntervals; + public int CursorCaps; + public DeviceCaps DeviceCaps; + public PrimitiveMiscCaps PrimitiveMiscCaps; + public RasterCaps RasterCaps; + public CompareCaps DepthCompareCaps; + public BlendCaps SourceBlendCaps; + public BlendCaps DestinationBlendCaps; + public CompareCaps AlpaCompareCaps; + public ShadeCaps ShadeCaps; + public TextureCaps TextureCaps; + public int TextureFilterCaps; + public int CubeTextureFilterCaps; + public int VolumeTextureFilterCaps; + public TextureAddressCaps TextureAddressCaps; + public TextureAddressCaps VolumeTextureAddressCaps; + public LineCaps LineCaps; + public int MaxTextureWidth; + public int MaxTextureHeight; + public int MaxVolumeExtent; + public int MaxTextureRepeat; + public int MaxTextureAspectRatio; + public int MaxAnisotropy; + public float MaxVertexW; + public float GuardBandLeft; + public float GuardBandTop; + public float GuardBandRight; + public float GuardBandBottom; + public float ExtentsAdjust; + public int StencilCaps; + public VertexFormatCaps FVFCaps; + public int TextureOperationCaps; + public int MaxTextureBlendStages; + public int MaxSimultaneousTextures; + public int VertexProcessingCaps; + public int MaxActiveLights; + public int MaxUserClipPlanes; + public int MaxVertexBlendMatrices; + public int MaxVertexBlendMatrixIndex; + public float MaxPointSize; + public int MaxPrimitiveCount; + public int MaxVertexIndex; + public int MaxStreams; + public int MaxStreamStride; + internal int VertexShaderVersion_; + public int MaxVertexShaderConst; + internal int PixelShaderVersion_; + public float PixelShader1xMaxValue; + public DeviceCaps2 DeviceCaps2; + public float MaxNpatchTessellationLevel; + internal int Reserved5; + public int MasterAdapterOrdinal; + public int AdapterOrdinalInGroup; + public int NumberOfAdaptersInGroup; + public int DeclarationTypes; + public int SimultaneousRTCount; + public int StretchRectFilterCaps; + public int VS20Caps; + public int VS20DynamicFlowControlDepth; + public int VS20NumTemps; + public int VS20StaticFlowControlDepth; + public int PS20Caps; + public int PS20DynamicFlowControlDepth; + public int PS20NumTemps; + public int PS20StaticFlowControlDepth; + public int PS20NumInstructionSlots; + public int VertexTextureFilterCaps; + public int MaxVShaderInstructionsExecuted; + public int MaxPShaderInstructionsExecuted; + public int MaxVertexShader30InstructionSlots; + public int MaxPixelShader30InstructionSlots; + } } \ No newline at end of file diff --git a/OpenTK/SharpDX/ComObject.cs b/OpenTK/SharpDX/ComObject.cs index 5a9a0112b..04410d158 100644 --- a/OpenTK/SharpDX/ComObject.cs +++ b/OpenTK/SharpDX/ComObject.cs @@ -1,67 +1,58 @@ -// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel -// -// 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. -using System; -using System.Runtime.InteropServices; - -namespace SharpDX -{ - public class ComObject : IDisposable - { - public IntPtr comPointer; - - public ComObject(IntPtr pointer) { - comPointer = pointer; - } - - protected ComObject() { - } - - public bool IsDisposed; - - public void Dispose() { - CheckAndDispose( true ); - } - - ~ComObject() { - CheckAndDispose( false ); - } - - unsafe void CheckAndDispose( bool disposing ) { - if( IsDisposed ) return; - - if( comPointer != IntPtr.Zero ) { - if( !disposing ) { - string text = String.Format( "Warning: Live ComObject [0x{0:X}], potential memory leak: {1}", - comPointer.ToInt64(), GetType().Name ); - Console.WriteLine( text ); - } - - int refCount = Marshal.Release( comPointer ); - if( refCount > 0 ) { - string text = String.Format( "Warning: ComObject [0x{0:X}] still has some references, potential memory leak: {1} ({2})", - comPointer.ToInt64(), GetType().Name, refCount ); - } - comPointer = IntPtr.Zero; - } - GC.SuppressFinalize( this ); - IsDisposed = true; - } - } +// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel +// +// 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. +using System; +using System.Runtime.InteropServices; + +namespace SharpDX { + public class ComObject : IDisposable { + public IntPtr comPointer; + + public ComObject(IntPtr pointer) { comPointer = pointer; } + public ComObject() { } + + public void Dispose() { + Dispose(true); + GC.SuppressFinalize(this); + } + + ~ComObject() { Dispose(false); } + + public bool IsDisposed; + unsafe void Dispose( bool disposing ) { + if( IsDisposed ) return; + + if( comPointer == IntPtr.Zero ) { + if( !disposing ) { + string text = String.Format( "Warning: Live ComObject [0x{0:X}], potential memory leak: {1}", + comPointer.ToInt64(), GetType().Name ); + Console.WriteLine( text ); + } + + int refCount = Marshal.Release( comPointer ); + if( refCount > 0 ) { + string text = String.Format( "Warning: ComObject [0x{0:X}] still has some references, potential memory leak: {1} ({2})", + comPointer.ToInt64(), GetType().Name, refCount ); + } + comPointer = IntPtr.Zero; + } + IsDisposed = true; + } + } } \ No newline at end of file diff --git a/OpenTK/SharpDX/Raw.cs b/OpenTK/SharpDX/Raw.cs index 2b2d98b27..c750e7c19 100644 --- a/OpenTK/SharpDX/Raw.cs +++ b/OpenTK/SharpDX/Raw.cs @@ -1,60 +1,60 @@ -// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel -// -// 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. - -using System; -using System.Runtime.InteropServices; - -namespace SharpDX { - - [StructLayout(LayoutKind.Sequential, Size = 4)] - public struct RawBool { - private int boolValue; - - public RawBool(bool boolValue) { - this.boolValue = boolValue ? 1 : 0; - } - - public static implicit operator bool(RawBool booleanValue) { - return booleanValue.boolValue != 0; - } - - public static implicit operator RawBool(bool boolValue) { - return new RawBool(boolValue); - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct LockedRectangle { - - /// Gets the number of bytes per row. - public int Pitch; - - /// Pointer to the data. - public IntPtr DataPointer; - } - - [StructLayout(LayoutKind.Sequential)] - public struct D3DRect { - public int Left; - public int Top; - public int Right; - public int Bottom; - } -} +// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel +// +// 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. + +using System; +using System.Runtime.InteropServices; + +namespace SharpDX { + + [StructLayout(LayoutKind.Sequential, Size = 4)] + public struct RawBool { + private int boolValue; + + public RawBool(bool boolValue) { + this.boolValue = boolValue ? 1 : 0; + } + + public static implicit operator bool(RawBool booleanValue) { + return booleanValue.boolValue != 0; + } + + public static implicit operator RawBool(bool boolValue) { + return new RawBool(boolValue); + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct LockedRectangle { + + /// Gets the number of bytes per row. + public int Pitch; + + /// Pointer to the data. + public IntPtr DataPointer; + } + + [StructLayout(LayoutKind.Sequential)] + public struct D3DRect { + public int Left; + public int Top; + public int Right; + public int Bottom; + } +} diff --git a/OpenTK/SharpDX/Result.cs b/OpenTK/SharpDX/Result.cs index 3c8f1346e..1ecf27f5d 100644 --- a/OpenTK/SharpDX/Result.cs +++ b/OpenTK/SharpDX/Result.cs @@ -1,53 +1,52 @@ -// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel -// -// 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. -using System; -using System.Runtime.InteropServices; - -namespace SharpDX { - - public enum Direct3DError : uint { - Ok = 0, - NotFound = 2150 | 0x88760000u, - MoreData = 2151 | 0x88760000u, - DeviceLost = 2152 | 0x88760000u, - DeviceNotReset = 2153 | 0x88760000u, - NotAvailable = 2154 | 0x88760000u, - OutOfVideoMemory = 380 | 0x88760000u, - InvalidDevice = 2155 | 0x88760000u, - InvalidCall = 2156 | 0x88760000u, - DriverInvalidCall = 2157 | 0x88760000u, - WasStillDrawing = 540 | 0x88760000u, - } - - public class SharpDXException : Exception { - - public int Code; - - public SharpDXException(int result) : base(Format(result)) { - HResult = result; - Code = result; - } - - static string Format( int code ) { - Direct3DError err = (Direct3DError)code; - return String.Format( "HRESULT: [0x{0:X}], D3D error type: {1}", code, err ); - } - } +// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel +// +// 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. +using System; +using System.Runtime.InteropServices; + +namespace SharpDX { + + public enum Direct3DError : uint { + Ok = 0, + NotFound = 2150 | 0x88760000u, + MoreData = 2151 | 0x88760000u, + DeviceLost = 2152 | 0x88760000u, + DeviceNotReset = 2153 | 0x88760000u, + NotAvailable = 2154 | 0x88760000u, + OutOfVideoMemory = 380 | 0x88760000u, + InvalidDevice = 2155 | 0x88760000u, + InvalidCall = 2156 | 0x88760000u, + DriverInvalidCall = 2157 | 0x88760000u, + WasStillDrawing = 540 | 0x88760000u, + } + + public class SharpDXException : Exception { + public int Code; + + public SharpDXException(int result) : base(Format(result)) { + HResult = result; + Code = result; + } + + static string Format( int code ) { + Direct3DError err = (Direct3DError)code; + return String.Format( "HRESULT: [0x{0:X}], D3D error type: {1}", code, err ); + } + } } \ No newline at end of file diff --git a/src/Client/Window.h b/src/Client/Window.h index 583465340..37f5381ad 100644 --- a/src/Client/Window.h +++ b/src/Client/Window.h @@ -80,7 +80,7 @@ void GLContext_Update(void); void GLContext_Free(void); #define GLContext_IsInvalidAddress(ptr) (ptr == (void*)0 || ptr == (void*)1 || ptr == (void*)-1 || ptr == (void*)2) -void* GLContext_GetAddress(const UInt8* function); +void* GLContext_GetAddress(const UChar* function); void GLContext_SwapBuffers(void); bool GLContext_GetVSync(void); void GLContext_SetVSync(bool enabled);