mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 09:46:53 +00:00
Moved OpenTK.GLControl to its own project.
This commit is contained in:
parent
073109c8c7
commit
c6516c2255
77
Source/GLControl/CarbonGLControl.cs
Normal file
77
Source/GLControl/CarbonGLControl.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Platform;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
class CarbonGLControl : IGLControl
|
||||
{
|
||||
GraphicsMode mode;
|
||||
Control control;
|
||||
|
||||
internal CarbonGLControl(GraphicsMode mode, Control owner)
|
||||
{
|
||||
this.mode = mode;
|
||||
this.control = owner;
|
||||
}
|
||||
|
||||
#region IGLControl Members
|
||||
|
||||
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(mode, WindowInfo, major, minor, flags);
|
||||
}
|
||||
|
||||
// TODO: Fix this
|
||||
bool lastIsIdle = false;
|
||||
public bool IsIdle
|
||||
{
|
||||
get
|
||||
{
|
||||
lastIsIdle = !lastIsIdle;
|
||||
return lastIsIdle;
|
||||
}
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Utilities.CreateWindowInfo(mode, control.Handle, true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted.
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,15 +25,17 @@
|
|||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Platform;
|
||||
|
||||
namespace OpenTK.Platform.Dummy
|
||||
namespace OpenTK
|
||||
{
|
||||
class DummyGLControl : IGLControl
|
||||
{
|
||||
#region IGLControl Members
|
||||
|
||||
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(null, null);
|
||||
}
|
||||
|
@ -45,7 +47,7 @@ namespace OpenTK.Platform.Dummy
|
|||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get { return new DummyWindowInfo(); }
|
||||
get { return Utilities.CreateWindowInfo(null, IntPtr.Zero, true); }
|
||||
}
|
||||
|
||||
#endregion
|
|
@ -1,14 +1,34 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
@ -16,7 +36,7 @@ using System.Windows.Forms;
|
|||
|
||||
using OpenTK.Platform;
|
||||
using OpenTK.Graphics;
|
||||
using System.Diagnostics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
|
@ -78,9 +98,9 @@ namespace OpenTK
|
|||
// to clean up this hacky code. The best option is to do this along with multisampling
|
||||
// support.
|
||||
if (DesignMode)
|
||||
implementation = new Platform.Dummy.DummyGLControl();
|
||||
implementation = new DummyGLControl();
|
||||
else
|
||||
implementation = Platform.Factory.Default.CreateGLControl(mode, this);
|
||||
implementation = new GLControlFactory().CreateGLControl(mode, this);
|
||||
|
||||
this.CreateControl();
|
||||
}
|
||||
|
@ -269,19 +289,18 @@ namespace OpenTK
|
|||
/// <exception cref="OpenTK.Graphics.GraphicsContextException">
|
||||
/// Occurs when no OpenTK.Graphics.GraphicsContext is current in the calling thread.
|
||||
/// </exception>
|
||||
[Obsolete]
|
||||
[Obsolete("This method will be removed. Please provide your own code to capture framebuffer contents.")]
|
||||
public Bitmap GrabScreenshot()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
|
||||
//System.Drawing.Imaging.BitmapData data =
|
||||
// bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
|
||||
// System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
//GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
|
||||
// data.Scan0);
|
||||
//bmp.UnlockBits(data);
|
||||
//bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
//return bmp;
|
||||
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
|
||||
System.Drawing.Imaging.BitmapData data =
|
||||
bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
|
||||
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
|
||||
data.Scan0);
|
||||
bmp.UnlockBits(data);
|
||||
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
#endregion
|
47
Source/GLControl/GLControlFactory.cs
Normal file
47
Source/GLControl/GLControlFactory.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
// Constructs GLControls.
|
||||
class GLControlFactory
|
||||
{
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, Control control)
|
||||
{
|
||||
if (Configuration.RunningOnWindows) return new WinGLControl(mode, control);
|
||||
else if (Configuration.RunningOnX11) return new X11GLControl(mode, control);
|
||||
else if (Configuration.RunningOnMacOS) return new CarbonGLControl(mode, control);
|
||||
else throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
43
Source/GLControl/IGLControl.cs
Normal file
43
Source/GLControl/IGLControl.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Platform;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
internal interface IGLControl
|
||||
{
|
||||
IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags);
|
||||
bool IsIdle { get; }
|
||||
IWindowInfo WindowInfo { get; }
|
||||
}
|
||||
}
|
182
Source/GLControl/OpenTK.GLControl.csproj
Normal file
182
Source/GLControl/OpenTK.GLControl.csproj
Normal file
|
@ -0,0 +1,182 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{8CC9D641-0000-0000-0000-000000000000}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>OpenTK.GLControl</AssemblyName>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>
|
||||
</AppDesignerFolder>
|
||||
<RootNamespace>OpenTK.GLControl</RootNamespace>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
||||
<DocumentationFile>OpenTK.GLControl.xml</DocumentationFile>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>..\..\Binaries\Debug\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE;</DefineConstants>
|
||||
<DocumentationFile>OpenTK.GLControl.xml</DocumentationFile>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>..\..\Binaries\Release\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.Xml</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenTK\OpenTK.csproj">
|
||||
<Name>OpenTK</Name>
|
||||
<Project>{2C035F6B-0000-0000-0000-000000000000}</Project>
|
||||
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CarbonGLControl.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DummyGLControl.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GLControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GLControl.Designer.cs">
|
||||
<DependentUpon>GLControl.cs</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GLControlFactory.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IGLControl.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WinGLControl.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="X11GLControl.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
38
Source/GLControl/Properties/AssemblyInfo.cs
Normal file
38
Source/GLControl/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenTK.GLControl")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("OpenTK.GLControl")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5414b90b-d7be-4382-b0e1-f07ce154f7f7")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly: System.CLSCompliant(true)]
|
158
Source/GLControl/WinGLControl.cs
Normal file
158
Source/GLControl/WinGLControl.cs
Normal file
|
@ -0,0 +1,158 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Platform;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
class WinGLControl : IGLControl
|
||||
{
|
||||
#region P/Invoke declarations
|
||||
|
||||
#region Message
|
||||
|
||||
struct MSG
|
||||
{
|
||||
public IntPtr HWnd;
|
||||
public uint Message;
|
||||
public IntPtr WParam;
|
||||
public IntPtr LParam;
|
||||
public uint Time;
|
||||
public POINT Point;
|
||||
//internal object RefObject;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("msg=0x{0:x} ({1}) hwnd=0x{2:x} wparam=0x{3:x} lparam=0x{4:x} pt=0x{5:x}", (int)Message, Message.ToString(), HWnd.ToInt32(), WParam.ToInt32(), LParam.ToInt32(), Point);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Point
|
||||
|
||||
struct POINT
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
|
||||
public POINT(int x, int y)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
|
||||
public System.Drawing.Point ToPoint()
|
||||
{
|
||||
return new System.Drawing.Point(X, Y);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Point {" + X.ToString() + ", " + Y.ToString() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PeekMessage
|
||||
|
||||
[System.Security.SuppressUnmanagedCodeSecurity]
|
||||
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
||||
static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
|
||||
|
||||
#endregion
|
||||
|
||||
#region
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
MSG msg = new MSG();
|
||||
IWindowInfo window_info;
|
||||
GraphicsMode mode;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public WinGLControl(GraphicsMode mode, Control control)
|
||||
{
|
||||
this.mode = mode;
|
||||
|
||||
control.HandleCreated += delegate(object sender, EventArgs e)
|
||||
{
|
||||
if (window_info != null)
|
||||
window_info.Dispose();
|
||||
window_info = Utilities.CreateWindowInfo(mode, ((Control)sender).Handle, true);
|
||||
};
|
||||
|
||||
control.HandleDestroyed += delegate(object sender, EventArgs e)
|
||||
{
|
||||
if (window_info != null)
|
||||
{
|
||||
window_info.Dispose();
|
||||
window_info = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IGLControl Members
|
||||
|
||||
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(mode, window_info, major, minor, flags);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
// This method forces the creation of the control. Beware of this side-effect!
|
||||
return window_info;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
67
Source/GLControl/X11GLControl.cs
Normal file
67
Source/GLControl/X11GLControl.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Platform;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
class X11GLControl : IGLControl
|
||||
{
|
||||
#region P/Invokes
|
||||
|
||||
[DllImport("libX11")]
|
||||
public extern static int XPending(IntPtr diplay);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
GraphicsMode mode;
|
||||
Control control;
|
||||
IWindowInfo window_info;
|
||||
|
||||
#endregion
|
||||
|
||||
internal X11GLControl(GraphicsMode mode, Control control)
|
||||
{
|
||||
this.mode = mode;
|
||||
this.control = control;
|
||||
|
||||
window_info = Utilities.CreateWindowInfo(mode, control.Handle, true);
|
||||
}
|
||||
|
||||
#region IGLControl Members
|
||||
|
||||
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(mode, this.WindowInfo, major, minor, flags);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return XPending(((Platform.X11.X11WindowInfo)window_info).Display) == 0; }
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return window_info;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -118,18 +118,6 @@ namespace OpenTK.Platform.Egl
|
|||
}
|
||||
}
|
||||
|
||||
// Todo: implement this!
|
||||
public bool ErrorChecking
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IGraphicsContextInternal Members
|
||||
|
|
|
@ -89,11 +89,6 @@ namespace OpenTK.Platform
|
|||
return default_implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
return default_implementation.CreateGLControl(mode, owner);
|
||||
}
|
||||
|
||||
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
return default_implementation.CreateDisplayDeviceDriver();
|
||||
|
@ -134,11 +129,6 @@ namespace OpenTK.Platform
|
|||
throw new PlatformNotSupportedException(error_string);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
throw new PlatformNotSupportedException(error_string);
|
||||
}
|
||||
|
||||
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
throw new PlatformNotSupportedException(error_string);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
internal interface IGLControl
|
||||
{
|
||||
GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags);
|
||||
bool IsIdle { get; }
|
||||
IWindowInfo WindowInfo { get; }
|
||||
}
|
||||
}
|
|
@ -37,8 +37,6 @@ namespace OpenTK.Platform
|
|||
{
|
||||
INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
|
||||
|
||||
IGLControl CreateGLControl(GraphicsMode mode, GLControl owner);
|
||||
|
||||
IDisplayDeviceDriver CreateDisplayDeviceDriver();
|
||||
|
||||
IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags);
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace OpenTK.Platform.MacOS
|
|||
windowPort = API.GetWindowPort(carbonWindow.WindowRef);
|
||||
return windowPort;
|
||||
}
|
||||
public void Update(IWindowInfo window)
|
||||
public override void Update(IWindowInfo window)
|
||||
{
|
||||
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenTK.Platform.MacOS
|
||||
{
|
||||
using Graphics;
|
||||
|
||||
class CarbonGLControl : IGLControl
|
||||
{
|
||||
GraphicsMode mode;
|
||||
Control control;
|
||||
|
||||
internal CarbonGLControl(GraphicsMode mode, Control owner)
|
||||
{
|
||||
this.mode = mode;
|
||||
this.control = owner;
|
||||
}
|
||||
|
||||
#region IGLControl Members
|
||||
|
||||
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(mode, WindowInfo, major, minor, flags);
|
||||
}
|
||||
|
||||
// TODO: Fix this
|
||||
bool lastIsIdle = false;
|
||||
public bool IsIdle
|
||||
{
|
||||
get
|
||||
{
|
||||
lastIsIdle = !lastIsIdle;
|
||||
return lastIsIdle;
|
||||
}
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
control.CreateControl();
|
||||
return new CarbonWindowInfo(control.Handle, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -42,11 +42,6 @@ namespace OpenTK.Platform.MacOS
|
|||
return new CarbonGLNative(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
return new CarbonGLControl(mode, owner);
|
||||
}
|
||||
|
||||
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
return new QuartzDisplayDeviceDriver();
|
||||
|
|
|
@ -263,7 +263,7 @@ namespace OpenTK.Platform
|
|||
public static void CreateGraphicsContext(GraphicsMode mode, IntPtr cntrlHandle,
|
||||
out IGraphicsContext context, out IWindowInfo info)
|
||||
{
|
||||
info = CreateWindowInfo(mode, cntrlHandle);
|
||||
info = CreateWindowInfo(mode, cntrlHandle, true);
|
||||
|
||||
context = new GraphicsContext(mode, info);
|
||||
context.MakeCurrent(info);
|
||||
|
@ -273,30 +273,19 @@ namespace OpenTK.Platform
|
|||
|
||||
#region --- CreateWindowInfo ---
|
||||
|
||||
/// <summary>
|
||||
/// Creates an object which implements the IWindowInfo interface for the platform
|
||||
/// currently running on. This will create a handle for the control, so it is not
|
||||
/// recommended that this be called in the constructor of a custom control.
|
||||
/// </summary>
|
||||
/// <param name="mode">The desired GraphicsMode for this window.</param>
|
||||
/// <param name="cntrl">A <see cref="System.Windows.Forms.Control"/> to get the IWindowInfo from.</param>
|
||||
/// <returns></returns>
|
||||
public static IWindowInfo CreateWindowInfo(GraphicsMode mode, Control cntrl)
|
||||
{
|
||||
return CreateWindowInfo(mode, cntrl.Handle);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an object which implements the IWindowInfo interface for the platform
|
||||
/// currently running on.
|
||||
/// </summary>
|
||||
/// <param name="mode">The desired GraphicsMode for this window.</param>
|
||||
/// <param name="controlHandle">The handle to the control, obtained from Control.Handle.</param>
|
||||
/// <param name="isControl">Set to true if this is a Windows.Forms control.</param>
|
||||
/// <returns></returns>
|
||||
public static IWindowInfo CreateWindowInfo(GraphicsMode mode, IntPtr controlHandle)
|
||||
public static IWindowInfo CreateWindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
|
||||
{
|
||||
if (Configuration.RunningOnWindows) return CreateWinWindowInfo(controlHandle);
|
||||
else if (Configuration.RunningOnX11) return CreateX11WindowInfo(mode, controlHandle);
|
||||
else if (Configuration.RunningOnMacOS) return CreateMacOSCarbonWindowInfo(controlHandle);
|
||||
else if (Configuration.RunningOnX11) return CreateX11WindowInfo(mode, controlHandle, isControl);
|
||||
else if (Configuration.RunningOnMacOS) return CreateMacOSCarbonWindowInfo(controlHandle, isControl);
|
||||
else
|
||||
throw new PlatformNotSupportedException("Refer to http://www.opentk.com for more information.");
|
||||
}
|
||||
|
@ -305,16 +294,17 @@ namespace OpenTK.Platform
|
|||
|
||||
#region --- X11 Platform-specific implementation ---
|
||||
|
||||
private static IWindowInfo CreateX11WindowInfo(GraphicsMode mode, IntPtr controlHandle)
|
||||
private static IWindowInfo CreateX11WindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
|
||||
{
|
||||
Platform.X11.X11WindowInfo window = new OpenTK.Platform.X11.X11WindowInfo();
|
||||
window.WindowHandle = controlHandle;
|
||||
|
||||
if (isControl)
|
||||
{
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||
|
||||
window.WindowHandle = controlHandle;
|
||||
|
||||
// get the required handles from the X11 API.
|
||||
window.Display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||
window.RootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
||||
|
@ -336,6 +326,10 @@ namespace OpenTK.Platform
|
|||
SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.Visual);
|
||||
SetStaticFieldValue(xplatui, "CustomColormap",
|
||||
Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
@ -351,9 +345,9 @@ namespace OpenTK.Platform
|
|||
#endregion
|
||||
#region --- Mac OS X Platform-specific implementation ---
|
||||
|
||||
private static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr controlHandle)
|
||||
private static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr controlHandle, bool isControl)
|
||||
{
|
||||
return new OpenTK.Platform.MacOS.CarbonWindowInfo(controlHandle, false, true);
|
||||
return new OpenTK.Platform.MacOS.CarbonWindowInfo(controlHandle, false, isControl);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -43,11 +43,6 @@ namespace OpenTK.Platform.Windows
|
|||
return new WinGLNative(x, y, width, height, title, options, device);
|
||||
}
|
||||
|
||||
public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
return new WinGLControl(mode, owner);
|
||||
}
|
||||
|
||||
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
return new WinDisplayDeviceDriver();
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform.Windows
|
||||
{
|
||||
class WinGLControl : IGLControl
|
||||
{
|
||||
MSG msg = new MSG();
|
||||
GraphicsMode mode;
|
||||
Control control;
|
||||
WinWindowInfo window_info;
|
||||
|
||||
internal WinGLControl(GraphicsMode mode, Control control)
|
||||
{
|
||||
this.mode = mode;
|
||||
this.control = control;
|
||||
this.control.HandleCreated += delegate(object sender, EventArgs e)
|
||||
{
|
||||
if (window_info != null)
|
||||
window_info.Dispose();
|
||||
window_info = new WinWindowInfo(this.control.Handle, null);
|
||||
};
|
||||
this.control.HandleDestroyed += delegate(object sender, EventArgs e)
|
||||
{
|
||||
if (window_info != null)
|
||||
{
|
||||
window_info.Dispose();
|
||||
window_info = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#region --- IGLControl Members ---
|
||||
|
||||
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
// Make sure the Control exists before create the context.
|
||||
if (window_info == null)
|
||||
window_info = new WinWindowInfo(control.Handle, null);
|
||||
|
||||
return new GraphicsContext(mode, window_info, major, minor, flags);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return !OpenTK.Platform.Windows.Functions.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
// This method forces the creation of the control. Beware of this side-effect!
|
||||
return window_info;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -15,11 +15,6 @@ namespace OpenTK.Platform.X11
|
|||
return new X11GLNative(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
return new X11GLControl(mode, owner);
|
||||
}
|
||||
|
||||
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
return new X11XrandrDisplayDevice();
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform.X11
|
||||
{
|
||||
class X11GLControl : IGLControl
|
||||
{
|
||||
GraphicsMode mode;
|
||||
Control control;
|
||||
IntPtr display;
|
||||
|
||||
internal X11GLControl(GraphicsMode mode, Control control)
|
||||
{
|
||||
if (!mode.Index.HasValue)
|
||||
throw new GraphicsModeException("Invalid GraphicsMode.");
|
||||
|
||||
this.mode = mode;
|
||||
this.control = control;
|
||||
|
||||
X11WindowInfo window = (X11WindowInfo)this.WindowInfo;
|
||||
XVisualInfo info = new XVisualInfo();
|
||||
|
||||
info.VisualID = mode.Index.Value;
|
||||
int dummy;
|
||||
window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(
|
||||
Functions.XGetVisualInfo(window.Display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo));
|
||||
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
xplatui.GetField("CustomVisual", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
||||
.SetValue(null, window.VisualInfo.Visual);
|
||||
xplatui.GetField("CustomColormap", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
||||
.SetValue(null, Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
|
||||
}
|
||||
|
||||
#region --- IGLControl Members ---
|
||||
|
||||
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new GraphicsContext(mode, this.WindowInfo, major, minor, flags);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return Functions.XPending(display) == 0; }
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||
|
||||
X11WindowInfo window = new X11WindowInfo();
|
||||
|
||||
if (control.IsHandleCreated)
|
||||
window.WindowHandle = control.Handle;
|
||||
|
||||
display =
|
||||
window.Display = (IntPtr)xplatui.GetField("DisplayHandle",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||
window.RootWindow = (IntPtr)xplatui.GetField("RootWindow",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||
window.Screen = (int)xplatui.GetField("ScreenNo",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||
|
||||
if (control.IsHandleCreated)
|
||||
window.WindowHandle = control.Handle;
|
||||
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
63
Source/OpenTK/Properties/Resources.Designer.cs
generated
Normal file
63
Source/OpenTK/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4918
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace OpenTK.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenTK.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Source/OpenTK/Properties/Resources.resx
Normal file
120
Source/OpenTK/Properties/Resources.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in a new issue