Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Synced gl4 branch with trunk.

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/branches/gl4@3017 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information...
commit 838e83887c4733e4a742132c0f63e85462aa3694 2 parents fca9b2b + eed2de1
the_fiddler authored
Showing with 7,995 additions and 2,982 deletions.
  1. +20 −0 QuickStart.sln
  2. +13 −29 Source/Bind/Generator.Bind.csproj
  3. +29 −1 Source/Build.UpdateVersion/Build.UpdateVersion.csproj
  4. +82 −8 Source/Build.UpdateVersion/Program.cs
  5. +0 −2  Source/Compatibility/Audio/OpenAL/AL/EffectsExtensionPresets.cs
  6. +0 −5 Source/Compatibility/Graphics/GL/GLHelper.cs
  7. +20 −7 Source/Compatibility/OpenTK.Compatibility.csproj
  8. +13 −29 Source/Converter/Generator.Convert.csproj
  9. +63 −38 Source/Examples/ExampleBrowser.cs
  10. +204 −0 Source/Examples/OpenGL/1.x/Anaglyph.cs
  11. BIN  Source/Examples/OpenGL/1.x/Anaglyph.rtf
  12. +26 −36 Source/Examples/OpenGL/1.x/FramebufferObject.cs
  13. BIN  Source/Examples/OpenGL/1.x/FramebufferObject.rtf
  14. +438 −0 Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs
  15. BIN  Source/Examples/OpenGL/1.x/OpenGLDiagnostics.rtf
  16. +2 −2 Source/Examples/OpenGL/1.x/VBODynamic.cs
  17. +6 −6 Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs
  18. +2 −2 Source/Examples/OpenGL/2.x/SimpleGLSL.cs
  19. +11 −1 Source/Examples/OpenTK.Examples.csproj
  20. +20 −1 Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs
  21. +48 −46 Source/Examples/OpenTK/Test/BlittableValueTypes.cs
  22. +88 −7 Source/Examples/OpenTK/Test/GameWindowStates.cs
  23. +5 −1 Source/GLControl/OpenTK.GLControl.csproj
  24. +52 −6 Source/OpenTK/Audio/OpenAL/AL/AL.cs
  25. +66 −30 Source/OpenTK/DisplayDevice.cs
  26. +72 −0 Source/OpenTK/DisplayIndex.cs
  27. +17 −8 Source/OpenTK/GameWindow.cs
  28. +101 −11 Source/OpenTK/Graphics/ColorFormat.cs
  29. +58 −6 Source/OpenTK/Graphics/GraphicsContext.cs
  30. +2 −2 Source/OpenTK/Graphics/GraphicsMode.cs
  31. +63 −0 Source/OpenTK/Graphics/GraphicsModeComparer.cs
  32. +1 −1  Source/OpenTK/Graphics/OpenGL/GLHelper.cs
  33. +20 −4 Source/OpenTK/INativeWindow.cs
  34. +46 −0 Source/OpenTK/Input/ButtonState.cs
  35. +10 −0 Source/OpenTK/Input/IGamePadDriver.cs
  36. +41 −0 Source/OpenTK/Input/IInputDriver2.cs
  37. +1 −0  Source/OpenTK/Input/IJoystickDriver.cs
  38. +1 −0  Source/OpenTK/Input/IKeyboardDriver.cs
  39. +31 −0 Source/OpenTK/Input/IKeyboardDriver2.cs
  40. +1 −0  Source/OpenTK/Input/IMouseDriver.cs
  41. +40 −0 Source/OpenTK/Input/IMouseDriver2.cs
  42. +0 −126 Source/OpenTK/Input/InputDriver.cs
  43. +41 −18 Source/OpenTK/Input/Keyboard.cs
  44. +199 −19 Source/OpenTK/Input/KeyboardState.cs
  45. +39 −10 Source/OpenTK/Input/Mouse.cs
  46. +309 −5 Source/OpenTK/Input/MouseState.cs
  47. +49 −0 Source/OpenTK/IntPtrEqualityComparer.cs
  48. +2 −2 Source/OpenTK/Math/Box2.cs
  49. +0 −2  Source/OpenTK/Math/Matrix4.cs
  50. +0 −2  Source/OpenTK/Math/Matrix4d.cs
  51. +10 −0 Source/OpenTK/Math/Vector2.cs
  52. +10 −0 Source/OpenTK/Math/Vector2d.cs
  53. +20 −0 Source/OpenTK/Math/Vector2h.cs
  54. +12 −1 Source/OpenTK/Math/Vector3.cs
  55. +14 −3 Source/OpenTK/Math/Vector3d.cs
  56. +22 −0 Source/OpenTK/Math/Vector3h.cs
  57. +14 −0 Source/OpenTK/Math/Vector4.cs
  58. +14 −0 Source/OpenTK/Math/Vector4d.cs
  59. +24 −0 Source/OpenTK/Math/Vector4h.cs
  60. +96 −28 Source/OpenTK/NativeWindow.cs
  61. +23 −10 Source/OpenTK/OpenTK.csproj
  62. +53 −0 Source/OpenTK/Platform/DisplayDeviceBase.cs
  63. +12 −2 Source/OpenTK/Platform/Factory.cs
  64. +26 −6 Source/OpenTK/Platform/IDisplayDeviceDriver.cs
  65. +3 −1 Source/OpenTK/Platform/IPlatformFactory.cs
  66. +218 −209 Source/OpenTK/Platform/MacOS/AglContext.cs
  67. +76 −70 Source/OpenTK/Platform/MacOS/Application.cs
  68. +26 −5 Source/OpenTK/Platform/MacOS/CarbonBindings/Agl.cs
  69. +49 −6 Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs
  70. +49 −0 Source/OpenTK/Platform/MacOS/CarbonBindings/CoreFoundation.cs
  71. +27 −0 Source/OpenTK/Platform/MacOS/CarbonBindings/MacOSKeys.cs
  72. +61 −1 Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs
  73. +27 −0 Source/OpenTK/Platform/MacOS/CarbonBindings/SpeechChannel.cs
  74. +552 −583 Source/OpenTK/Platform/MacOS/CarbonGLNative.cs
  75. +52 −1 Source/OpenTK/Platform/MacOS/CarbonInput.cs
  76. +19 −20 Source/OpenTK/Platform/MacOS/CarbonWindowInfo.cs
  77. +43 −20 Source/OpenTK/Platform/MacOS/EventInfo.cs
  78. +937 −0 Source/OpenTK/Platform/MacOS/HIDInput.cs
  79. +28 −0 Source/OpenTK/Platform/MacOS/MacOSException.cs
  80. +15 −3 Source/OpenTK/Platform/MacOS/MacOSFactory.cs
  81. +139 −7 Source/OpenTK/Platform/MacOS/MacOSGraphicsMode.cs
  82. +31 −2 Source/OpenTK/Platform/MacOS/MacOSKeyMap.cs
  83. +86 −75 Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs
  84. +0 −1  Source/OpenTK/Platform/Utilities.cs
  85. +116 −74 Source/OpenTK/Platform/Windows/API.cs
  86. +111 −233 Source/OpenTK/Platform/Windows/WMInput.cs
  87. +9 −4 Source/OpenTK/Platform/Windows/WglHelper.cs
  88. +99 −54 Source/OpenTK/Platform/Windows/WinDisplayDevice.cs
  89. +31 −7 Source/OpenTK/Platform/Windows/WinFactory.cs
  90. +111 −95 Source/OpenTK/Platform/Windows/WinGLContext.cs
  91. +199 −125 Source/OpenTK/Platform/Windows/WinGLNative.cs
  92. +138 −137 Source/OpenTK/Platform/Windows/WinGraphicsMode.cs
  93. +203 −0 Source/OpenTK/Platform/Windows/WinInputBase.cs
  94. +95 −86 Source/OpenTK/Platform/Windows/WinKeyMap.cs
  95. +1 −1  Source/OpenTK/Platform/Windows/WinMMJoystick.cs
  96. +107 −175 Source/OpenTK/Platform/Windows/WinRawInput.cs
  97. +226 −191 Source/OpenTK/Platform/Windows/WinRawKeyboard.cs
  98. +203 −174 Source/OpenTK/Platform/Windows/WinRawMouse.cs
  99. +109 −1 Source/OpenTK/Platform/X11/API.cs
  100. +83 −4 Source/OpenTK/Platform/X11/Functions.cs
  101. +195 −0 Source/OpenTK/Platform/X11/Structs.cs
  102. +84 −31 Source/OpenTK/Platform/X11/X11DisplayDevice.cs
  103. +10 −2 Source/OpenTK/Platform/X11/X11Factory.cs
  104. +135 −61 Source/OpenTK/Platform/X11/X11GLNative.cs
  105. +1 −0  Source/OpenTK/Platform/X11/X11KeyMap.cs
  106. +125 −0 Source/OpenTK/Platform/X11/X11Keyboard.cs
  107. +152 −0 Source/OpenTK/Platform/X11/X11Mouse.cs
  108. +263 −0 Source/OpenTK/Platform/X11/XI2Mouse.cs
  109. +49 −0 Source/QuickStart/QuickStart.csproj
