minor code cleanup

This commit is contained in:
UnknownShadow200 2018-07-07 21:18:04 +10:00
parent e052f7eb5f
commit 3286f3e7ee
14 changed files with 537 additions and 597 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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 {
/// <summary> Implementation of a native window and native input handling mechanism on Windows, OSX, and Linux. </summary>
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) {

View File

@ -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); }
}
}

View File

@ -1,155 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="2.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{35FEE071-2DE6-48A1-9343-B5C1F202A12B}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>OpenTK</RootNamespace>
<AssemblyName>OpenTK</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<BaseAddress>4194304</BaseAddress>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
<OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\output\release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="BindingsBase.cs" />
<Compile Include="Debug.cs" />
<Compile Include="DisplayDevice.cs" />
<Compile Include="FrameEventArgs.cs" />
<Compile Include="GameWindow.cs" />
<Compile Include="Graphics\OpenGL\GL.cs" />
<Compile Include="IGameWindow.cs" />
<Compile Include="INativeWindow.cs" />
<Compile Include="Interop.cs" />
<Compile Include="KeyPressEventArgs.cs" />
<Compile Include="MemUtils.cs" />
<Compile Include="NativeWindow.cs" />
<Compile Include="Graphics\ColorFormat.cs" />
<Compile Include="Graphics\GraphicsContextBase.cs" />
<Compile Include="Graphics\GraphicsContextException.cs" />
<Compile Include="Graphics\GraphicsMode.cs" />
<Compile Include="Graphics\GraphicsModeException.cs" />
<Compile Include="Graphics\IGraphicsContext.cs" />
<Compile Include="Graphics\OpenGL\GLEnums.cs" />
<Compile Include="Graphics\OpenGL\GLHelper.cs" />
<Compile Include="Input\Key.cs" />
<Compile Include="Input\KeyboardDevice.cs" />
<Compile Include="Input\MouseButton.cs" />
<Compile Include="Input\MouseDevice.cs" />
<Compile Include="Math\Matrix4.cs" />
<Compile Include="Math\Vector2.cs" />
<Compile Include="Math\Vector3.cs" />
<Compile Include="Math\Vector4.cs" />
<Compile Include="Platform\Configuration.cs" />
<Compile Include="Platform\IPlatformFactory.cs" />
<Compile Include="Platform\IWindowInfo.cs" />
<Compile Include="Platform\MacOS\AglContext.cs" />
<Compile Include="Platform\MacOS\Application.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\Agl.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\CarbonAPI.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\CoreFoundation.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\MacOSKeys.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\QuartzDisplayServicesAPI.cs" />
<Compile Include="Platform\MacOS\CarbonGLNative.cs" />
<Compile Include="Platform\MacOS\CarbonWindowInfo.cs" />
<Compile Include="Platform\MacOS\MacOSException.cs" />
<Compile Include="Platform\MacOS\MacOSKeyMap.cs" />
<Compile Include="Platform\MacOS\QuartzDisplayDevice.cs" />
<Compile Include="Platform\PlatformException.cs" />
<Compile Include="Platform\Windows\API.cs" />
<Compile Include="Platform\Windows\Wgl.cs" />
<Compile Include="Platform\Windows\WinDisplayDevice.cs" />
<Compile Include="Platform\Windows\WinGLContext.cs" />
<Compile Include="Platform\Windows\WinGLNative.cs" />
<Compile Include="Platform\Windows\WinKeyMap.cs" />
<Compile Include="Platform\Windows\WinWindowInfo.cs" />
<Compile Include="Platform\NullContext.cs" />
<Compile Include="Platform\X11\API.cs" />
<Compile Include="Platform\X11\Functions.cs" />
<Compile Include="Platform\X11\Glx.cs" />
<Compile Include="Platform\X11\Structs.cs" />
<Compile Include="Platform\X11\X11DisplayDevice.cs" />
<Compile Include="Platform\X11\X11GLContext.cs" />
<Compile Include="Platform\X11\X11GLNative.cs" />
<Compile Include="Platform\X11\X11KeyMap.cs" />
<Compile Include="Platform\X11\X11WindowInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SharpDX.Direct3D\AdapterDetails.cs" />
<Compile Include="SharpDX.Direct3D\Device.cs" />
<Compile Include="SharpDX.Direct3D\Direct3D.cs" />
<Compile Include="SharpDX.Direct3D\Enumerations.cs" />
<Compile Include="SharpDX.Direct3D\PresentParameters.cs" />
<Compile Include="SharpDX.Direct3D\Resources.cs" />
<Compile Include="SharpDX.Direct3D\Structures.cs" />
<Compile Include="SharpDX\ComObject.cs" />
<Compile Include="SharpDX\Raw.cs" />
<Compile Include="SharpDX\Result.cs" />
<Compile Include="WindowState.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Graphics" />
<Folder Include="Graphics\OpenGL" />
<Folder Include="Input" />
<Folder Include="Math" />
<Folder Include="Platform" />
<Folder Include="Platform\MacOS" />
<Folder Include="Platform\MacOS\CarbonBindings" />
<Folder Include="Platform\Windows" />
<Folder Include="Platform\X11" />
<Folder Include="Properties" />
<Folder Include="SharpDX" />
<Folder Include="SharpDX.Direct3D" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InteropPatcher\InteropPatcher.csproj">
<Project>{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}</Project>
<Name>InteropPatcher</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<!-- This actually rewrites the calli and fixed code.-->
<Target Name="AfterBuild">
<Exec Command="$(OutputPath)InteropPatcher.exe $(OutDir)OpenTK.dll" />
<!--Copy back *.dll from bin/Debug|Release to obj/Debug/Release directory-->
<Copy SourceFiles="@(MainAssembly)" DestinationFolder="$(IntermediateOutputPath)" SkipUnchangedFiles="true" />
<!-- Copy back *.pdb from bin/Debug|Release to obj/Debug/Release directory-->
<Copy SourceFiles="@(_DebugSymbolsOutputPath)" DestinationFiles="@(_DebugSymbolsIntermediatePath)" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true'" />
</Target>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="2.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{35FEE071-2DE6-48A1-9343-B5C1F202A12B}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>OpenTK</RootNamespace>
<AssemblyName>OpenTK</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<BaseAddress>4194304</BaseAddress>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
<OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\output\release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="BindingsBase.cs" />
<Compile Include="Debug.cs" />
<Compile Include="DisplayDevice.cs" />
<Compile Include="FrameEventArgs.cs" />
<Compile Include="GameWindow.cs" />
<Compile Include="Graphics\OpenGL\GL.cs" />
<Compile Include="IGameWindow.cs" />
<Compile Include="INativeWindow.cs" />
<Compile Include="Interop.cs" />
<Compile Include="KeyPressEventArgs.cs" />
<Compile Include="MemUtils.cs" />
<Compile Include="NativeWindow.cs" />
<Compile Include="Graphics\ColorFormat.cs" />
<Compile Include="Graphics\GraphicsContextBase.cs" />
<Compile Include="Graphics\GraphicsContextException.cs" />
<Compile Include="Graphics\GraphicsMode.cs" />
<Compile Include="Graphics\GraphicsModeException.cs" />
<Compile Include="Graphics\IGraphicsContext.cs" />
<Compile Include="Graphics\OpenGL\GLEnums.cs" />
<Compile Include="Graphics\OpenGL\GLHelper.cs" />
<Compile Include="Input\Key.cs" />
<Compile Include="Input\KeyboardDevice.cs" />
<Compile Include="Input\MouseButton.cs" />
<Compile Include="Input\MouseDevice.cs" />
<Compile Include="Math\Matrix4.cs" />
<Compile Include="Math\Vector2.cs" />
<Compile Include="Math\Vector3.cs" />
<Compile Include="Math\Vector4.cs" />
<Compile Include="Platform\Configuration.cs" />
<Compile Include="Platform\IPlatformFactory.cs" />
<Compile Include="Platform\IWindowInfo.cs" />
<Compile Include="Platform\MacOS\AglContext.cs" />
<Compile Include="Platform\MacOS\Application.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\Agl.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\CarbonAPI.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\CoreFoundation.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\MacOSKeys.cs" />
<Compile Include="Platform\MacOS\CarbonBindings\QuartzDisplayServicesAPI.cs" />
<Compile Include="Platform\MacOS\CarbonGLNative.cs" />
<Compile Include="Platform\MacOS\CarbonWindowInfo.cs" />
<Compile Include="Platform\MacOS\MacOSException.cs" />
<Compile Include="Platform\MacOS\MacOSKeyMap.cs" />
<Compile Include="Platform\MacOS\QuartzDisplayDevice.cs" />
<Compile Include="Platform\PlatformException.cs" />
<Compile Include="Platform\Windows\API.cs" />
<Compile Include="Platform\Windows\Wgl.cs" />
<Compile Include="Platform\Windows\WinDisplayDevice.cs" />
<Compile Include="Platform\Windows\WinGLContext.cs" />
<Compile Include="Platform\Windows\WinGLNative.cs" />
<Compile Include="Platform\Windows\WinKeyMap.cs" />
<Compile Include="Platform\Windows\WinWindowInfo.cs" />
<Compile Include="Platform\NullContext.cs" />
<Compile Include="Platform\X11\API.cs" />
<Compile Include="Platform\X11\Functions.cs" />
<Compile Include="Platform\X11\Glx.cs" />
<Compile Include="Platform\X11\Structs.cs" />
<Compile Include="Platform\X11\X11DisplayDevice.cs" />
<Compile Include="Platform\X11\X11GLContext.cs" />
<Compile Include="Platform\X11\X11GLNative.cs" />
<Compile Include="Platform\X11\X11KeyMap.cs" />
<Compile Include="Platform\X11\X11WindowInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SharpDX.Direct3D\AdapterDetails.cs" />
<Compile Include="SharpDX.Direct3D\Device.cs" />
<Compile Include="SharpDX.Direct3D\Direct3D.cs" />
<Compile Include="SharpDX.Direct3D\Enumerations.cs" />
<Compile Include="SharpDX.Direct3D\Resources.cs" />
<Compile Include="SharpDX.Direct3D\Structures.cs" />
<Compile Include="SharpDX\ComObject.cs" />
<Compile Include="SharpDX\Raw.cs" />
<Compile Include="SharpDX\Result.cs" />
<Compile Include="WindowState.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Graphics" />
<Folder Include="Graphics\OpenGL" />
<Folder Include="Input" />
<Folder Include="Math" />
<Folder Include="Platform" />
<Folder Include="Platform\MacOS" />
<Folder Include="Platform\MacOS\CarbonBindings" />
<Folder Include="Platform\Windows" />
<Folder Include="Platform\X11" />
<Folder Include="Properties" />
<Folder Include="SharpDX" />
<Folder Include="SharpDX.Direct3D" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InteropPatcher\InteropPatcher.csproj">
<Project>{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}</Project>
<Name>InteropPatcher</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<!-- This actually rewrites the calli and fixed code.-->
<Target Name="AfterBuild">
<Exec Command="$(OutputPath)InteropPatcher.exe $(OutDir)OpenTK.dll" />
<!--Copy back *.dll from bin/Debug|Release to obj/Debug/Release directory-->
<Copy SourceFiles="@(MainAssembly)" DestinationFolder="$(IntermediateOutputPath)" SkipUnchangedFiles="true" />
<!-- Copy back *.pdb from bin/Debug|Release to obj/Debug/Release directory-->
<Copy SourceFiles="@(_DebugSymbolsOutputPath)" DestinationFiles="@(_DebugSymbolsIntermediatePath)" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true'" />
</Target>
</Project>

View File

@ -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);
}
/// <summary> Gets the adapter ordinal. </summary>
public int Adapter;
/// <summary> Gets the details. </summary>
public AdapterDetails Details;
}

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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 {
/// <summary> Gets the number of bytes per row. </summary>
public int Pitch;
/// <summary> Pointer to the data. </summary>
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 {
/// <summary> Gets the number of bytes per row. </summary>
public int Pitch;
/// <summary> Pointer to the data. </summary>
public IntPtr DataPointer;
}
[StructLayout(LayoutKind.Sequential)]
public struct D3DRect {
public int Left;
public int Top;
public int Right;
public int Bottom;
}
}

View File

@ -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 );
}
}
}

View File

@ -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);