View
20 QuickStart.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickStart", "Source\QuickStart\QuickStart.csproj", "{90762BBE-CB23-42FF-9D3E-486D2F6CA485}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|AnyCPU = Debug|AnyCPU
+ Release|AnyCPU = Release|AnyCPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {90762BBE-CB23-42FF-9D3E-486D2F6CA485}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
+ {90762BBE-CB23-42FF-9D3E-486D2F6CA485}.Debug|AnyCPU.Build.0 = Debug|Any CPU
+ {90762BBE-CB23-42FF-9D3E-486D2F6CA485}.Release|AnyCPU.ActiveCfg = Release|Any CPU
+ {90762BBE-CB23-42FF-9D3E-486D2F6CA485}.Release|AnyCPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = Source\QuickStart\QuickStart.csproj
+ EndGlobalSection
+EndGlobal
View
42 Source/Bind/Generator.Bind.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -7,8 +7,6 @@
<ProjectGuid>{31D19132-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ApplicationIcon>
- </ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>Bind</AssemblyName>
@@ -21,8 +19,6 @@
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>Bind</RootNamespace>
- <StartupObject>
- </StartupObject>
<StartArguments>
</StartArguments>
<FileUpgradeFlags>
@@ -47,73 +43,60 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>True</DebugSymbols>
+ <DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>False</Optimize>
+ <Optimize>false</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>True</Optimize>
+ <Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>True</Optimize>
+ <Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
+ <DebugType>none</DebugType>
+ <WarningLevel>4</WarningLevel>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@@ -1055,6 +1038,7 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
View
30 Source/Build.UpdateVersion/Build.UpdateVersion.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)' == 'Documentation'">
<OutputPath>..\..\Binaries\OpenTK\Release</OutputPath>
@@ -26,17 +26,45 @@
<RootNamespace>Build.UpdateVersion</RootNamespace>
<OutputType>Exe</OutputType>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Documentation|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <DefineConstants>TRACE;</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <DefineConstants>TRACE;</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Nsis|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <DefineConstants>TRACE;</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
<Target Name="BeforeBuild">
<Delete Files="..\..\Version.txt" />
</Target>
View
90 Source/Build.UpdateVersion/Program.cs
@@ -26,20 +26,38 @@
#endregion
using System;
+using System.Diagnostics;
using System.IO;
namespace Build.UpdateVersion
{
- class Program
- {
+ class Program
+ {
const string Major = "1";
const string Minor = "1";
+ static string RootDirectory;
+ static string SourceDirectory;
+
public static void Main()
{
+ string wdir = Environment.CurrentDirectory;
+ if (Directory.GetParent(wdir).Name == "Source")
+ {
+ // Running through msbuild inside Source/Build.UpdateVersion/
+ RootDirectory = "../..";
+ SourceDirectory = "..";
+ }
+ else
+ {
+ // Running manually inside Binaries/OpenTK/[Debug|Release]/
+ RootDirectory = "../../..";
+ SourceDirectory = "../../../Source";
+ }
+
DateTime now = DateTime.UtcNow;
- GenerateVersionInfo(now, "../../Version.txt");
- GenerateAssemblyInfo(now, "../GlobalAssemblyInfo.cs");
+ GenerateVersionInfo(now, Path.Combine(RootDirectory, "Version.txt"));
+ GenerateAssemblyInfo(now, Path.Combine(SourceDirectory, "GlobalAssemblyInfo.cs"));
}
static void GenerateVersionInfo(DateTime now, string file)
@@ -54,7 +72,7 @@ static void GenerateVersionInfo(DateTime now, string file)
version = lines[0];
}
}
-
+
// If the file does not exist, create it.
if (version == null)
{
@@ -69,7 +87,9 @@ static void GenerateAssemblyInfo(DateTime now, string file)
// Revision number is defined as the fraction of the current day, expressed in seconds.
double timespan = now.Subtract(new DateTime(2010, 1, 1)).TotalDays;
string build = ((int)timespan).ToString();
- string revision = ((int)((timespan - (int)timespan) * UInt16.MaxValue)).ToString();
+
+ string revision = RetrieveSvnRevision() ?? RetrieveBzrRevision() ?? RetrieveSeconds(timespan);
+ revision = revision.Trim();
File.WriteAllLines(file, new string[]
{
@@ -90,5 +110,59 @@ static void GenerateAssemblyInfo(DateTime now, string file)
String.Format("[assembly: AssemblyFileVersion(\"{0}.{1}.{2}.{3}\")]", Major, Minor, build, revision),
});
}
- }
-}
+
+ static string RetrieveSeconds(double timespan)
+ {
+ string revision = ((int)((timespan - (int)timespan) * UInt16.MaxValue)).ToString();
+ return revision;
+ }
+
+ static string RetrieveSvnRevision()
+ {
+ try
+ {
+ string output = RunProcess("svn", "info", RootDirectory);
+
+ const string RevisionText = "Revision: ";
+ int index = output.IndexOf(RevisionText);
+ if (index > -1)
+ return output.Substring(index + RevisionText.Length, 5)
+ .Replace('\r', ' ').Replace('\n', ' ').Trim();
+ }
+ catch (Exception e)
+ {
+ Debug.Print("Failed to retrieve svn revision. Error: {0}", e);
+ }
+ return null;
+ }
+
+ static string RetrieveBzrRevision()
+ {
+ try
+ {
+ string output = RunProcess("bzr", "revno", RootDirectory);
+ return output != null && !output.StartsWith("bzr") ? output : null;
+ }
+ catch (Exception e)
+ {
+ Debug.Print("Failed to retrieve svn revision. Error: {0}", e);
+ }
+ return null;
+ }
+
+ static string RunProcess(string cmd, string args, string wdir)
+ {
+ ProcessStartInfo info = new ProcessStartInfo(cmd, args);
+ info.WorkingDirectory = wdir;
+ info.RedirectStandardOutput = true;
+ info.RedirectStandardError = true;
+ info.UseShellExecute = false;
+ Process p = new Process();
+ p.StartInfo = info;
+ p.Start();
+ p.WaitForExit();
+ string output = p.StandardOutput.ReadToEnd();
+ return output;
+ }
+ }
+}
View
2  Source/Compatibility/Audio/OpenAL/AL/EffectsExtensionPresets.cs
@@ -363,7 +363,5 @@ public static class ReverbPresets
public static EaxReverb Chapel = new EaxReverb(26, 19.6f, 0.840f, -1000, -500, 0, 4.62f, 0.64f, 1.23f, -700, 0.032f, 0f, 0f, 0f, -200, 0.049f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0.110f, -5f, 5000f, 250f, 0f, 0x3f);
public static EaxReverb Smallwaterroom = new EaxReverb(26, 36.2f, 0.700f, -1000, -698, 0, 1.51f, 1.25f, 1.14f, -100, 0.020f, 0f, 0f, 0f, 300, 0.030f, 0f, 0f, 0f, 0.179f, 0.150f, 0.895f, 0.190f, -7f, 5000f, 250f, 0f, 0x0);
}
-
-#pragma warning restore 1591
}
}
View
5 Source/Compatibility/Graphics/GL/GLHelper.cs
@@ -1312,11 +1312,6 @@ public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, Co
#endregion
-#pragma warning restore 3019
-#pragma warning restore 1591
-#pragma warning restore 1572
-#pragma warning restore 1573
-
#endregion
}
}
View
27 Source/Compatibility/OpenTK.Compatibility.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -47,7 +47,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE;</DefineConstants>
- <DocumentationFile>OpenTK.Compatibility.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>false</Optimize>
@@ -55,7 +56,7 @@
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
- <NoWarn>1591</NoWarn>
+ <NoWarn>0219, 0414, 0612, 0618, 1591, 3005, 3006</NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>full</DebugType>
</PropertyGroup>
@@ -65,19 +66,25 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
- <DocumentationFile>OpenTK.Compatibility.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
<FileAlignment>4096</FileAlignment>
<Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
- <NoWarn>1591</NoWarn>
+ <NoWarn>0219, 0414, 0612, 0618, 1591, 3005, 3006</NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
+ <DebugType>none</DebugType>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>0219, 0414, 0612, 0618, 1591, 3005, 3006</NoWarn>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -85,14 +92,15 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
- <DocumentationFile>OpenTK.Compatibility.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
<FileAlignment>4096</FileAlignment>
<Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
- <NoWarn>1591</NoWarn>
+ <NoWarn>0219, 0414, 0612, 0618, 1591, 3005, 3006</NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>none</DebugType>
</PropertyGroup>
@@ -475,6 +483,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
+ <ItemGroup>
+ <None Include="OpenTK.Compatibility.xml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
View
42 Source/Converter/Generator.Convert.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -7,8 +7,6 @@
<ProjectGuid>{5FDFF4B6-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ApplicationIcon>
- </ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>Convert</AssemblyName>
@@ -21,8 +19,6 @@
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>Convert</RootNamespace>
- <StartupObject>
- </StartupObject>
<StartArguments>
</StartArguments>
<FileUpgradeFlags>
@@ -45,73 +41,60 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>True</DebugSymbols>
+ <DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>False</Optimize>
+ <Optimize>false</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>True</Optimize>
+ <Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
+ <DebugType>none</DebugType>
+ <WarningLevel>4</WarningLevel>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
- <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<DocumentationFile>
</DocumentationFile>
- <DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
- <Optimize>True</Optimize>
+ <Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
- <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <NoStdLib>False</NoStdLib>
- <NoWarn>
- </NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@@ -184,6 +167,7 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
View
101 Source/Examples/ExampleBrowser.cs
@@ -42,10 +42,8 @@ public partial class ExampleBrowser : Form
#region Fields
//PrivateFontCollection font_collection = new PrivateFontCollection();
-
bool show_warning = true;
-
- static readonly string SourcePath = FindSourcePath();
+ readonly string SourcePath;
#endregion
@@ -53,6 +51,10 @@ public partial class ExampleBrowser : Form
public ExampleBrowser()
{
+ SourcePath =
+ FindSourcePath(Directory.GetCurrentDirectory()) ??
+ FindSourcePath(Assembly.GetExecutingAssembly().Location);
+
Font = SystemFonts.DialogFont;
InitializeComponent();
@@ -121,7 +123,8 @@ private void treeViewSamples_AfterSelect(object sender, TreeViewEventArgs e)
const string no_docs = "Documentation has not been entered.";
const string no_source = "Source code has not been entered.";
- if (e.Node.Tag != null && !String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation))
+ if (SourcePath != null && e.Node.Tag != null &&
+ !String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation))
{
string docs = null;
string source = null;
@@ -358,7 +361,10 @@ static void RunSample(Control parent, ExampleInfo e)
MethodInfo main =
e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ??
- e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(object), typeof(object) }, null);
+ e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] {
+ typeof(object),
+ typeof(object)
+ }, null);
if (main != null)
{
try
@@ -371,31 +377,13 @@ static void RunSample(Control parent, ExampleInfo e)
Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title));
Trace.WriteLine(String.Empty);
- Thread thread = new Thread((ThreadStart)delegate
- {
- try
- {
- main.Invoke(null, null);
- }
- catch (TargetInvocationException expt)
- {
- string ex_info;
- if (expt.InnerException != null)
- ex_info = expt.InnerException.ToString();
- else
- ex_info = expt.ToString();
- MessageBox.Show(ex_info, "An OpenTK example encountered an error.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
- Debug.Print(expt.ToString());
- }
- catch (NullReferenceException expt)
- {
- MessageBox.Show(expt.ToString(), "The Example launcher failed to load the example.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- });
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
+ AppDomain sandbox = AppDomain.CreateDomain("Sandbox");
+ sandbox.DomainUnload += HandleSandboxDomainUnload;
+
+ SampleRunner runner = new SampleRunner(main);
+ CrossAppDomainDelegate cross = new CrossAppDomainDelegate(runner.Invoke);
+ sandbox.DoCallBack(cross);
+ AppDomain.Unload(sandbox);
}
finally
{
@@ -412,31 +400,68 @@ static void RunSample(Control parent, ExampleInfo e)
}
}
+ static void HandleSandboxDomainUnload(object sender, EventArgs e)
+ {
+ AppDomain sandbox = (AppDomain)sender;
+ sandbox.DomainUnload -= HandleSandboxDomainUnload;
+ }
+
+ [Serializable]
+ class SampleRunner
+ {
+ MethodInfo _main;
+
+ public SampleRunner(MethodInfo main)
+ {
+ _main = main;
+ }
+
+ public void Invoke()
+ {
+ try
+ {
+ _main.Invoke(null, null);
+ }
+ catch (TargetInvocationException expt)
+ {
+ string ex_info;
+ if (expt.InnerException != null)
+ ex_info = expt.InnerException.ToString();
+ else
+ ex_info = expt.ToString();
+ //MessageBox.Show(ex_info, "An OpenTK example encountered an error.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+
+ Trace.WriteLine(ex_info.ToString());
+ }
+ catch (Exception expt)
+ {
+ Trace.WriteLine(expt.ToString());
+ }
+ }
+ }
+
// Tries to detect the path that contains the source for the examples.
- static string FindSourcePath()
+ static string FindSourcePath(string guess)
{
- string current_dir = Directory.GetCurrentDirectory();
+ guess = Path.GetDirectoryName(guess);
// Typically, our working directory is either "[opentk]/Binaries/OpenTK/[config]" or "[opentk]".
// The desired source path is "[opentk]/Source/Examples/[ExampleCategory]"
-
- string guess = current_dir;
if (CheckPath(ref guess))
return guess; // We were in [opentk] after all
- guess = current_dir;
for (int i = 0; i < 3; i++)
{
DirectoryInfo dir = Directory.GetParent(guess);
- if (!dir.Exists)
+ if (dir == null || !dir.Exists)
break;
guess = dir.FullName;
}
-
+
if (CheckPath(ref guess))
return guess; // We were in [opentk]/Binaries/OpenTK/[config] after all
- throw new DirectoryNotFoundException();
+ return null;
}
static bool CheckPath(ref string path)
View
204 Source/Examples/OpenGL/1.x/Anaglyph.cs
@@ -0,0 +1,204 @@
+using System;
+using System.Drawing;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+using OpenTK;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+namespace Examples.Tutorial
+{
+ [Example( "Anaglyph Stereo", ExampleCategory.OpenGL, "1.x", Documentation = "Anaglyph" )]
+
+ class Anaglyph : GameWindow
+ {
+
+ Examples.Shapes.DrawableShape Object;
+
+ /// <summary>Creates a 800x600 window with the specified title.</summary>
+ public Anaglyph()
+ : base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.Default)
+ {
+ VSync = VSyncMode.On;
+ }
+
+ /// <summary>Load resources here.</summary>
+ /// <param name="e">Not used.</param>
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ GL.ClearColor(System.Drawing.Color.Black);
+ GL.Enable(EnableCap.DepthTest);
+
+ GL.Enable( EnableCap.Lighting );
+ GL.Enable( EnableCap.Light0 );
+
+ Object = new Examples.Shapes.MengerSponge(1.0, Shapes.MengerSponge.eSubdivisions.Two, true );
+ // Object = new Examples.Shapes.TorusKnot( 256, 32, 0.1, 3, 4, 1, true );
+ }
+
+ protected override void OnUnload( EventArgs e )
+ {
+ base.OnUnload( e );
+
+ Object.Dispose();
+ }
+
+ /// <summary>
+ /// Called when your window is resized. Set your viewport here. It is also
+ /// a good place to set up your projection matrix (which probably changes
+ /// along when the aspect ratio of your window).
+ /// </summary>
+ /// <param name="e">Not used.</param>
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ GL.Viewport(ClientRectangle);
+ }
+
+ /// <summary>
+ /// Called when it is time to setup the next frame. Add you game logic here.
+ /// </summary>
+ /// <param name="e">Contains timing information for framerate independent logic.</param>
+ protected override void OnUpdateFrame(FrameEventArgs e)
+ {
+ base.OnUpdateFrame(e);
+
+ if (Keyboard[Key.Escape])
+ Exit();
+ }
+
+ struct Camera
+ {
+ public Vector3 Position, Direction, Up;
+ public double NearPlane, FarPlane;
+ public double EyeSeparation;
+ public double Aperture; // FOV in degrees
+ public double FocalLength;
+ }
+
+ enum Eye
+ {
+ left,
+ right,
+ }
+
+ void SetupCamera( Eye eye )
+ {
+ Camera camera;
+
+ camera.Position = Vector3.UnitZ;
+ camera.Up = Vector3.UnitY;
+ camera.Direction = -Vector3.UnitZ;
+ camera.NearPlane = 1.0;
+ camera.FarPlane = 5.0;
+ camera.FocalLength = 2.0;
+ camera.EyeSeparation = camera.FocalLength / 30.0;
+ camera.Aperture = 75.0;
+
+ double left, right,
+ bottom, top;
+
+ double widthdiv2 = camera.NearPlane * Math.Tan( MathHelper.DegreesToRadians( (float)( camera.Aperture / 2.0 ) ) ); // aperture in radians
+ double precalc1 = ClientRectangle.Width / (double)ClientRectangle.Height * widthdiv2;
+ double precalc2 = 0.5 * camera.EyeSeparation * camera.NearPlane / camera.FocalLength;
+
+ Vector3 Right = Vector3.Cross( camera.Direction, camera.Up ); // Each unit vectors
+ Right.Normalize();
+
+ Right.X *= (float)( camera.EyeSeparation / 2.0 );
+ Right.Y *= (float)( camera.EyeSeparation / 2.0 );
+ Right.Z *= (float)( camera.EyeSeparation / 2.0 );
+
+ // Projection Matrix
+ top = widthdiv2;
+ bottom = -widthdiv2;
+ if ( eye == Eye.right )
+ {
+ left = -precalc1 - precalc2;
+ right = precalc1 - precalc2;
+ }
+ else
+ {
+ left = -precalc1 + precalc2;
+ right = precalc1 + precalc2;
+ }
+
+ GL.MatrixMode( MatrixMode.Projection );
+ GL.LoadIdentity();
+ GL.Frustum( left, right, bottom, top, camera.NearPlane, camera.FarPlane );
+
+ // Modelview Matrix
+ Matrix4 modelview;
+ if ( eye == Eye.right )
+ {
+ modelview = Matrix4.LookAt(
+ new Vector3( camera.Position.X + Right.X, camera.Position.Y + Right.Y, camera.Position.Z + Right.Z ),
+ new Vector3( camera.Position.X + Right.X + camera.Direction.X, camera.Position.Y + Right.Y + camera.Direction.Y, camera.Position.Z + Right.Z + camera.Direction.Z ),
+ camera.Up );
+ }
+ else
+ {
+ modelview = Matrix4.LookAt(
+ new Vector3( camera.Position.X - Right.X, camera.Position.Y - Right.Y, camera.Position.Z - Right.Z ),
+ new Vector3( camera.Position.X - Right.X + camera.Direction.X, camera.Position.Y - Right.Y + camera.Direction.Y, camera.Position.Z - Right.Z + camera.Direction.Z ),
+ camera.Up );
+ }
+ GL.MatrixMode( MatrixMode.Modelview );
+ GL.LoadIdentity();
+ GL.MultMatrix( ref modelview );
+
+ }
+
+ float Angle;
+
+ void Draw()
+ {
+ GL.Translate( 0f, 0f, -2f );
+ GL.Rotate( Angle, Vector3.UnitY );
+ Object.Draw();
+ }
+
+ /// <summary>
+ /// Called when it is time to render the next frame. Add your rendering code here.
+ /// </summary>
+ /// <param name="e">Contains timing information.</param>
+ protected override void OnRenderFrame( FrameEventArgs e )
+ {
+ Angle += (float)(e.Time *20.0);
+
+
+ GL.Clear( ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit );
+ SetupCamera( Eye.right );
+ GL.ColorMask( true, false, false, true );
+ Draw();
+
+ GL.Clear( ClearBufferMask.DepthBufferBit ); //
+ SetupCamera( Eye.left );
+ GL.ColorMask( false, true, true, true );
+ Draw();
+
+ GL.ColorMask( true, true, true, true );
+ SwapBuffers();
+ }
+
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ // The 'using' idiom guarantees proper resource cleanup.
+ // We request 30 UpdateFrame events per second, and unlimited
+ // RenderFrame events (as fast as the computer can handle).
+ using (Anaglyph game = new Anaglyph())
+ {
+ game.Run(10.0);
+ }
+ }
+ }
+}
View
BIN  Source/Examples/OpenGL/1.x/Anaglyph.rtf
Binary file not shown
View
62 Source/Examples/OpenGL/1.x/FramebufferObject.cs
@@ -21,7 +21,7 @@ namespace Examples.Tutorial
public class SimpleFBO : GameWindow
{
public SimpleFBO()
- : base(800, 600)
+ : base(800, 400)
{
}
@@ -33,24 +33,7 @@ public SimpleFBO()
const int TextureSize = 512;
- #region Randoms
-
- Random rnd = new Random();
- public const float scale = 3f;
-
- /// <summary>Returns a random Float in the range [-0.5*scale..+0.5*scale]</summary>
- public float GetRandom()
- {
- return (float)(rnd.NextDouble() - 0.5) * scale;
- }
-
- /// <summary>Returns a random Float in the range [0..1]</summary>
- public float GetRandom0to1()
- {
- return (float)rnd.NextDouble();
- }
-
- #endregion Randoms
+ Examples.Shapes.DrawableShape Object;
protected override void OnLoad(EventArgs e)
{
@@ -63,13 +46,14 @@ protected override void OnLoad(EventArgs e)
Exit();
}
+ Object = new Shapes.TorusKnot(256, 16, 0.2, 7,8, 1, true);
+
GL.Enable(EnableCap.DepthTest);
GL.ClearDepth(1.0f);
GL.DepthFunc(DepthFunction.Lequal);
- GL.Disable(EnableCap.CullFace);
- GL.PolygonMode(MaterialFace.Back, PolygonMode.Line);
-
+ GL.Enable(EnableCap.CullFace);
+
// Create Color Tex
GL.GenTextures(1, out ColorTexture);
GL.BindTexture(TextureTarget.Texture2D, ColorTexture);
@@ -176,20 +160,24 @@ protected override void OnLoad(EventArgs e)
GL.ClearColor(1f, 0f, 0f, 0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
- // smack 50 random triangles into the FBO's textures
- GL.Begin(BeginMode.Triangles);
- {
- for (int i = 0; i < 50; i++)
- {
- GL.Color3(GetRandom0to1(), GetRandom0to1(), GetRandom0to1());
- GL.Vertex3(GetRandom(), GetRandom(), GetRandom());
- GL.Color3(GetRandom0to1(), GetRandom0to1(), GetRandom0to1());
- GL.Vertex3(GetRandom(), GetRandom(), GetRandom());
- GL.Color3(GetRandom0to1(), GetRandom0to1(), GetRandom0to1());
- GL.Vertex3(GetRandom(), GetRandom(), GetRandom());
- }
- }
- GL.End();
+ OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView( MathHelper.PiOver4, TextureSize / (float)TextureSize, 2.5f, 6f );
+ GL.MatrixMode( MatrixMode.Projection );
+ GL.LoadMatrix( ref perspective );
+
+ Matrix4 lookat = Matrix4.LookAt( 0f, 0f, 4.5f, 0f, 0f, 0f, 0f, 1f, 0f );
+ GL.MatrixMode( MatrixMode.Modelview );
+ GL.LoadMatrix( ref lookat );
+
+ // draw some complex object into the FBO's textures
+ GL.Enable( EnableCap.Lighting );
+ GL.Enable( EnableCap.Light0 );
+ GL.Enable( EnableCap.ColorMaterial );
+ GL.Color3( 0f, 1f, 0f );
+ Object.Draw();
+ GL.Disable( EnableCap.ColorMaterial );
+ GL.Disable( EnableCap.Light0 );
+ GL.Disable( EnableCap.Lighting );
+
}
GL.PopAttrib();
GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // disable rendering into the FBO
@@ -203,6 +191,8 @@ protected override void OnLoad(EventArgs e)
protected override void OnUnload(EventArgs e)
{
+ Object.Dispose();
+
// Clean up what we allocated before exiting
if (ColorTexture != 0)
GL.DeleteTextures(1, ref ColorTexture);
View
BIN  Source/Examples/OpenGL/1.x/FramebufferObject.rtf
Binary file not shown
View
438 Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs
@@ -0,0 +1,438 @@
+using System;
+using System.Drawing;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+using OpenTK;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+namespace Examples.Tutorial
+{
+ [Example( "OpenGL Diagnostics", ExampleCategory.OpenGL, "1.x", Documentation = "OpenGLDiagnostics" )]
+
+ class GLDiagnostics : GameWindow
+ {
+ /// <summary>Creates a 800x600 window with the specified title.</summary>
+ public GLDiagnostics()
+ : base(80, 60, GraphicsMode.Default, "OpenTK Quick Start Sample", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.Default)
+ {
+ VSync = VSyncMode.On;
+ this.Context.ErrorChecking = false;
+ }
+
+ struct TexFormat
+ {
+ public PixelInternalFormat pif;
+ public PixelFormat pf;
+ public PixelType pt;
+
+ public TexFormat(PixelInternalFormat _pif, PixelFormat _pf, PixelType _pt)
+ {
+ pif = _pif;
+ pf = _pf;
+ pt = _pt;
+ }
+ }
+
+ TexFormat[] TextureFormats = new TexFormat[]
+ {
+ new TexFormat( PixelInternalFormat.Alpha, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Alpha4, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Alpha8, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Alpha12, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Alpha16, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.Alpha16fArb, PixelFormat.Alpha, PixelType.HalfFloat),
+ new TexFormat( (PixelInternalFormat)All.Alpha32fArb, PixelFormat.Alpha, PixelType.Float),
+
+ new TexFormat( PixelInternalFormat.DepthComponent, PixelFormat.DepthComponent, PixelType.Int),
+ new TexFormat( PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.Float),
+ new TexFormat( PixelInternalFormat.DepthComponent24, PixelFormat.DepthComponent, PixelType.Float),
+ new TexFormat( PixelInternalFormat.DepthComponent32, PixelFormat.DepthComponent, PixelType.Float),
+ new TexFormat( PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float),
+ new TexFormat( PixelInternalFormat.DepthStencil, PixelFormat.DepthStencil, PixelType.UnsignedInt248),
+ new TexFormat( PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248),
+ new TexFormat( PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev),
+
+ new TexFormat( PixelInternalFormat.One, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Two, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgba, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.Srgb, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.SrgbAlpha, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Srgb8, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.R16f, PixelFormat.Red, PixelType.HalfFloat),
+ new TexFormat( PixelInternalFormat.Rg16f, PixelFormat.Rg, PixelType.HalfFloat),
+ new TexFormat( PixelInternalFormat.Rgb16f, PixelFormat.Rgb, PixelType.HalfFloat),
+ new TexFormat( PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat),
+ new TexFormat( PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float),
+ new TexFormat( PixelInternalFormat.Rg32f, PixelFormat.Rg, PixelType.Float),
+ new TexFormat( PixelInternalFormat.Rgb32f, PixelFormat.Rgb, PixelType.Float),
+ new TexFormat( PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float),
+
+ new TexFormat( PixelInternalFormat.R8, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb8, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.R8ui, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rg8ui, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb8ui, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgba8ui, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.R16ui, PixelFormat.Red, PixelType.UnsignedShort),
+ new TexFormat( PixelInternalFormat.Rg16ui, PixelFormat.Rg, PixelType.UnsignedShort),
+ new TexFormat( PixelInternalFormat.Rgb16ui, PixelFormat.Rgb, PixelType.UnsignedShort),
+ new TexFormat( PixelInternalFormat.Rgba16ui, PixelFormat.Rgba, PixelType.UnsignedShort),
+ new TexFormat( PixelInternalFormat.R32ui, PixelFormat.Red, PixelType.UnsignedInt),
+ new TexFormat( PixelInternalFormat.Rg32ui, PixelFormat.Rg, PixelType.UnsignedInt),
+ new TexFormat( PixelInternalFormat.Rgb32ui, PixelFormat.Rgb, PixelType.UnsignedInt),
+ new TexFormat( PixelInternalFormat.Rgba32ui, PixelFormat.Rgba, PixelType.UnsignedInt),
+
+ new TexFormat( PixelInternalFormat.R8i, PixelFormat.Red, PixelType.Byte),
+ new TexFormat( PixelInternalFormat.Rg8i, PixelFormat.Rg, PixelType.Byte),
+ new TexFormat( PixelInternalFormat.Rgb8i, PixelFormat.Rgb, PixelType.Byte),
+ new TexFormat( PixelInternalFormat.Rgba8i, PixelFormat.Rgba, PixelType.Byte),
+ new TexFormat( PixelInternalFormat.R16i, PixelFormat.Red, PixelType.Short),
+ new TexFormat( PixelInternalFormat.Rg16i, PixelFormat.Rg, PixelType.Short),
+ new TexFormat( PixelInternalFormat.Rgb16i, PixelFormat.Rgb, PixelType.Short),
+ new TexFormat( PixelInternalFormat.Rgba16i, PixelFormat.Rgba, PixelType.Short),
+ new TexFormat( PixelInternalFormat.R32i, PixelFormat.Red, PixelType.Int),
+ new TexFormat( PixelInternalFormat.Rg32i, PixelFormat.Rg, PixelType.Int),
+ new TexFormat( PixelInternalFormat.Rgb32i, PixelFormat.Rgb, PixelType.Int),
+ new TexFormat( PixelInternalFormat.Rgba32i, PixelFormat.Rgba, PixelType.Int),
+
+ new TexFormat( PixelInternalFormat.R3G3B2, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb10A2, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb5A1, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.Rgb9E5, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.CompressedAlpha, PixelFormat.Alpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedIntensity, PixelFormat.Luminance, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedLuminance, PixelFormat.Luminance, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedLuminanceAlpha, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedLuminanceLatc1Ext, PixelFormat.Luminance, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedLuminanceAlphaLatc2Ext, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.CompressedRed, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedRedRgtc1, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRedGreenRgtc2Ext, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedRg, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedRgRgtc2, PixelFormat.Rg, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedRgb, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbFxt13Dfx, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedRgba, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbaFxt13Dfx, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ new TexFormat( (PixelInternalFormat)All.CompressedSignedLuminanceAlphaLatc2Ext, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedSignedLuminanceLatc1Ext, PixelFormat.Luminance, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSignedRedRgtc1, PixelFormat.Red, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSignedRgRgtc2, PixelFormat.Rg, PixelType.UnsignedByte),
+
+ new TexFormat( PixelInternalFormat.CompressedSluminance, PixelFormat.Luminance, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSluminanceAlpha, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgb, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgbAlpha, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgbS3tcDxt1Ext, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbS3tcDxt1Ext, PixelFormat.Rgb, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt1Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt3Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+ new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt5Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
+
+ };
+
+ #region GL.Get* Helper
+
+ public enum eType
+ {
+ Boolean,
+ Int,
+ IntEnum,
+ IntArray2,
+ IntArray4,
+ Float,
+ FloatArray2,
+ FloatArray4,
+ }
+
+ public void Analyze(GetPName pname, eType type)
+ {
+ bool result1b;
+ int result1i;
+ int[] result2i = new int[2];
+ int[] result4i = new int[4];
+ float result1f;
+ Vector2 result2f;
+ Vector4 result4f;
+ string output;
+
+ switch (type)
+ {
+ case eType.Boolean:
+ GL.GetBoolean(pname, out result1b);
+ output = pname + ": " + result1b;
+ break;
+ case eType.Int:
+ GL.GetInteger(pname, out result1i);
+ output = pname + ": " + result1i;
+ break;
+ case eType.IntEnum:
+ GL.GetInteger(pname, out result1i);
+ output = pname + ": " + (All)result1i;
+ break;
+ case eType.IntArray2:
+ GL.GetInteger(pname, result2i);
+ output = pname + ": ( " + result2i[0] + ", " + result2i[1] + " )";
+ break;
+ case eType.IntArray4:
+ GL.GetInteger(pname, result4i);
+ output = pname + ": ( " + result4i[0] + ", " + result4i[1] + " ) ( " + result4i[2] + ", " + result4i[3] + " )";
+ break;
+ case eType.Float:
+ GL.GetFloat(pname, out result1f);
+ output = pname + ": " + result1f;
+ break;
+ case eType.FloatArray2:
+ GL.GetFloat(pname, out result2f);
+ output = pname + ": ( " + result2f.X + ", " + result2f.Y + " )";
+ break;
+ case eType.FloatArray4:
+ GL.GetFloat(pname, out result4f);
+ output = pname + ": ( " + result4f.X + ", " + result4f.Y + ", " + result4f.Z + ", " + result4f.W + " )";
+ break;
+ default: throw new NotImplementedException();
+ }
+
+ ErrorCode err = GL.GetError();
+ if (err != ErrorCode.NoError)
+ Trace.WriteLine("Unsupported Token: " + pname);
+ else
+ Trace.WriteLine(output);
+
+ }
+
+ #endregion GL.Get* Helper
+
+ /// <summary>Load resources here.</summary>
+ /// <param name="e">Not used.</param>
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ GL.ClearColor(System.Drawing.Color.MidnightBlue);
+ GL.Enable(EnableCap.DepthTest);
+
+ // returns 0 formats, driver broken?
+ /*
+ int CompressedTextureFormatCount;
+ GL.GetInteger(GetPName.NumCompressedTextureFormats, out CompressedTextureFormatCount);
+ if (CompressedTextureFormatCount > 0)
+ {
+ int[] CompressedTextureFormats = new int[CompressedTextureFormatCount];
+ GL.GetInteger(GetPName.CompressedTextureFormats, CompressedTextureFormats);
+ Trace.WriteLine("Supported compressed Texture formats:");
+ for (int i = 0; i < CompressedTextureFormats.Length; i++)
+ Trace.Write((All)CompressedTextureFormats[i] + ", ");
+ }
+ */
+
+ string Renderer = GL.GetString(StringName.Renderer);
+ string GLSLang = GL.GetString(StringName.ShadingLanguageVersion);
+ string Vendor = GL.GetString(StringName.Vendor);
+ string Version = GL.GetString(StringName.Version);
+
+ string ExtensionsRaw = GL.GetString(StringName.Extensions);
+ string[] splitter = new string[] { " " };
+ string[] Extensions = ExtensionsRaw.Split(splitter, StringSplitOptions.None);
+
+ Trace.WriteLine("Vendor: " + Vendor);
+ Trace.WriteLine("Renderer: " + Renderer);
+ Trace.WriteLine("GL Version: " + Version);
+ Analyze(GetPName.MajorVersion, eType.Int);
+ Analyze(GetPName.MinorVersion, eType.Int);
+ Trace.WriteLine("GLSL Version: " + GLSLang);
+ Trace.WriteLine("Extensions: ");
+ for (int i = 0; i < Extensions.Length; i++)
+ Trace.WriteLine(Extensions[i]);
+
+ Trace.WriteLine("--- Framebuffer ---");
+ Analyze(GetPName.Doublebuffer, eType.Boolean);
+ Analyze(GetPName.MaxColorAttachments, eType.Int);
+ Analyze(GetPName.MaxDrawBuffers, eType.Int);
+ Analyze(GetPName.AuxBuffers, eType.Int);
+ Analyze(GetPName.DrawBuffer, eType.IntEnum);
+ Analyze(GetPName.MaxSamples, eType.Int);
+ Analyze(GetPName.MaxViewportDims, eType.IntArray2);
+ Analyze(GetPName.Viewport, eType.IntArray4);
+
+ Trace.WriteLine("--- Framebuffer channels ---");
+ Analyze(GetPName.RedBits, eType.Int);
+ Analyze(GetPName.GreenBits, eType.Int);
+ Analyze(GetPName.BlueBits, eType.Int);
+ Analyze(GetPName.AlphaBits, eType.Int);
+ Analyze(GetPName.DepthBits, eType.Int);
+ Analyze(GetPName.StencilBits, eType.Int);
+
+ Analyze(GetPName.AccumRedBits, eType.Int);
+ Analyze(GetPName.AccumGreenBits, eType.Int);
+ Analyze(GetPName.AccumBlueBits, eType.Int);
+ Analyze(GetPName.AccumAlphaBits, eType.Int);
+
+ Trace.WriteLine("--- Textures ---");
+ Analyze(GetPName.MaxCombinedTextureImageUnits, eType.Int);
+ Analyze(GetPName.MaxVertexTextureImageUnits, eType.Int);
+ Analyze(GetPName.MaxTextureImageUnits, eType.Int);
+ Analyze(GetPName.MaxTextureUnits, eType.Int);
+ Analyze(GetPName.MaxTextureSize, eType.Int);
+ Analyze(GetPName.Max3DTextureSize, eType.Int);
+ Analyze(GetPName.MaxCubeMapTextureSize, eType.Int);
+ Analyze(GetPName.MaxRenderbufferSize, eType.Int);
+ Analyze(GetPName.MaxTextureLodBias, eType.Int);
+
+ Queue<TexFormat> Supported = new Queue<TexFormat>();
+ Queue<TexFormat> Unsupported = new Queue<TexFormat>();
+
+ uint DummyTexture;
+ foreach (TexFormat t in TextureFormats)
+ {
+ GL.GenTextures(1, out DummyTexture);
+ GL.BindTexture(TextureTarget.Texture2D, DummyTexture);
+ GL.TexImage2D(TextureTarget.Texture2D, 0, t.pif, 4, 4, 0, t.pf, t.pt, IntPtr.Zero);
+ if (GL.GetError() == ErrorCode.NoError)
+ Supported.Enqueue(t);
+ else
+ Unsupported.Enqueue(t);
+ GL.DeleteTextures(1, ref DummyTexture);
+ }
+ GL.BindTexture(TextureTarget.Texture2D, 0);
+
+ Trace.WriteLine("--- UN-supported Texture formats ---");
+ while (Unsupported.Count > 0)
+ {
+ TexFormat tex = Unsupported.Dequeue();
+ Trace.Write((All)tex.pif+", ");
+ }
+ Trace.WriteLine( " " );
+
+ Trace.WriteLine("--- SUPPORTED Texture formats ---");
+ while (Supported.Count > 0)
+ {
+ TexFormat tex = Supported.Dequeue();
+ Trace.WriteLine((All)tex.pif+" " +tex.pf + " "+tex.pt);
+ }
+ Trace.WriteLine(" ");
+
+ Trace.WriteLine("--- Point&Line volumes ---");
+ Analyze(GetPName.AliasedPointSizeRange, eType.FloatArray2);
+ Analyze(GetPName.PointSizeMin, eType.Float);
+ Analyze(GetPName.PointSizeMax, eType.Float);
+ Analyze(GetPName.PointSizeGranularity, eType.Float);
+ Analyze(GetPName.PointSizeRange, eType.FloatArray2);
+
+ Analyze(GetPName.AliasedLineWidthRange, eType.FloatArray2);
+ Analyze(GetPName.LineWidthGranularity, eType.Float);
+ Analyze(GetPName.LineWidthRange, eType.FloatArray2);
+
+ Trace.WriteLine("--- VBO ---");
+ Analyze(GetPName.MaxElementsIndices, eType.Int);
+ Analyze(GetPName.MaxElementsVertices, eType.Int);
+ Analyze(GetPName.MaxVertexAttribs, eType.Int);
+
+ Trace.WriteLine("--- GLSL ---");
+ Analyze(GetPName.MaxCombinedFragmentUniformComponents, eType.Int);
+ Analyze(GetPName.MaxCombinedGeometryUniformComponents, eType.Int);
+ Analyze(GetPName.MaxCombinedVertexUniformComponents, eType.Int);
+ Analyze(GetPName.MaxFragmentUniformComponents, eType.Int);
+ Analyze(GetPName.MaxVertexUniformComponents, eType.Int);
+
+ Analyze(GetPName.MaxCombinedUniformBlocks, eType.Int);
+ Analyze(GetPName.MaxFragmentUniformBlocks, eType.Int);
+ Analyze(GetPName.MaxGeometryUniformBlocks, eType.Int);
+ Analyze(GetPName.MaxVertexUniformBlocks, eType.Int);
+ Analyze(GetPName.MaxUniformBlockSize, eType.Int);
+ Analyze(GetPName.MaxUniformBufferBindings, eType.Int);
+
+ Analyze(GetPName.MaxVaryingFloats, eType.Int);
+
+ Trace.WriteLine("--- Transform Feedback ---");
+ Analyze(GetPName.MaxTransformFeedbackInterleavedComponents, eType.Int);
+ Analyze(GetPName.MaxTransformFeedbackSeparateAttribs, eType.Int);
+ Analyze(GetPName.MaxTransformFeedbackSeparateComponents, eType.Int);
+
+ Trace.WriteLine("--- Fixed-Func Stacks, GL.Push* and GL.Pop* ---");
+ Analyze(GetPName.MaxClientAttribStackDepth, eType.Int);
+ Analyze(GetPName.MaxAttribStackDepth, eType.Int);
+ Analyze(GetPName.MaxProjectionStackDepth, eType.Int);
+ Analyze(GetPName.MaxModelviewStackDepth, eType.Int);
+ Analyze(GetPName.MaxTextureStackDepth, eType.Int);
+ Analyze(GetPName.MaxNameStackDepth, eType.Int);
+
+ Trace.WriteLine("--- Fixed-Func misc. stuff ---");
+ Analyze(GetPName.MaxEvalOrder, eType.Int);
+ Analyze(GetPName.MaxClipPlanes, eType.Int);
+ Analyze(GetPName.MaxArrayTextureLayers, eType.Int);
+ Analyze(GetPName.MaxListNesting, eType.Int);
+ Analyze(GetPName.MaxLights, eType.Int);
+ Analyze(GetPName.MaxTextureCoords, eType.Int);
+
+ this.Exit();
+ }
+
+ /// <summary>
+ /// Called when your window is resized. Set your viewport here. It is also
+ /// a good place to set up your projection matrix (which probably changes
+ /// along when the aspect ratio of your window).
+ /// </summary>
+ /// <param name="e">Not used.</param>
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ GL.Viewport(ClientRectangle);
+ }
+
+ /// <summary>
+ /// Called when it is time to setup the next frame. Add you game logic here.
+ /// </summary>
+ /// <param name="e">Contains timing information for framerate independent logic.</param>
+ protected override void OnUpdateFrame(FrameEventArgs e)
+ {
+ base.OnUpdateFrame(e);
+
+ if (Keyboard[Key.Escape])
+ Exit();
+ }
+
+ /// <summary>
+ /// Called when it is time to render the next frame. Add your rendering code here.
+ /// </summary>
+ /// <param name="e">Contains timing information.</param>
+ protected override void OnRenderFrame(FrameEventArgs e)
+ {
+ base.OnRenderFrame(e);
+ }
+
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ // The 'using' idiom guarantees proper resource cleanup.
+ // We request 30 UpdateFrame events per second, and unlimited
+ // RenderFrame events (as fast as the computer can handle).
+ using (GLDiagnostics game = new GLDiagnostics())
+ {
+ game.Run(10.0);
+ }
+ }
+ }
+}
View
BIN  Source/Examples/OpenGL/1.x/OpenGLDiagnostics.rtf
Binary file not shown
View
4 Source/Examples/OpenGL/1.x/VBODynamic.cs
@@ -57,8 +57,8 @@ protected override void OnLoad(EventArgs e)
GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
// Setup VBO state
- GL.EnableClientState(EnableCap.ColorArray);
- GL.EnableClientState(EnableCap.VertexArray);
+ GL.EnableClientState(ArrayCap.ColorArray);
+ GL.EnableClientState(ArrayCap.VertexArray);
GL.GenBuffers(1, out VBOHandle);
View
12 Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs
@@ -730,9 +730,9 @@ void renderCubeVBO()
//GL.Arb.DrawArraysInstanced(BeginMode.Triangles, 0, cubeData.Length/8, 1);
GL.DrawArrays(BeginMode.Triangles, 0, cubeData.Length / (vboCubeStride / sizeof(float)));
- GL.DisableClientState(EnableCap.VertexArray);
- GL.DisableClientState(EnableCap.NormalArray);
- GL.DisableClientState(EnableCap.TextureCoordArray);
+ GL.DisableClientState(ArrayCap.VertexArray);
+ GL.DisableClientState(ArrayCap.NormalArray);
+ GL.DisableClientState(ArrayCap.TextureCoordArray);
}
void renderSphereVBO()
@@ -753,9 +753,9 @@ void renderSphereVBO()
//GL.Arb.DrawArraysInstanced(BeginMode.Triangles, 0, cubeData.Length/8, 1);
//GL.DrawArrays(BeginMode.Triangles, 0, sphereData.Length / (vboSphereStride / sizeof(float)));
- GL.DisableClientState(EnableCap.VertexArray);
- GL.DisableClientState(EnableCap.NormalArray);
- GL.DisableClientState(EnableCap.TextureCoordArray);
+ GL.DisableClientState(ArrayCap.VertexArray);
+ GL.DisableClientState(ArrayCap.NormalArray);
+ GL.DisableClientState(ArrayCap.TextureCoordArray);
}
void renderCubemap()
View
4 Source/Examples/OpenGL/2.x/SimpleGLSL.cs
@@ -261,8 +261,8 @@ protected override void OnRenderFrame(FrameEventArgs e)
//GL.DrawArrays(GL.Enums.BeginMode.POINTS, 0, shape.Vertices.Length);
- GL.DisableClientState(EnableCap.VertexArray);
- GL.DisableClientState(EnableCap.ColorArray);
+ GL.DisableClientState(ArrayCap.VertexArray);
+ GL.DisableClientState(ArrayCap.ColorArray);
//int error = GL.GetError();
View
12 Source/Examples/OpenTK.Examples.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -80,6 +80,10 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
+ <DebugType>none</DebugType>
+ <WarningLevel>4</WarningLevel>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -143,6 +147,10 @@
<Compile Include="ExampleInfo.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="OpenGL\1.x\Anaglyph.cs" />
+ <Compile Include="OpenGL\1.x\OpenGLDiagnostics.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="SamplesTreeViewSorter.cs">
<SubType>Code</SubType>
</Compile>
@@ -543,6 +551,8 @@
<None Include="Data\Audio\the_ring_that_fell.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <EmbeddedResource Include="OpenGL\1.x\OpenGLDiagnostics.rtf" />
+ <EmbeddedResource Include="OpenGL\1.x\Anaglyph.rtf" />
<None Include="Resources\App.ico">
</None>
<None Include="..\OpenTK\OpenTK.dll.config">
View
21 Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs
@@ -66,7 +66,9 @@ protected override void OnLoad(EventArgs e)
void glControl_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F12)
- glControl.GrabScreenshot().Save("screenshot.png");
+ {
+ GrabScreenshot().Save("screenshot.png");
+ }
}
#endregion
@@ -204,6 +206,23 @@ private void DrawCube()
#endregion
+ #region private void GrabScreenshot()
+
+ Bitmap GrabScreenshot()
+ {
+ 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
+
#region public static void Main()
/// <summary>
View
94 Source/Examples/OpenTK/Test/BlittableValueTypes.cs
@@ -1,44 +1,46 @@
// This code is in the Public Domain. It is provided "as is"
-// without express or implied warranty of any kind.
-
-using System;
-using System.Diagnostics;
-using System.Reflection;
-using OpenTK;
-
-namespace Examples.Tests
-{
- struct Simple { public int Value; }
- struct Generic<T> { public T Value; }
- enum Enum { First, Second }
- struct Complex { public Simple Value; }
- struct Complex<T> { public Generic<T> Value; }
- struct Complex2 { public Enum Value; }
- struct Complex3 { public Class Value; }
- struct Complex4 : Interface { public Class Value; }
- class Class { public int Value; }
- class Class<T> { public T Value; }
- interface Interface { }
-
- [Example("Blittable Value Types", ExampleCategory.OpenTK, "Test", Documentation="BlittableValueTypes")]
- public class BlittableValueTypes
- {
- public static void Main()
- {
- TestType(new Simple());
- TestType(new Generic<Simple>());
- TestType(new Generic<Enum>());
- TestType(new Complex());
- TestType(new Complex<Enum>());
- TestType(new Complex2());
- TestType(new Complex3());
- TestType(new Complex4());
- TestType(new Class());
- TestType(new Class<Simple>());
- }
-
- // Tests whether specified type is blittable and prints its marshalled size if so.
- static void TestType<T>(T instance)
+// without express or implied warranty of any kind.
+
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using OpenTK;
+
+#pragma warning disable 0649 // Do not warn about unitialized fields, this is on purpose
+
+namespace Examples.Tests
+{
+ struct Simple { public int Value; }
+ struct Generic<T> { public T Value; }
+ enum Enum { First, Second }
+ struct Complex { public Simple Value; }
+ struct Complex<T> { public Generic<T> Value; }
+ struct Complex2 { public Enum Value; }
+ struct Complex3 { public Class Value; }
+ struct Complex4 : Interface { public Class Value; }
+ class Class { public int Value; }
+ class Class<T> { public T Value; }
+ interface Interface { }
+
+ [Example("Blittable Value Types", ExampleCategory.OpenTK, "Test", Documentation="BlittableValueTypes")]
+ public class BlittableValueTypes
+ {
+ public static void Main()
+ {
+ TestType(new Simple());
+ TestType(new Generic<Simple>());
+ TestType(new Generic<Enum>());
+ TestType(new Complex());
+ TestType(new Complex<Enum>());
+ TestType(new Complex2());
+ TestType(new Complex3());
+ TestType(new Complex4());
+ TestType(new Class());
+ TestType(new Class<Simple>());
+ }
+
+ // Tests whether specified type is blittable and prints its marshalled size if so.
+ static void TestType<T>(T instance)
{
PrintType<T>();
@@ -52,9 +54,9 @@ static void TestType<T>(T instance)
catch (Exception e)
{
Trace.Write(String.Format("({0})", e.GetType().Name));
- }
-
- Trace.WriteLine("");
+ }
+
+ Trace.WriteLine("");
}
// Prints a simple description for the type.
@@ -71,6 +73,6 @@ static void PrintType<T>()
Trace.Write(typename.Substring(typename.LastIndexOf('.') + 1));
Trace.Write(" } ");
- }
- }
-}
+ }
+ }
+}
View
95 Source/Examples/OpenTK/Test/GameWindowStates.cs
@@ -14,15 +14,17 @@
namespace Examples.Tests
{
- [Example("GameWindow states", ExampleCategory.OpenTK, "Test", Documentation = "GameWindowStates")]
+ [Example("GameWindow States", ExampleCategory.OpenTK, "GameWindow", 4, Documentation = "GameWindowStates")]
public class GameWindowStates : GameWindow
{
- static readonly Font TextFont = new Font(FontFamily.GenericSansSerif, 12);
+ static readonly Font TextFont = new Font(FontFamily.GenericSansSerif, 11);
Bitmap TextBitmap = new Bitmap(512, 512);
int texture;
bool mouse_in_window = false;
bool viewport_changed = true;
bool refresh_text = true;
+ MouseState mouse, mouse_old;
+ KeyboardState keyboard, keyboard_old;
public GameWindowStates()
: base(800, 600)
@@ -38,14 +40,22 @@ public GameWindowStates()
Resize += delegate { refresh_text = true; };
WindowBorderChanged += delegate { refresh_text = true; };
WindowStateChanged += delegate { refresh_text = true; };
- Mouse.Move += delegate { refresh_text = true; };
+ FocusedChanged += delegate { refresh_text = true; };
+ Mouse.Move += MouseMoveHandler;
+ Mouse.ButtonDown += MouseButtonHandler;
+ Mouse.ButtonUp += MouseButtonHandler;
}
void KeyDownHandler(object sender, KeyboardKeyEventArgs e)
{
switch (e.Key)
{
- case OpenTK.Input.Key.Escape: this.Exit(); break;
+ case OpenTK.Input.Key.Escape:
+ if (!CursorVisible)
+ CursorVisible = true;
+ else
+ Exit();
+ break;
case Key.Number1: WindowState = WindowState.Normal; break;
case Key.Number2: WindowState = WindowState.Maximized; break;
@@ -68,7 +78,22 @@ void KeyDownHandler(object sender, KeyboardKeyEventArgs e)
case Key.Minus: Size -= new Size(16, 16); break;
}
}
-
+
+ void MouseMoveHandler(object sender, MouseMoveEventArgs e)
+ {
+ refresh_text = true;
+ }
+
+ void MouseButtonHandler(object sender, MouseButtonEventArgs e)
+ {
+ refresh_text = true;
+
+ if (e.Button == MouseButton.Left && e.IsPressed)
+ {
+ CursorVisible = false;
+ }
+ }
+
static int Clamp(int val, int min, int max)
{
return val > max ? max : val < min ? min : val;
@@ -79,8 +104,58 @@ static void DrawString(Graphics gfx, string str, int line)
gfx.DrawString(str, TextFont, Brushes.White, new PointF(0, line * TextFont.Height));
}
+ static void DrawString(Graphics gfx, string str, int line, float offset)
+ {
+ gfx.DrawString(str, TextFont, Brushes.White, new PointF(offset, line * TextFont.Height));
+ }
+
+ static void DrawKeyboard(Graphics gfx, KeyboardState keyboard, int line)
+ {
+ const string str = "Keys pressed:";
+ float space = gfx.MeasureString(" ", TextFont).Width;
+ float offset = gfx.MeasureString(str, TextFont).Width + space;
+ DrawString(gfx, str, line);
+ for (int i = 0; i < (int)Key.LastKey; i++)
+ {
+ Key k = (Key)i;
+ if (keyboard[k])
+ {
+ string key = k.ToString();
+ DrawString(gfx, key, line, offset);
+ offset += gfx.MeasureString(key, TextFont).Width + space;
+ }
+ }
+ }
+
+ static void DrawMouse(Graphics gfx, MouseState mouse, int line)
+ {
+ const string str = "Buttons pressed:";
+ float space = gfx.MeasureString(" ", TextFont).Width;
+ float offset = gfx.MeasureString(str, TextFont).Width + space;
+ DrawString(gfx, str, line);
+ for (int i = 0; i < (int)MouseButton.LastButton; i++)
+ {
+ MouseButton b = (MouseButton)i;
+ if (mouse[b])
+ {
+ string button = b.ToString();
+ DrawString(gfx, button, line, offset);
+ offset += gfx.MeasureString(button, TextFont).Width + space;
+ }
+ }
+ }
+
protected override void OnUpdateFrame(FrameEventArgs e)
{
+ mouse = OpenTK.Input.Mouse.GetState();
+ if (mouse != mouse_old)
+ refresh_text = true;
+ mouse_old = mouse;
+ keyboard = OpenTK.Input.Keyboard.GetState();
+ if (keyboard != keyboard_old)
+ refresh_text = true;
+ keyboard_old = keyboard;
+
if (refresh_text)
{
refresh_text = false;
@@ -89,18 +164,22 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
int line = 0;
- gfx.Clear(Color.MidnightBlue);
+ gfx.Clear(Color.Black);
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
DrawString(gfx, String.Format("[1 - 4]: change WindowState (current: {0}).", this.WindowState), line++);
DrawString(gfx, String.Format("[5 - 7]: change WindowBorder (current: {0}).", this.WindowBorder), line++);
DrawString(gfx, String.Format("Focused: {0}.", this.Focused), line++);
DrawString(gfx, String.Format("Mouse {0} window.", mouse_in_window ? "inside" : "outside of"), line++);
- DrawString(gfx, String.Format("Mouse position: {0}", new Vector3(Mouse.X, Mouse.Y, Mouse.Wheel)), line++);
+ DrawString(gfx, String.Format("Mouse visible: {0}", CursorVisible), line++);
+ DrawString(gfx, String.Format("Mouse position (absolute): {0}", new Vector3(Mouse.X, Mouse.Y, Mouse.Wheel)), line++);
+ DrawString(gfx, String.Format("Mouse position (relative): {0}", new Vector3(mouse.X, mouse.Y, mouse.WheelPrecise)), line++);
DrawString(gfx, String.Format("Window.Bounds: {0}", Bounds), line++);
DrawString(gfx, String.Format("Window.Location: {0}, Size: {1}", Location, Size), line++);
DrawString(gfx, String.Format("Window.{{X={0}, Y={1}, Width={2}, Height={3}}}", X, Y, Width, Height), line++);
DrawString(gfx, String.Format("Window.ClientRectangle: {0}", ClientRectangle), line++);
+ DrawKeyboard(gfx, keyboard, line++);
+ DrawMouse(gfx, mouse, line++);
}
}
@@ -120,6 +199,8 @@ protected override void OnLoad(EventArgs e)
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.Texture2D);
+ GL.Enable(EnableCap.Blend);
+ GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcColor);
texture = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, texture);
View
6 Source/GLControl/OpenTK.GLControl.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -76,6 +76,10 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
+ <DebugType>none</DebugType>
+ <WarningLevel>4</WarningLevel>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
View
58 Source/OpenTK/Audio/OpenAL/AL/AL.cs
@@ -1274,13 +1274,36 @@ public static int[] SourceUnqueueBuffers(int sid, int numEntries)
/// <param name="buffers">Pointer to an array of uint values which will store the names of the new buffers.</param>
[CLSCompliant(false)]
[DllImport(AL.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity]
- public static extern void GenBuffers(int n, out uint buffers);
+ unsafe public static extern void GenBuffers(int n, [Out] int* buffers);
/// <summary>This function generates one or more buffers, which contain audio buffer (see AL.BufferData). References to buffers are uint values, which are used wherever a buffer reference is needed (in calls such as AL.DeleteBuffers, AL.Source with parameter ALSourcei, AL.SourceQueueBuffers, and AL.SourceUnqueueBuffers).</summary>
/// <param name="n">The number of buffers to be generated.</param>
/// <param name="buffers">Pointer to an array of uint values which will store the names of the new buffers.</param>
- [DllImport(AL.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity]
- public static extern void GenBuffers(int n, out int buffers);
+ [CLSCompliant(false)]
+ public static void GenBuffers(int n, out uint buffers)
+ {
+ unsafe
+ {
+ fixed (uint* pbuffers = &buffers)
+ {
+ GenBuffers(n, pbuffers);
+ }
+ }
+ }
+
+ /// <summary>This function generates one or more buffers, which contain audio buffer (see AL.BufferData). References to buffers are uint values, which are used wherever a buffer reference is needed (in calls such as AL.DeleteBuffers, AL.Source with parameter ALSourcei, AL.SourceQueueBuffers, and AL.SourceUnqueueBuffers).</summary>
+ /// <param name="n">The number of buffers to be generated.</param>
+ /// <param name="buffers">Pointer to an array of uint values which will store the names of the new buffers.</param>
+ public static void GenBuffers(int n, out int buffers)
+ {
+ unsafe
+ {
+ fixed (int* pbuffers = &buffers)
+ {
+ GenBuffers(n, pbuffers);
+ }
+ }
+ }
/// <summary>This function generates one or more buffers, which contain audio data (see AL.BufferData). References to buffers are uint values, which are used wherever a buffer reference is needed (in calls such as AL.DeleteBuffers, AL.Source with parameter ALSourcei, AL.SourceQueueBuffers, and AL.SourceUnqueueBuffers).</summary>
/// <param name="n">The number of buffers to be generated.</param>
@@ -1326,13 +1349,36 @@ public static void GenBuffer(out uint buffer)
/// <param name="buffers">Pointer to an array of buffer names identifying the buffers to be deleted.</param>
[CLSCompliant(false)]
[DllImport(AL.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
- public static extern void DeleteBuffers(int n, [In] ref uint buffers);
+ unsafe public static extern void DeleteBuffers(int n, [In] int* buffers);
/// <summary>This function deletes one or more buffers, freeing the resources used by the buffer. Buffers which are attached to a source can not be deleted. See AL.Source (ALSourcei) and AL.SourceUnqueueBuffers for information on how to detach a buffer from a source.</summary>
/// <param name="n">The number of buffers to be deleted.</param>
/// <param name="buffers">Pointer to an array of buffer names identifying the buffers to be deleted.</param>
- [DllImport(AL.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
- public static extern void DeleteBuffers(int n, [In] ref int buffers);
+ [CLSCompliant(false)]
+ public static void DeleteBuffers(int n, [In] ref uint buffers)
+ {
+ unsafe
+ {
+ fixed (uint* pbuffers = &buffers)
+ {
+ DeleteBuffers(n, pbuffers);
+ }
+ }
+ }
+
+ /// <summary>This function deletes one or more buffers, freeing the resources used by the buffer. Buffers which are attached to a source can not be deleted. See AL.Source (ALSourcei) and AL.SourceUnqueueBuffers for information on how to detach a buffer from a source.</summary>
+ /// <param name="n">The number of buffers to be deleted.</param>
+ /// <param name="buffers">Pointer to an array of buffer names identifying the buffers to be deleted.</param>
+ public static void DeleteBuffers(int n, [In] ref int buffers)
+ {
+ unsafe
+ {
+ fixed (int* pbuffers = &buffers)
+ {
+ DeleteBuffers(n, pbuffers);
+ }
+ }
+ }
/// <summary>This function deletes one buffer only, freeing the resources used by the buffer. Buffers which are attached to a source can not be deleted. See AL.Source (ALSourcei) and AL.SourceUnqueueBuffers for information on how to detach a buffer from a source.</summary>
/// <param name="buffers">Pointer to a buffer name identifying the buffer to be deleted.</param>
View
96 Source/OpenTK/DisplayDevice.cs
@@ -1,16 +1,33 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK team.
- * This notice may not be removed.
- * See license.txt for licensing detailed licensing details.
- */
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2010 the Open Toolkit library.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
#endregion
using System;
using System.Collections.Generic;
-using System.Text;
using System.Diagnostics;
-using System.Threading;
using System.Drawing;
namespace OpenTK
@@ -21,23 +38,19 @@ namespace OpenTK
/// </summary>
public class DisplayDevice
{
- // TODO: Add support for refresh rate queries and switches.
- // TODO: Check whether bits_per_pixel works correctly under Mono/X11.
// TODO: Add properties that describe the 'usable' size of the Display, i.e. the maximized size without the taskbar etc.
// TODO: Does not detect changes to primary device.
- // TODO: Mono does not support System.Windows.Forms.Screen.BitsPerPixel -- find workaround!
- #region --- Fields ---
+ #region Fields
+ bool primary;
+ Rectangle bounds;
DisplayResolution current_resolution = new DisplayResolution(), original_resolution;
List<DisplayResolution> available_resolutions = new List<DisplayResolution>();
IList<DisplayResolution> available_res