Synced trunk with 1.0 branch.

This commit is contained in:
the_fiddler 2010-10-02 18:52:34 +00:00
parent bca3751e8b
commit 88e6aceae0
98 changed files with 5294 additions and 8216 deletions

BIN
Build.exe

Binary file not shown.

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="2.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>$(MSBuildProjectDirectory)\Source\latex</OutputPath>
</PropertyGroup>
<Target Name="Build">
<Exec Command="doxygen Doxyfile" />
<Exec Command="pdflatex -interaction=batchmode refman.tex" WorkingDirectory="$(OutputPath)" />
<Exec Command="makeindex -q refman.idx" WorkingDirectory="$(OutputPath)" />
<Exec Command="pdflatex -interaction=batchmode refman.tex" WorkingDirectory="$(OutputPath)" />
<Copy SourceFiles="$(OutputPath)\refman.pdf" DestinationFiles="Reference.pdf" />
</Target>
</Project>

View file

@ -1,3 +1,155 @@
------------------------------
OpenTK 1.0 beta-3 -> 1.0 rc1
------------------------------
2010-03-24 the_fiddler
* Build.exe, Source/Build/Resources/DoxyFile.txt: Modified doxygen
script to ignore .svn directories.
* Source/Build/Build.cs: Improved documentation and added lib
target (builds project files directly).
* Documentation/Manual.pdf: Added manual to source control. This
file is a pdf copy of http://www.opentk.com/book/export/html/111,
converted to pdf format manually (it is not part of the regular
build process).
* Build.exe, Source/Build/Build.cs: Print total build time.
* Source/OpenTK/Platform/X11/X11GLNative.cs: Set initial values for
window bounds and client rectangle to ensure the various
properties return correct values inside the constructor and Load
event. Fixes issue [#1649]: "WindowBorder.Fixed causes 1x1 sized
window on Linux".
* ., Documentation: Update svn:ignore to ignore documentation
source and Visual Studio solution upgrade files.
* Source/Bind/Specifications/GL2/enumext.spec,
Source/OpenTK/Graphics/OpenGL/GLEnums.cs: Added
EXT_texture_compression_s3tc tokens to PixelInternalFormat.
Previously, only the srgb s3tc tokens were available there, now
we have both srgb and rgb tokens.
* Source/Compatibility, Source/Examples, Source/GLControl,
Source/OpenTK: Added pidb files to svn:ignore.
* Build.exe: Updated Build.exe to the latest version that includes
nsis and all targets.
* Installers/Nsis/opentk.nsi: Enabled all languages and add source
code and documentation to the generated installer.
* Source/Build/Build.cs, Source/Build/BuildNsis.cs,
Source/Build/BuildProject.cs,
Source/Build/Resources/OpenTK.Prebuild.xml: * Added "nsis" build
target. * Added "all" build target, that creates solutions,
builds them, creates documentation and runs the nsis target
automatically. * Added support for building the generated
solutions through Build.exe (using Microsoft BuildEngine). This
is necessary for the "all" target. * Patch Prebuild output to fix
csproj paths in the generated solutions.
* Source/OpenTK/GameWindow.cs: Disabled hack for modal event loop
when click-dragging on windows. Threaded rendering is now
supported and provides a superior solution.
* Source/OpenTK/Platform/X11/API.cs: Threaded X should be
initialized both in debug and release modes.
* Source/Build/Properties/Resources.Designer.cs,
Source/Build/Properties/Resources.resx,
Source/Compatibility/Properties/Resources.Designer.cs,
Source/Compatibility/Properties/Resources.resx,
Source/Examples/Properties/Resources.Designer.cs,
Source/Examples/Properties/Resources.resx: Use forward slashes in
resource paths in order to maintain compatibility with xbuild
2.6. See http://www.opentk.com/node/1551
2010-03-23 the_fiddler
* Build.exe, Installers, Installers/Nsis,
Installers/Nsis/opentk.nsi, Source/Build/Build.cs,
Source/Build/BuildNsis.cs,
Source/Build/Properties/AssemblyInfo.cs,
Source/Compatibility/Properties/AssemblyInfo.cs,
Source/Examples/Properties/AssemblyInfo.cs,
Source/GLControl/Properties/AssemblyInfo.cs,
Source/OpenTK/Properties/AssemblyInfo.cs: * Added Nsis installer
script. * Added support for Nsis installer generation in
OpenTK.Build. * Updated project titles. * Bumped version numbers
for 1.0-rc1 release.
* Source/OpenTK/Platform/Windows/WinGLContext.cs: Print
success/failure of wglShareLists. In case of failure, print error
code to simplify debugging.
2010-03-12 the_fiddler
* Source/OpenTK/Graphics/GraphicsContext.cs,
Source/OpenTK/Graphics/IGraphicsContext.cs,
Source/OpenTK/Platform/Dummy/DummyGLContext.cs,
Source/OpenTK/Platform/MacOS/AglContext.cs,
Source/OpenTK/Platform/Windows/WinGLContext.cs,
Source/OpenTK/Platform/X11/X11GLContext.cs: Make LoadAll() method
available to IGraphicsContext. Avoids the need for ugly casts of
GraphicsContext to IGraphicsContextInternal when loading entry
points (for example when trying to use an external, dummy
context).
* Source/OpenTK/Platform/X11/API.cs: XCloseDisplay causes crash in
libGL. Removed as a temporary workaround while investigating the
issue.
* Source/OpenTK/Platform/X11/X11DisplayDevice.cs,
Source/OpenTK/Platform/X11/X11Factory.cs,
Source/OpenTK/Platform/X11/X11XrandrDisplayDevice.cs: * Do not
blow up when XRandR extension is not available. Fixes issue
[#1331]: "XRandR does not work with Nvidia dynamic TwinView
enabled". * Renamed X11XrandrDisplayDevice to X11DisplayDevice as
it should provide more code-paths than only XRandR.
2010-03-11 the_fiddler
* Source/OpenTK/Platform/X11/X11GLNative.cs: * Added support for
reading the actual window borders (WM decoration) through
_NET_FRAME_EXTENTS. Updated Bounds property to use the actual
border size. * Refactored parts of the event loop into separate
functions for improved code clarity. * Updates the window
location or size now immediately process pending events. Fixes
issue [#1605]: "LINUX X, Y, Width, Height not being updated."
* Source/OpenTK/Platform/X11/Functions.cs: XMoveWindow was
incorrectly p/invoking XResizeWindow instead of XMoveWindow.
Fixes issue [#1599]: GameWindow.X or Y don't work correctly on
Linux.
* Source/OpenTK/Platform/Windows/WinGLNative.cs: In the current
implementation, ClientRectangle origin always starts at (0,0).
Location is used for Bounds (the outer rectangle) and was not
used correctly here.
* Source/OpenTK/Platform/Windows/WinGLNative.cs: * Raise only a
single Resize event when changing WindowBorder or WindowState.
Fixes issue [#1461]: "OnResize called multiple times when
changing WindowState." * Refactored WindowBorder and WindowState
parts into new private methods for increased clarity. *
* Source/Examples/OpenTK/GameWindow/ThreadedRendering.cs: Serialize
viewport updates between main and rendering thread to avoid race
conditions.
* Source/OpenTK/Platform/Windows/API.cs: Hide internal members from
doxygen documentation. Fixes issue [#1617]: "Hide internal /
private members for the function reference".
* Source/OpenTK/Platform/Windows/WinGLNative.cs: Use Guid for class
name instead of trying to create our own unique name. Fixes issue
[#1622]: "WinGLNative's window class registration strategy does
not take AppDomains into account" (thanks kring789!)
--------------------------------- ---------------------------------
OpenTK 1.0 beta-2 -> 1.0 beta-3 OpenTK 1.0 beta-2 -> 1.0 beta-3
--------------------------------- ---------------------------------

1602
Documentation/Doxyfile Normal file

File diff suppressed because it is too large Load diff

BIN
Documentation/Manual.pdf Normal file

Binary file not shown.

View file

@ -1,19 +1,14 @@
The Open Toolkit 1.0 beta 3 The Open Toolkit 1.0 rc1
[Overview] [Overview]
This is the third beta release of OpenTK 1.0. This release resolves a large number of identified issues: This is the first release candidate for OpenTK 1.0. Notable changes:
* adds support for doxygen-based documentation. * Implemented NSIS-based installer, added new build targets ("nsis", "lib" and "all") and made the build system more robust.
* significantly improves GameWindow stability. * Fixed ClassName clashes between GameWindows running on different AppDomains. Fixes NUnit support (patch by kring789).
* improves stability on multithreaded scenarios. * Improved behavior of several GameWindow events and properties on Windows and Linux.
* fixes a number of input-related bugs. * Fixed various documentation issues.
* improves support for OpenGL 3.2 functions and adds a number of missing OpenGL tokens.
* features a better "GameWindow States" sample and introduces a "Multithreaded Rendering" sample.
* adds new double-precision based OpenGL overloads.
* fixes a number of smaller annoyances and oversights.
Visit http://www.opentk.com for the latest news and information on the Open Toolkit. Visit http://www.opentk.com for the latest news and information on the Open Toolkit.
@ -21,31 +16,14 @@ Visit http://www.opentk.com for the latest news and information on the Open Tool
[Resolved issues] [Resolved issues]
[#966] [#1132]
[#1244] [#1461]
[#1343] [#1599]
[#1417] [#1605]
[#1418] [#1617]
[#1419] [#1622]
[#1422] [#1649]
[#1443]
[#1444]
[#1446]
[#1457]
[#1467]
[#1468]
[#1483]
[#1492]
[#1498]
[#1504]
[#1508]
[#1531]
[#1538]
[#1542]
[#1593]
[#1596]
[#1598]
[#1600]
Please report any issues you encounter at http://www.opentk.com/node/add/project-issue/opentk Please report any issues you encounter at http://www.opentk.com/node/add/project-issue/opentk
@ -60,11 +38,11 @@ Please report any issues you encounter at http://www.opentk.com/node/add/project
* Mono 2.2 and 2.4.0 fail to compile OpenTK due to a compiler bug (https://bugzilla.novell.com/show_bug.cgi?id=488960). Please compile with Mono 2.0, 2.4.2+ or use the supplied binaries instead. * Mono 2.2 and 2.4.0 fail to compile OpenTK due to a compiler bug (https://bugzilla.novell.com/show_bug.cgi?id=488960). Please compile with Mono 2.0, 2.4.2+ or use the supplied binaries instead.
* The example browser should list summaries for available samples. * The example browser does not list summaries for available samples.
* MonoDevelop fails to sign assemblies (bugs https://bugzilla.novell.com/show_bug.cgi?id=484752 and https://bugzilla.novell.com/show_bug.cgi?id=537063). * MonoDevelop fails to sign assemblies (bugs https://bugzilla.novell.com/show_bug.cgi?id=484752 and https://bugzilla.novell.com/show_bug.cgi?id=537063).
* XBuild <= 2.6.1 fails to compile OpenTK. This issue has been upstream. * XBuild <= 2.4.3 fails to build OpenTK. Please use XBuild 2.6.0 or newer.
[API changes] [API changes]
@ -73,6 +51,10 @@ Please note that binary compatibility is not preserved between beta releases.
If you are upgrading from OpenTK 0.9.9-0 or earlier you can simplify the upgrade process by adding a reference to OpenTK.Compatibility.dll and OpenTK.GLControl.dll (if necessary). OpenTK.Compatibility contains code and APIs that have been deprecated and removed from the core library and supports applications written against the Tao framework (Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl). If you are upgrading from OpenTK 0.9.9-0 or earlier you can simplify the upgrade process by adding a reference to OpenTK.Compatibility.dll and OpenTK.GLControl.dll (if necessary). OpenTK.Compatibility contains code and APIs that have been deprecated and removed from the core library and supports applications written against the Tao framework (Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl).
[1.0 rc1]
No API changes.
[1.0 beta-3] [1.0 beta-3]

Binary file not shown.

264
Installers/Nsis/opentk.nsi Normal file
View file

@ -0,0 +1,264 @@
; Script generated by the HM NIS Edit Script Wizard.
RequestExecutionLevel user
!include x64.nsh
!include WordFunc.nsh
!insertmacro VersionCompare
!include LogicLib.nsh
SetCompressor lzma
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "OpenTK"
!define PRODUCT_VERSION "{{version}}" ; To be replaced by Build.exe
!define PRODUCT_VERSION_REVISION "{{revision}}" ; To be replaced by Build.exe
!define PRODUCT_VERSION_EXTRA "{{extra}}" ; To be replaced by Build.exe
!define PRODUCT_PUBLISHER "The Open Toolkit team"
!define PRODUCT_WEB_SITE "http://www.opentk.com"
!define PRODUCT_UNINST_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define DOTNET20_PUBLIC_ASSEMBLIES_KEY "SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\${PRODUCT_NAME} ${PRODUCT_VERSION}"
!define MULTIUSER_EXECUTIONLEVEL User
;!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "SHELL_CONTEXT"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "InstallDir"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "SHELL_CONTEXT"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallDir"
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_NAME}\${PRODUCT_VERSION}"
;!include MultiUser.nsh ; Doesn't really do what we need to (goes to AppData instead of Documents, no x64 support)
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "..\..\Source\Examples\Resources\App.ico"
!define MUI_UNICON "..\..\Source\Examples\Resources\App.ico"
; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "..\..\Documentation\License.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Basque"
!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Irish"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Kurdish"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Luxembourgish"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Welsh"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI END ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "opentk-${PRODUCT_VERSION}.${PRODUCT_VERSION_REVISION}-${PRODUCT_VERSION_EXTRA}.exe"
InstallDir "${MULTIUSER_INSTALLMODE_INSTDIR}"
ShowInstDetails show
ShowUnInstDetails show
Var AccountType
Function .onInit
; !insertmacro MULTIUSER_INIT
UserInfo::GetAccountType
Pop $AccountType
${If} $AccountType == "Admin"
${OrIf} $AccountType == "Power"
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${MULTIUSER_INSTALLMODE_INSTDIR}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
${EndIf}
${Else}
StrCpy $INSTDIR "$DOCUMENTS\${MULTIUSER_INSTALLMODE_INSTDIR}"
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
; The "" makes the section hidden.
Section "" SecUninstallPrevious
Call UninstallPrevious
SectionEnd
Function UninstallPrevious
; Check for uninstaller.
ReadRegStr $R0 ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "InstallDir"
${If} $R0 == ""
Goto Done
${EndIf}
DetailPrint "Removing previous installation."
; Run the uninstaller silently.
ExecWait '"$INSTDIR\uninst.exe /S"'
Done:
FunctionEnd
Section "MainSection" SEC01
${If} $INSTDIR == $PROGRAMFILES
${OrIf} $INSTDIR == $DOCUMENTS
${OrIf} $INSTDIR == $DESKTOP
${OrIf} $INSTDIR == $WINDIR
${OrIf} $INSTDIR == $SYSDIR
${OrIf} $INSTDIR == $PROFILE
MessageBox MB_OK "Cannot install directly under $INSTDIR. Please specify a subfolder."
Abort
${EndIf}
SetOutPath $INSTDIR
File /r /x *.vshost.exe /x *.vshost.exe.manifest /x *.log ..\..\Binaries
File /r /x .svn /x Source /x Source\*.* ..\..\Documentation
File /r /x .svn /x obj /x *.snk /x *.user /x *.pidb /x html /x latex /x OpenTK*.xml ..\..\Source
File ..\..\Build.exe
File ..\..\*.sln
File /r /x .svn /x opentk-actual.* /x opentk*.exe /x opentk*.msi /x opentk*.deb /x opentk*.rpm ..\..\Installers
SectionEnd
Section -AdditionalIcons
SetOutPath $INSTDIR
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\OpenTK"
CreateShortCut "$SMPROGRAMS\OpenTK\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\OpenTK\Examples.lnk" "$INSTDIR\Binaries\OpenTK\Debug\Examples.exe"
CreateShortCut "$SMPROGRAMS\OpenTK\Reference.lnk" "$INSTDIR\Documentation\Reference.pdf"
CreateShortCut "$SMPROGRAMS\OpenTK\Manual.lnk" "$INSTDIR\Documentation\Manual.pdf"
CreateShortCut "$SMPROGRAMS\OpenTK\Release.lnk" "$INSTDIR\Documentation\Release.txt"
SectionEnd
Section -Post
${If} ${RunningX64}
SetRegView 64
${EndIf}
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${DOTNET20_PUBLIC_ASSEMBLIES_KEY}" "" "$INSTDIR\Binaries\OpenTK\Release"
; Install necessary dependencies
ExecShell "open" '"$INSTDIR\Installers\Dependencies\oalinst.exe"' /S
SectionEnd
Function un.onUninstSuccess
HideWindow
;MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully uninstalled."
FunctionEnd
Function un.onInit
; !insertmacro MULTIUSER_UNINIT
!insertmacro MUI_UNGETLANGUAGE
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you wish to completely uninstall $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
${If} ${RunningX64}
SetRegView 64
${EndIf}
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$SMPROGRAMS\OpenTK\Examples.lnk"
Delete "$SMPROGRAMS\OpenTK\Website.lnk"
Delete "$SMPROGRAMS\OpenTK\Reference.lnk"
Delete "$SMPROGRAMS\OpenTK\Manual.lnk"
Delete "$SMPROGRAMS\OpenTK\Release.lnk"
RMDir "$SMPROGRAMS\OpenTK"
Delete "$INSTDIR\*.sln"
Delete "$INSTDIR\Build.exe"
Delete "$INSTDIR\*.log"
RMDir /r "$INSTDIR\Installers"
RMDir /r "$INSTDIR\Source"
RMDir /r "$INSTDIR\Documentation"
RMDir /r "$INSTDIR\Binaries"
RMDir "$INSTDIR"
DeleteRegKey ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY} "${DOTNET20_PUBLIC_ASSEMBLIES_KEY}"
SetAutoClose true
SectionEnd

View file

@ -53,11 +53,22 @@ namespace Bind.ES
{ {
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
{ {
Delegate d = new Delegate(); var name = node.GetAttribute("name", String.Empty);
d.Name = node.GetAttribute("name", String.Empty);
//d.Extension = node.GetAttribute("extension"); // Check whether we are adding to an existing delegate or creating a new one.
d.Version = node.GetAttribute("version", String.Empty); Delegate d = null;
d.Category = node.GetAttribute("category", String.Empty); if (delegates.ContainsKey(name))
{
d = delegates[name];
}
else
{
d = new Delegate();
d.Name = name;
d.Version = node.GetAttribute("version", String.Empty);
d.Category = node.GetAttribute("category", String.Empty);
}
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element)) foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
{ {
switch (param.Name) switch (param.Name)

View file

@ -6527,6 +6527,12 @@ PixelInternalFormat enum:
COMPRESSED_INTENSITY = 0x84EC COMPRESSED_INTENSITY = 0x84EC
COMPRESSED_RGB = 0x84ED COMPRESSED_RGB = 0x84ED
COMPRESSED_RGBA = 0x84EE COMPRESSED_RGBA = 0x84EE
# Tokens from EXT_texture_compression_s3tc enum:
COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0
COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
HintTarget enum: HintTarget enum:
TEXTURE_COMPRESSION_HINT = 0x84EF TEXTURE_COMPRESSION_HINT = 0x84EF

View file

@ -19,11 +19,12 @@ using OpenTK.Build.Properties;
namespace OpenTK.Build namespace OpenTK.Build
{ {
class Project partial class Project
{ {
static readonly string RootPath = Directory.GetCurrentDirectory(); static readonly string RootPath = Directory.GetCurrentDirectory();
static readonly string SourcePath = Path.Combine(RootPath, "Source"); static readonly string SourcePath = Path.Combine(RootPath, "Source");
static readonly string DocPath = Path.Combine(RootPath, "Documentation"); static readonly string DocPath = Path.Combine(RootPath, "Documentation");
static readonly string InstallersPath = Path.Combine(RootPath, "Installers");
const string bindings = "Generator.Prebuild.xml"; const string bindings = "Generator.Prebuild.xml";
const string opentk = "OpenTK.Prebuild.xml"; const string opentk = "OpenTK.Prebuild.xml";
@ -33,15 +34,23 @@ namespace OpenTK.Build
const string KeyFile = "OpenTK.snk"; // Do not change const string KeyFile = "OpenTK.snk"; // Do not change
const string Usage = @"Usage: Build.exe target const string Usage = @"Solution generator and build script for OpenTK.
target: one of vs, vs9, doc, clean, distclean, help"; Usage: [mono] Build.exe [target]
[mono]: use the Mono VM (otherwise use .Net)
[target]: vs, vs9 - generate solutions
all, lib, doc, nsis - build specified target
clean, distclean - delete intermediate and/or final build results
help - display extended usage information";
const string Help = Usage + @" const string Help = Usage + @"
Available targets: Available targets:
vs: Create Visual Studio 2005 project files. vs: Create Visual Studio 2005 project files.
vs9: Create Visual Studio 2008 project files. vs9: Create Visual Studio 2008 project files.
doc: Builds html and pdf documentation. all: Build library, documentation and installer packages.
lib: Build library.
doc: Build html and pdf documentation.
nsis: Build NSIS installer for Windows.
clean: Delete intermediate files but leave final binaries and project clean: Delete intermediate files but leave final binaries and project
files intact. files intact.
distclean: Delete intermediate files, final binaries and project files. distclean: Delete intermediate files, final binaries and project files.
@ -54,17 +63,41 @@ Assembly signing:
"; ";
static readonly Assembly Prebuild = Assembly.Load(Resources.Prebuild); static readonly Assembly Prebuild = Assembly.Load(Resources.Prebuild);
static readonly Version AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
static string ProductVersion { get { return AssemblyVersion.Major + "." + AssemblyVersion.Minor; } }
static string ProductVersionRevision { get { return AssemblyVersion.Build.ToString(); } }
static string ProductVersionExtra
{
get
{
// See discussion here: http://www.opentk.com/node/1420#comment-7554
// 0-99 = alpha
// 100-199 = beta
// 200-299 = rc
// 300 = final
if (AssemblyVersion.Revision < 99)
return "alpha" + AssemblyVersion.Revision % 100;
else if (AssemblyVersion.Revision < 199)
return "beta" + AssemblyVersion.Revision % 100;
else if (AssemblyVersion.Revision < 299)
return "rc" + AssemblyVersion.Revision % 100;
else
return "final";
}
}
enum BuildTarget enum BuildTarget
{ {
None = 0, None = 0,
All,
VS2005, VS2005,
VS2008, VS2008,
Mono, Net20,
Net, // Net40, // Not implemented yet
Clean, Clean,
DistClean, DistClean,
Docs, Docs,
Nsis,
} }
static void PrintUsage() static void PrintUsage()
@ -77,6 +110,7 @@ Assembly signing:
Console.WriteLine(Help); Console.WriteLine(Help);
} }
[STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
@ -90,6 +124,7 @@ Assembly signing:
args[0] = "vs"; args[0] = "vs";
} }
DateTime start = DateTime.Now;
try try
{ {
PrepareBuildFiles(); PrepareBuildFiles();
@ -105,6 +140,9 @@ Assembly signing:
} }
finally finally
{ {
DateTime end = DateTime.Now;
Console.WriteLine("Total build time: {0}", end - start);
// Wait until Prebuild releases the input files. // Wait until Prebuild releases the input files.
System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(2000);
DeleteBuildFiles(); DeleteBuildFiles();
@ -132,14 +170,7 @@ Assembly signing:
File.WriteAllText(quickstart, String.Format(Resources.QuickStart, sign_assembly)); File.WriteAllText(quickstart, String.Format(Resources.QuickStart, sign_assembly));
string doxy = Regex.Replace(Resources.DoxyFile, @"(\{\}|\{\w+\})", ""); string doxy = Regex.Replace(Resources.DoxyFile, @"(\{\}|\{\w+\})", "");
File.WriteAllText(DoxyFile, String.Format(doxy, GetVersion())); File.WriteAllText(DoxyFile, String.Format(doxy, AssemblyVersion.ToString()));
}
// Returns the version of the executing assembly.
static string GetVersion()
{
string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
return version;
} }
// Copies keyfile to the various source directories. This is necessary // Copies keyfile to the various source directories. This is necessary
@ -168,14 +199,17 @@ Assembly signing:
PrintHelp(); PrintHelp();
break; break;
case "mono": case "lib":
case "xbuild": case "lib20":
target = BuildTarget.Mono; target = BuildTarget.Net20;
break; break;
case "net": //case "lib40":
case "msbuild": // target = BuildTarget.Net40;
target = BuildTarget.Net; // break;
case "all":
target = BuildTarget.All;
break; break;
case "vs2005": case "vs2005":
@ -194,6 +228,12 @@ Assembly signing:
target = BuildTarget.Docs; target = BuildTarget.Docs;
break; break;
case "ns":
case "nsi":
case "nsis":
target = BuildTarget.Nsis;
break;
case "clean": case "clean":
target = BuildTarget.Clean; target = BuildTarget.Clean;
break; break;
@ -216,65 +256,33 @@ Assembly signing:
{ {
switch (target) switch (target)
{ {
//case BuildTarget.Mono:
// Console.WriteLine("Building OpenTK using Mono/XBuild.");
// ExecuteProcess(PrebuildPath, "/target nant /file " + PrebuildXml);
// Console.WriteLine();
// ExecuteProcess(
// "nant",
// "-buildfile:./Build/OpenTK.build -t:mono-2.0 " + (mode == BuildMode.Debug ? "build-debug" : "build-release"));
// CopyBinaries();
// break;
//case BuildTarget.Net:
// Console.WriteLine("Building OpenTK using .Net");
// ExecuteProcess(PrebuildPath, "/target nant /file " + PrebuildXml);
// Console.WriteLine();
// ExecuteProcess(
// "nant",
// "-buildfile:./Build/OpenTK.build -t:net-2.0 " + (mode == BuildMode.Debug ? "build-debug" : "build-release"));
// CopyBinaries();
// break;
case BuildTarget.VS2005: case BuildTarget.VS2005:
Console.WriteLine("Creating VS2005 project files"); BuildVS2005();
ExecutePrebuild("/target", "vs2008", "/file", bindings);
ExecutePrebuild("/target", "vs2005", "/file", opentk);
ExecutePrebuild("/target", "vs2005", "/file", quickstart);
break; break;
case BuildTarget.VS2008: case BuildTarget.VS2008:
Console.WriteLine("Creating VS2008 project files"); BuildVS2008();
ExecutePrebuild("/target", "vs2008", "/file", bindings); break;
ExecutePrebuild("/target", "vs2008", "/file", opentk);
ExecutePrebuild("/target", "vs2008", "/file", quickstart); case BuildTarget.All:
BuildVS2005();
BuildProject();
BuildDocumentation();
BuildVS2005(); // Ensure that QuickStart project contains the correct links.
BuildNsis(ProductVersion, ProductVersionRevision, ProductVersionExtra);
break;
case BuildTarget.Net20:
BuildVS2005();
BuildProject();
break; break;
case BuildTarget.Docs: case BuildTarget.Docs:
Console.WriteLine("Generating reference documentation (this may take several minutes)..."); BuildDocumentation();
Console.WriteLine("Generating html sources..."); break;
try { ExecuteCommand("doxygen", null, null); }
catch
{
Console.WriteLine("Failed to run \"doxygen\".");
Console.WriteLine("Please consult the documentation for more information.");
}
string latex_path = Path.Combine(Path.Combine(DocPath, "Source"), "latex"); case BuildTarget.Nsis:
Console.WriteLine("Compiling sources to pdf..."); BuildNsis(null, null, null);
try
{
ExecuteCommand("pdflatex", latex_path, "-interaction=batchmode", "refman.tex");
ExecuteCommand("makeindex", latex_path, "-q", "refman.idx");
ExecuteCommand("pdflatex", latex_path, "-interaction=batchmode", "refman.tex");
}
catch
{
Console.WriteLine("Failed to run \"pdflatex\" or \"makeindex\".");
Console.WriteLine("Please consult the documentation for more information");
}
File.Copy(Path.Combine(latex_path, "refman.pdf"),
Path.Combine(DocPath, ReferenceFile), true);
break; break;
case BuildTarget.Clean: case BuildTarget.Clean:
@ -284,6 +292,7 @@ Assembly signing:
ExecutePrebuild("/clean", "/yes", "/file", quickstart); ExecutePrebuild("/clean", "/yes", "/file", quickstart);
DeleteDirectories(RootPath, "obj"); DeleteDirectories(RootPath, "obj");
DeleteFiles(SourcePath, KeyFile); DeleteFiles(SourcePath, KeyFile);
CleanNsisFiles();
break; break;
case BuildTarget.DistClean: case BuildTarget.DistClean:
@ -296,6 +305,7 @@ Assembly signing:
DeleteDirectories(DocPath, "Source"); DeleteDirectories(DocPath, "Source");
DeleteFiles(DocPath, ReferenceFile); DeleteFiles(DocPath, ReferenceFile);
DeleteFiles(SourcePath, KeyFile); DeleteFiles(SourcePath, KeyFile);
DistCleanNsisFiles();
string binaries_path = Path.Combine(RootPath, "Binaries"); string binaries_path = Path.Combine(RootPath, "Binaries");
try try
@ -318,6 +328,72 @@ Assembly signing:
} }
} }
static void BuildDocumentation()
{
Console.WriteLine("Generating reference documentation (this may take several minutes)...");
Console.WriteLine("Generating html sources...");
try { ExecuteCommand("doxygen", null, null); }
catch
{
Console.WriteLine("Failed to run \"doxygen\".");
Console.WriteLine("Please consult the documentation for more information.");
}
string latex_path = Path.Combine(Path.Combine(DocPath, "Source"), "latex");
Console.WriteLine("Compiling sources to pdf...");
try
{
ExecuteCommand("pdflatex", latex_path, "-interaction=batchmode", "refman.tex");
ExecuteCommand("makeindex", latex_path, "-q", "refman.idx");
ExecuteCommand("pdflatex", latex_path, "-interaction=batchmode", "refman.tex");
}
catch
{
Console.WriteLine("Failed to run \"pdflatex\" or \"makeindex\".");
Console.WriteLine("Please consult the documentation for more information");
}
File.Copy(Path.Combine(latex_path, "refman.pdf"),
Path.Combine(DocPath, ReferenceFile), true);
}
static void BuildVS2005()
{
Console.WriteLine("Creating VS2005 project files");
ExecutePrebuild("/target", "vs2008", "/file", bindings);
ExecutePrebuild("/target", "vs2005", "/file", opentk);
ExecutePrebuild("/target", "vs2005", "/file", quickstart);
PatchPrebuildOutput();
}
static void BuildVS2008()
{
Console.WriteLine("Creating VS2008 project files");
ExecutePrebuild("/target", "vs2008", "/file", bindings);
ExecutePrebuild("/target", "vs2008", "/file", opentk);
ExecutePrebuild("/target", "vs2008", "/file", quickstart);
PatchPrebuildOutput();
}
// Prebuild is fiendishly buggy. Patch a number of known issues
// to ensure its output actually works.
static void PatchPrebuildOutput()
{
// Patch 1: sln files contain paths to csproj in the form of
// "../[current dir]/Source/". If we rename [current dir]
// the generated solutions become invalid. Ugh!
Console.WriteLine("Patching paths in prebuild output");
foreach (string solution in Directory.GetFiles(RootPath, "*.sln", SearchOption.TopDirectoryOnly))
{
// We could use an XmlDocument for extra validation,
// but it's not worth the extra effort. Let's just remove
// the offending part ("../[current dir]") directly.
string sln_data = File.ReadAllText(solution);
string current_dir = RootPath.Substring(RootPath.LastIndexOf(Path.DirectorySeparatorChar) + 1);
sln_data = sln_data.Replace(String.Format("..{0}{1}{0}", Path.DirectorySeparatorChar, current_dir), "");
File.WriteAllText(solution, sln_data);
}
}
static void WaitForExit() static void WaitForExit()
{ {
if (Debugger.IsAttached) if (Debugger.IsAttached)

115
Source/Build/BuildNsis.cs Normal file
View file

@ -0,0 +1,115 @@
#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.Diagnostics;
using System.IO;
namespace OpenTK.Build
{
partial class Project
{
static readonly string NsisPath = Path.Combine("Installers", "Nsis");
// Constructs NSIS installer.
// Note 1: for this to work correctly, we need to construct VS projects,
// compile them and build documentation first. This is not handled here.
// Note 2: if version numbers are not specified, we ask the user explicitly.
static void BuildNsis(string pversion, string prevision, string pextra)
{
if (!CheckNsisInstallation())
return;
Console.WriteLine("IMPORTANT: for a correct NSIS installer, you need to create VS projects, compile them and build documentation first. Use \"Build.exe all\" to do all this automatically.");
if (String.IsNullOrEmpty(pversion) || String.IsNullOrEmpty(prevision) ||
String.IsNullOrEmpty(pextra))
RequestVersionInfo(out pversion, out prevision, out pextra);
string source_nsi = Path.Combine(NsisPath, "opentk.nsi");
string actual_nsi = Path.Combine(NsisPath, "opentk-actual.nsi");
File.WriteAllText(actual_nsi, File.ReadAllText(source_nsi)
.Replace("{{version}}", pversion)
.Replace("{{revision}}", prevision)
.Replace("{{extra}}", pextra));
ExecuteCommand("makensis", NsisPath, Path.GetFullPath(actual_nsi));
File.Delete(actual_nsi);
}
static bool CheckNsisInstallation()
{
Console.WriteLine("Checking for NSIS installation.");
try
{
ExecuteCommand("makensis", null, null);
}
catch (Exception e)
{
Console.WriteLine("Could not detect \"makensis\" command.");
Console.WriteLine("Please install NSIS and ensure its installation folder exists in your path.");
Console.WriteLine("Windows users: download from http://nsis.sourceforge.net");
Console.WriteLine("Ubuntu/Debian users: type \"sudo apt-get install nsis\"");
Console.WriteLine();
Console.WriteLine("Exact error message:");
Console.WriteLine(e.ToString());
return false;
}
Console.WriteLine("Working fine.");
return true;
}
static void RequestVersionInfo(out string pversion, out string prevision, out string pextra)
{
Console.WriteLine("Please specify the following information (press enter for defaults)");
Console.Write("Product version ({0}): ", ProductVersion);
pversion = Console.ReadLine();
Console.Write("Product revision ({0}): ", ProductVersionRevision);
prevision = Console.ReadLine();
Console.Write("Product version extra ({0}): ", ProductVersionExtra);
pextra = Console.ReadLine();
if (String.IsNullOrEmpty(pversion))
pversion = ProductVersion;
if (String.IsNullOrEmpty(prevision))
prevision = ProductVersionRevision;
if (String.IsNullOrEmpty(pextra))
pextra = ProductVersionExtra;
}
static void CleanNsisFiles()
{
DeleteFiles(Path.Combine("Installers", "Nsis"), "opentk-actual.nsi");
}
static void DistCleanNsisFiles()
{
CleanNsisFiles();
DeleteFiles(Path.Combine("Installers", "Nsis"), "*.exe");
}
}
}

View file

@ -0,0 +1,74 @@
#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.IO;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using Microsoft.Build.BuildEngine;
namespace OpenTK.Build
{
partial class Project
{
static void BuildProject()
{
Engine engine = new Engine();
engine.BinPath = RuntimeEnvironment.GetRuntimeDirectory();
engine.RegisterLogger(new ConsoleLogger());
engine.OnlyLogCriticalEvents = true;
string project_path = Path.Combine(RootPath, "OpenTK.sln");
Microsoft.Build.BuildEngine.Project project = new Microsoft.Build.BuildEngine.Project(engine);
project.Load(project_path);
project.GlobalProperties.SetProperty("Configuration", "Release");
project.Build();
project.Load(project_path);
project.GlobalProperties.SetProperty("Configuration", "Debug");
project.Build();
// For some reason, xbuild doesn't copy xml docs to the output directory.
// Let's do that by hand.
CopyXMLDocs();
}
static void CopyXMLDocs()
{
string binaries_path = Path.Combine(Path.Combine(RootPath, "Binaries"), "OpenTK");
foreach (string file in Directory.GetFiles(SourcePath, "OpenTK*.xml", SearchOption.AllDirectories))
{
if (Path.GetFileName(file).Contains("Prebuild"))
continue;
File.Copy(file, Path.Combine(Path.Combine(binaries_path, "Release"), Path.GetFileName(file)), true);
File.Copy(file, Path.Combine(Path.Combine(binaries_path, "Debug"), Path.GetFileName(file)), true);
}
}
}
}

View file

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("The Open Toolkit Library Build Script")] [assembly: AssemblyTitle("OpenTK.Build")]
[assembly: AssemblyDescription("Cross-platform build script for OpenTK")] [assembly: AssemblyDescription("Cross-platform build script for OpenTK")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Open Toolkit Library")] [assembly: AssemblyCompany("The Open Toolkit Library")]
[assembly: AssemblyProduct("The Open Toolkit Library")] [assembly: AssemblyProduct("The Open Toolkit Library")]
[assembly: AssemblyCopyright("Copyright © 2006-2009 the Open Toolkit Library")] [assembly: AssemblyCopyright("Copyright © 2006-2010 the Open Toolkit Library")]
[assembly: AssemblyTrademark("OpenTK")] [assembly: AssemblyTrademark("OpenTK")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -29,8 +29,8 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.9.9.4")] [assembly: AssemblyVersion("1.0.0.201")]
[assembly: AssemblyFileVersion("0.9.9.4")] [assembly: AssemblyFileVersion("1.0.0.201")]
#if SIGN_ASSEMBLY #if SIGN_ASSEMBLY
[assembly: AssemblyKeyFile(@"../../../OpenTK.snk")] [assembly: AssemblyKeyFile(@"../../../OpenTK.snk")]

View file

@ -61,7 +61,7 @@ namespace OpenTK.Build.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to # Doxyfile 1.6.1 /// Looks up a localized string similar to # Doxyfile 1.6.2
/// ///
///# This file describes the settings to be used by the documentation system ///# This file describes the settings to be used by the documentation system
///# doxygen (www.doxygen.org) for a project ///# doxygen (www.doxygen.org) for a project
@ -74,7 +74,7 @@ namespace OpenTK.Build.Properties {
///# Values that contain spaces should be placed between quotes (&quot; &quot;) ///# Values that contain spaces should be placed between quotes (&quot; &quot;)
/// ///
///#--------------------------------------------------------------------------- ///#---------------------------------------------------------------------------
///# Project relate [rest of string was truncated]&quot;;. ///# Project related configurati [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string DoxyFile { internal static string DoxyFile {
get { get {

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@ -119,21 +119,21 @@
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="DoxyFile" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="DoxyFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DoxyFile.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value> <value>../Resources/DoxyFile.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value>
</data> </data>
<data name="Generator" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Generator" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Generator.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> <value>../Resources/Generator.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data> </data>
<data name="OpenTK" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="OpenTK" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\OpenTK.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> <value>../Resources/OpenTK.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data> </data>
<data name="Prebuild" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Prebuild" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Prebuild.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>../Resources/Prebuild.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="Prebuild_License" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Prebuild_License" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Prebuild License.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> <value>../Resources/Prebuild License.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data> </data>
<data name="QuickStart" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="QuickStart" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\QuickStart.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> <value>../Resources/QuickStart.Prebuild.xml;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data> </data>
</root> </root>

View file

@ -664,7 +664,7 @@ EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories # against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/* # for example use the pattern */test/*
EXCLUDE_PATTERNS = EXCLUDE_PATTERNS = */.svn/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the # (namespaces, classes, functions, etc.) that should be excluded from the

View file

@ -77,6 +77,8 @@
</Configuration> </Configuration>
<Reference name="System"/> <Reference name="System"/>
<Reference name="Microsoft.Build.Engine"/>
<Reference name="Microsoft.Build.Framework"/>
<Files> <Files>
<Match path="." pattern="*.cs" recurse="true"/> <Match path="." pattern="*.cs" recurse="true"/>
@ -148,10 +150,12 @@
<Files> <Files>
<Match path="." pattern="*.cs" recurse="true"/> <Match path="." pattern="*.cs" recurse="true"/>
<Match path="." pattern="*.rtf" recurse="true" buildAction="EmbeddedResource" /> <Match path="." pattern="*.rtf" recurse="true" buildAction="EmbeddedResource">
<Exclude name="obj"/>
</Match>
<Match path="." pattern="*.resx" recurse="true" buildAction="EmbeddedResource"/> <Match path="." pattern="*.resx" recurse="true" buildAction="EmbeddedResource"/>
<Match path="../Examples/Data" pattern="^.*\.(bmp|png|jpg|txt|glsl|wav|ogg|dds|ico)$" useRegex="true" recurse="true" buildAction="None" copyToOutput="Always"/> <Match path="Data" pattern="^.*\.(bmp|png|jpg|txt|glsl|wav|ogg|dds|ico)$" useRegex="true" recurse="true" buildAction="None" copyToOutput="Always"/>
<Match path="../Examples/Resources" pattern="^.*\.(bmp|png|jpg|txt|glsl|wav|ogg|dds|ico)$" useRegex="true" recurse="true" buildAction="None"/> <Match path="Resources" pattern="^.*\.(bmp|png|jpg|txt|glsl|wav|ogg|dds|ico)$" useRegex="true" recurse="true" buildAction="None"/>
<Match path="../OpenTK" pattern="OpenTK.dll.config" buildAction="None" copyToOutput="Always"/> <Match path="../OpenTK" pattern="OpenTK.dll.config" buildAction="None" copyToOutput="Always"/>
<Match path="../OpenTK" pattern="OpenTK.Compatibility.dll.config" buildAction="None" copyToOutput="Always"/> <Match path="../OpenTK" pattern="OpenTK.Compatibility.dll.config" buildAction="None" copyToOutput="Always"/>
</Files> </Files>

View file

@ -6,12 +6,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("The Open Toolkit Compatilibity Module")] [assembly: AssemblyTitle("OpenTK.Compatibility")]
[assembly: AssemblyDescription("Provides compatibility with previous versions of OpenTK and the Tao framework.")] [assembly: AssemblyDescription("Provides compatibility with previous versions of OpenTK and the Tao framework.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Open Toolkit Library")] [assembly: AssemblyCompany("The Open Toolkit Library")]
[assembly: AssemblyProduct("The Open Toolkit Library")] [assembly: AssemblyProduct("The Open Toolkit Library")]
[assembly: AssemblyCopyright("Copyright © 2006-2009 the Open Toolkit Library")] [assembly: AssemblyCopyright("Copyright © 2006-2010 the Open Toolkit Library")]
[assembly: AssemblyTrademark("OpenTK")] [assembly: AssemblyTrademark("OpenTK")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -30,11 +30,14 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.9.9.4")] [assembly: AssemblyVersion("1.0.0.201")]
[assembly: AssemblyFileVersion("0.9.9.4")] [assembly: AssemblyFileVersion("1.0.0.201")]
[assembly: System.CLSCompliant(true)] [assembly: System.CLSCompliant(true)]
[assembly: System.Security.AllowPartiallyTrustedCallers] [assembly: System.Security.AllowPartiallyTrustedCallers]
#if NET40
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
#endif
#if SIGN_ASSEMBLY #if SIGN_ASSEMBLY
[assembly: AssemblyKeyFile(@"../../../OpenTK.snk")] [assembly: AssemblyKeyFile(@"../../../OpenTK.snk")]

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4918 // Runtime Version:2.0.50727.4927
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@ -119,6 +119,6 @@
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TaoButton" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="TaoButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\TaoButton.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>../Resources/TaoButton.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,13 +23,13 @@ namespace Examples
public bool Visible { get { return visible; } set { visible = value; } } public bool Visible { get { return visible; } set { visible = value; } }
public ExampleAttribute(string title, ExampleCategory category, string subcategory) public ExampleAttribute(string title, ExampleCategory category, string subcategory)
: this(title, category, subcategory, 0, true) { } : this(title, category, subcategory, Int32.MaxValue, true) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty) public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty)
: this(title, category, subcategory, difficulty, true) { } : this(title, category, subcategory, difficulty, true) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, bool visible) public ExampleAttribute(string title, ExampleCategory category, string subcategory, bool visible)
: this(title, category, subcategory, 0, visible) { } : this(title, category, subcategory, Int32.MaxValue, visible) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty, bool visible) public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty, bool visible)
{ {

View file

@ -37,7 +37,6 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.viewDescriptionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewDescriptionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.viewSourceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewSourceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.imageListSampleCategories = new System.Windows.Forms.ImageList(this.components);
this.tabControlSample = new System.Windows.Forms.TabControl(); this.tabControlSample = new System.Windows.Forms.TabControl();
this.tabDescription = new System.Windows.Forms.TabPage(); this.tabDescription = new System.Windows.Forms.TabPage();
this.richTextBoxDescription = new System.Windows.Forms.RichTextBox(); this.richTextBoxDescription = new System.Windows.Forms.RichTextBox();
@ -51,6 +50,7 @@
this.textBoxOutput = new System.Windows.Forms.TextBox(); this.textBoxOutput = new System.Windows.Forms.TextBox();
this.contextMenuStripOutput = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStripOutput = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.copyToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.imageListSampleCategories = new System.Windows.Forms.ImageList(this.components);
this.toolTipSamples = new System.Windows.Forms.ToolTip(this.components); this.toolTipSamples = new System.Windows.Forms.ToolTip(this.components);
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@ -91,7 +91,7 @@
this.treeViewSamples.HotTracking = true; this.treeViewSamples.HotTracking = true;
this.treeViewSamples.ImageIndex = 0; this.treeViewSamples.ImageIndex = 0;
this.treeViewSamples.ImageList = this.imageListSampleCategories; this.treeViewSamples.ImageList = this.imageListSampleCategories;
this.treeViewSamples.Indent = 71; this.treeViewSamples.Indent = 32;
this.treeViewSamples.Location = new System.Drawing.Point(0, 0); this.treeViewSamples.Location = new System.Drawing.Point(0, 0);
this.treeViewSamples.Name = "treeViewSamples"; this.treeViewSamples.Name = "treeViewSamples";
this.treeViewSamples.SelectedImageIndex = 0; this.treeViewSamples.SelectedImageIndex = 0;
@ -138,31 +138,6 @@
this.viewSourceToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.viewSourceToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
this.viewSourceToolStripMenuItem.Text = "View Source Code"; this.viewSourceToolStripMenuItem.Text = "View Source Code";
// //
// imageListSampleCategories
//
this.imageListSampleCategories.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListSampleCategories.ImageStream")));
this.imageListSampleCategories.TransparentColor = System.Drawing.Color.Transparent;
this.imageListSampleCategories.Images.SetKeyName(0, "OpenAL.jpg");
this.imageListSampleCategories.Images.SetKeyName(1, "OpenGL.jpg");
this.imageListSampleCategories.Images.SetKeyName(2, "1.1.jpg");
this.imageListSampleCategories.Images.SetKeyName(3, "1.2.jpg");
this.imageListSampleCategories.Images.SetKeyName(4, "1.3.jpg");
this.imageListSampleCategories.Images.SetKeyName(5, "1.4.jpg");
this.imageListSampleCategories.Images.SetKeyName(6, "1.5.jpg");
this.imageListSampleCategories.Images.SetKeyName(7, "2.0.jpg");
this.imageListSampleCategories.Images.SetKeyName(8, "2.1.jpg");
this.imageListSampleCategories.Images.SetKeyName(9, "3.0.jpg");
this.imageListSampleCategories.Images.SetKeyName(10, "3.1.jpg");
this.imageListSampleCategories.Images.SetKeyName(11, "GLSL.jpg");
this.imageListSampleCategories.Images.SetKeyName(12, "FBO.jpg");
this.imageListSampleCategories.Images.SetKeyName(13, "EFX.jpg");
this.imageListSampleCategories.Images.SetKeyName(14, "GameWindow.jpg");
this.imageListSampleCategories.Images.SetKeyName(15, "GLControl.jpg");
this.imageListSampleCategories.Images.SetKeyName(16, "Test.jpg");
this.imageListSampleCategories.Images.SetKeyName(17, "Fonts.jpg");
this.imageListSampleCategories.Images.SetKeyName(18, "OpenTK.jpg");
this.imageListSampleCategories.Images.SetKeyName(19, "OpenCL.png");
//
// tabControlSample // tabControlSample
// //
this.tabControlSample.Controls.Add(this.tabDescription); this.tabControlSample.Controls.Add(this.tabDescription);
@ -288,6 +263,20 @@
this.copyToolStripMenuItem2.Size = new System.Drawing.Size(102, 22); this.copyToolStripMenuItem2.Size = new System.Drawing.Size(102, 22);
this.copyToolStripMenuItem2.Text = "&Copy"; this.copyToolStripMenuItem2.Text = "&Copy";
// //
// imageListSampleCategories
//
this.imageListSampleCategories.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListSampleCategories.ImageStream")));
this.imageListSampleCategories.TransparentColor = System.Drawing.Color.Transparent;
this.imageListSampleCategories.Images.SetKeyName(0, "OpenAL.png");
this.imageListSampleCategories.Images.SetKeyName(1, "OpenCL.png");
this.imageListSampleCategories.Images.SetKeyName(2, "OpenGL.png");
this.imageListSampleCategories.Images.SetKeyName(3, "OpenGLES.png");
this.imageListSampleCategories.Images.SetKeyName(4, "OpenTK.png");
this.imageListSampleCategories.Images.SetKeyName(5, "1.x.png");
this.imageListSampleCategories.Images.SetKeyName(6, "2.x.png");
this.imageListSampleCategories.Images.SetKeyName(7, "3.x.png");
this.imageListSampleCategories.Images.SetKeyName(8, "4.x.png");
//
// ExampleBrowser // ExampleBrowser
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -33,6 +33,7 @@ using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using OpenTK.Examples.Properties; using OpenTK.Examples.Properties;
using System.Threading; using System.Threading;
using System.IO;
namespace Examples namespace Examples
{ {
@ -44,6 +45,8 @@ namespace Examples
bool show_warning = true; bool show_warning = true;
static readonly string SourcePath = FindSourcePath();
#endregion #endregion
#region Constructors #region Constructors
@ -108,16 +111,35 @@ namespace Examples
if (e.Node.Tag != null && !String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation)) if (e.Node.Tag != null && !String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation))
{ {
string docs = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation + "Doc"); string docs = null;
string source = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation); string source = null;
ExampleInfo einfo = (ExampleInfo)e.Node.Tag;
string sample = einfo.Attribute.Documentation;
string category = einfo.Attribute.Category.ToString();
string subcategory = einfo.Attribute.Subcategory;
string path = Path.Combine(Path.Combine(Path.Combine(SourcePath, category), subcategory), sample);
string sample_rtf = Path.ChangeExtension(path, "rtf");
string sample_cs = Path.ChangeExtension(path, "cs");
if (File.Exists(sample_rtf))
{
docs = File.ReadAllText(sample_rtf);
}
if (File.Exists(sample_cs))
{
source = File.ReadAllText(sample_cs);
}
if (String.IsNullOrEmpty(docs)) if (String.IsNullOrEmpty(docs))
richTextBoxDescription.Text = no_docs; richTextBoxDescription.Text = String.Format("File {0} not found.", sample_rtf);
else else
richTextBoxDescription.Rtf = docs; richTextBoxDescription.Rtf = docs;
if (String.IsNullOrEmpty(source)) if (String.IsNullOrEmpty(source))
richTextBoxSource.Text = no_source; richTextBoxSource.Text = String.Format("File {0} not found.", sample_cs);
else else
richTextBoxSource.Text = source; richTextBoxSource.Text = source;
} }
@ -312,7 +334,7 @@ namespace Examples
if (list.Images.ContainsKey(category.ToString() + ".png")) if (list.Images.ContainsKey(category.ToString() + ".png"))
return list.Images.IndexOfKey(category.ToString() + ".png"); return list.Images.IndexOfKey(category.ToString() + ".png");
return 0; return -1;
} }
static void RunSample(Control parent, ExampleInfo e) static void RunSample(Control parent, ExampleInfo e)
@ -335,26 +357,32 @@ namespace Examples
Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title)); Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title));
Trace.WriteLine(String.Empty); Trace.WriteLine(String.Empty);
Thread thread = new Thread((ThreadStart)delegate { main.Invoke(null, null); }); 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.IsBackground = true;
thread.Start(); thread.Start();
thread.Join(); thread.Join();
} }
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);
}
finally finally
{ {
if (parent != null) if (parent != null)
@ -370,7 +398,54 @@ namespace Examples
} }
} }
#endregion // Tries to detect the path that contains the source for the examples.
static string FindSourcePath()
{
string current_dir = Directory.GetCurrentDirectory();
// 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)
break;
guess = dir.FullName;
}
if (CheckPath(ref guess))
return guess; // We were in [opentk]/Binaries/OpenTK/[config] after all
throw new DirectoryNotFoundException();
}
static bool CheckPath(ref string path)
{
string guess = path;
if (Directory.Exists(guess))
{
guess = Path.Combine(guess, "Source");
if (Directory.Exists(guess))
{
guess = Path.Combine(guess, "Examples");
if (Directory.Exists(guess))
{
// We are have found [opentk]/Source/Examples
path = guess;
return true;
}
}
}
return false;
}
#endregion
#endregion #endregion
} }

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -81,8 +81,6 @@ namespace Examples
{ {
using (AudioContext context = new AudioContext()) using (AudioContext context = new AudioContext())
{ {
Trace.WriteLine("Testing WaveReader({0}).ReadToEnd()", filename);
int buffer = AL.GenBuffer(); int buffer = AL.GenBuffer();
int source = AL.GenSource(); int source = AL.GenSource();
int state; int state;

Binary file not shown.

View file

@ -43,7 +43,7 @@ using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Display Lists", ExampleCategory.OpenGL, "1.1", Documentation="DisplayLists")] [Example("Display Lists", ExampleCategory.OpenGL, "1.x", 2, Documentation="DisplayLists")]
public class T07_Display_Lists_Flower : GameWindow public class T07_Display_Lists_Flower : GameWindow
{ {
#region --- Fields --- #region --- Fields ---

Binary file not shown.

View file

@ -17,7 +17,7 @@ using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Framebuffer Objects", ExampleCategory.OpenGL, "FBO", Documentation="FramebufferObject")] [Example("Framebuffer Objects", ExampleCategory.OpenGL, "1.x", Documentation="FramebufferObject")]
public class SimpleFBO : GameWindow public class SimpleFBO : GameWindow
{ {
public SimpleFBO() public SimpleFBO()

View file

@ -25,7 +25,7 @@ namespace Examples.Tutorial
/// <summary> /// <summary>
/// Demonstrates immediate mode rendering. /// Demonstrates immediate mode rendering.
/// </summary> /// </summary>
[Example("Immediate mode", ExampleCategory.OpenGL, "1.1", Documentation="ImmediateMode")] [Example("Immediate mode", ExampleCategory.OpenGL, "1.x", 1, Documentation="ImmediateMode")]
public class T03_Immediate_Mode_Cube : GameWindow public class T03_Immediate_Mode_Cube : GameWindow
{ {
#region --- Fields --- #region --- Fields ---

Binary file not shown.

View file

@ -17,7 +17,7 @@ namespace Examples.Tutorial
/// Each Id is a uint, split into 4 bytes and used as triangle color. In an extra pass, the screen is cleared to uint.MaxValue, /// Each Id is a uint, split into 4 bytes and used as triangle color. In an extra pass, the screen is cleared to uint.MaxValue,
/// and then the mesh is drawn using color. Using GL.ReadPixels() the value under the mouse cursor is read and can be converted. /// and then the mesh is drawn using color. Using GL.ReadPixels() the value under the mouse cursor is read and can be converted.
/// </summary> /// </summary>
[Example("Picking", ExampleCategory.OpenGL, "1.1", Documentation = "Picking")] [Example("Picking", ExampleCategory.OpenGL, "1.x", Documentation = "Picking")]
class Picking : GameWindow class Picking : GameWindow
{ {
/// <summary>Creates a 800x600 window with the specified title.</summary> /// <summary>Creates a 800x600 window with the specified title.</summary>

Binary file not shown.

View file

@ -13,7 +13,7 @@ using Examples.Shapes;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Stencil CSG", ExampleCategory.OpenGL, "1.1", Documentation = "StencilCSG")] [Example("Stencil CSG", ExampleCategory.OpenGL, "1.x", Documentation = "StencilCSG")]
partial class StencilCSG: GameWindow partial class StencilCSG: GameWindow
{ {
#region Model Related #region Model Related

Binary file not shown.

View file

@ -10,15 +10,15 @@ using OpenTK.Input;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Texture Matrix Wormhole", ExampleCategory.OpenGL, "1.1", Documentation = "TextureMatrix")] [Example("Texture Matrix Wormhole", ExampleCategory.OpenGL, "1.x", Documentation = "TextureMatrix")]
class TextureMatrix : GameWindow class TextureMatrix : GameWindow
{ {
public TextureMatrix() public TextureMatrix()
: base(800, 600 ) : base(800, 600, new GraphicsMode(32, 16, 0, 4))
{ {
VSync = VSyncMode.Off; VSync = VSyncMode.On;
} }
int Texture; int Texture;
@ -119,18 +119,27 @@ namespace Examples.Tutorial
GL.GenTextures(1, out texture); GL.GenTextures(1, out texture);
GL.BindTexture(Target, texture); GL.BindTexture(Target, texture);
float version = Single.Parse(GL.GetString(StringName.Version).Substring(0, 3), System.Globalization.CultureInfo.InvariantCulture);
if (version >= 1.4)
{
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, (int)All.True);
GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
}
else
{
GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
}
GL.TexParameter(Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(Target, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
GL.TexParameter(Target, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
Bitmap bitmap = new Bitmap(filename); Bitmap bitmap = new Bitmap(filename);
BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(Target, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); GL.TexImage2D(Target, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
GL.Finish(); GL.Finish();
bitmap.UnlockBits(data); bitmap.UnlockBits(data);
GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(Target, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
GL.TexParameter(Target, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
if (GL.GetError() != ErrorCode.NoError) if (GL.GetError() != ErrorCode.NoError)
throw new Exception("Error loading texture " + filename); throw new Exception("Error loading texture " + filename);

Binary file not shown.

View file

@ -22,7 +22,7 @@ namespace Examples.Tutorial
/// <summary> /// <summary>
/// Demonstrates simple OpenGL Texturing. /// Demonstrates simple OpenGL Texturing.
/// </summary> /// </summary>
[Example("Texture mapping", ExampleCategory.OpenGL, "1.1", Documentation="Textures")] [Example("Texture mapping", ExampleCategory.OpenGL, "1.x", 5, Documentation="Textures")]
public class Textures : GameWindow public class Textures : GameWindow
{ {
Bitmap bitmap = new Bitmap("Data/Textures/logo.jpg"); Bitmap bitmap = new Bitmap("Data/Textures/logo.jpg");

Binary file not shown.

View file

@ -8,7 +8,7 @@ using OpenTK.Input;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Dynamic Vertex Buffer Objects", ExampleCategory.OpenGL, "VBO", Documentation = "DynamicVBO")] [Example("VBO Dynamic", ExampleCategory.OpenGL, "1.x", 4, Documentation = "VBODynamic")]
class T09_VBO_Dynamic: GameWindow class T09_VBO_Dynamic: GameWindow
{ {
/// <summary>Creates a 800x600 window with the specified title.</summary> /// <summary>Creates a 800x600 window with the specified title.</summary>

Binary file not shown.

View file

@ -22,7 +22,7 @@ using System.Drawing;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Static Vertex Buffer Objects", ExampleCategory.OpenGL, "VBO", Documentation="VertexBufferObject")] [Example("VBO Static", ExampleCategory.OpenGL, "1.x", 3, Documentation="VBOStatic")]
public class T08_VBO : GameWindow public class T08_VBO : GameWindow
{ {
const float rotation_speed = 180.0f; const float rotation_speed = 180.0f;

Binary file not shown.

View file

@ -22,7 +22,7 @@ namespace Examples.Tutorial
/// Demonstrates Vertex Arrays (in system memory). Example is incomplete (documentation). /// Demonstrates Vertex Arrays (in system memory). Example is incomplete (documentation).
/// Broken since release 0.3.12. /// Broken since release 0.3.12.
/// </summary> /// </summary>
[Example("Vertex Arrays", ExampleCategory.OpenGL, "1.1", 5, false)] [Example("Vertex Arrays", ExampleCategory.OpenGL, "1.x", 5, false)]
class T02_Vertex_Arrays : GameWindow class T02_Vertex_Arrays : GameWindow
{ {
float rotation_speed = 3.0f; float rotation_speed = 3.0f;

View file

@ -18,7 +18,7 @@ namespace Examples.Tutorial
/// <summary> /// <summary>
/// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation). /// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation).
/// </summary> /// </summary>
[Example("Vertex Lighting", ExampleCategory.OpenGL, "1.1", false)] [Example("Vertex Lighting", ExampleCategory.OpenGL, "1.x", false)]
public class T04_Vertex_Lighting : GameWindow public class T04_Vertex_Lighting : GameWindow
{ {
float x_angle, zoom; float x_angle, zoom;

View file

@ -23,7 +23,7 @@ using Examples.TextureLoaders;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("DDS Cube Map", ExampleCategory.OpenGL, "GLSL", Documentation = "DDSCubeMap")] [Example("DDS Cube Map", ExampleCategory.OpenGL, "2.x", Documentation = "DDSCubeMap")]
public class T13_GLSL_Earth: GameWindow public class T13_GLSL_Earth: GameWindow
{ {
public T13_GLSL_Earth( ) public T13_GLSL_Earth( )

View file

@ -36,7 +36,7 @@ using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Basic Geometry Shader", ExampleCategory.OpenGL, "GLSL", Documentation = "Simple usage of EXT_geometry_shader4")] [Example("Basic Geometry Shader", ExampleCategory.OpenGL, "2.x", Documentation = "Simple usage of EXT_geometry_shader4")]
public class SimpleGeometryShader : GameWindow public class SimpleGeometryShader : GameWindow
{ {
public SimpleGeometryShader() public SimpleGeometryShader()

View file

@ -63,7 +63,7 @@ using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("Advanced Geometry Shader", ExampleCategory.OpenGL, "GLSL", Documentation = "Advanced usage of EXT_geometry_shader4")] [Example("Advanced Geometry Shader", ExampleCategory.OpenGL, "2.x", Documentation = "Advanced usage of EXT_geometry_shader4")]
public class SimpleGeometryShader2 : GameWindow public class SimpleGeometryShader2 : GameWindow
{ {
public SimpleGeometryShader2() public SimpleGeometryShader2()

View file

@ -28,7 +28,7 @@ namespace Examples.Tutorial
/// One more major optimization could be applied (exploit the symmetry of the image with RTT), but /// One more major optimization could be applied (exploit the symmetry of the image with RTT), but
/// that would make the program alot more complicated to follow. You can do this as an exercise. /// that would make the program alot more complicated to follow. You can do this as an exercise.
/// </summary> /// </summary>
[Example("Julia Set Fractal", ExampleCategory.OpenGL, "GLSL", Documentation="JuliaSetFractal")] [Example("Julia Set Fractal", ExampleCategory.OpenGL, "2.x", Documentation = "JuliaSetFractal")]
public class JuliaSetFractal : GameWindow public class JuliaSetFractal : GameWindow
{ {
public JuliaSetFractal() public JuliaSetFractal()

View file

@ -29,7 +29,7 @@ namespace Examples.Tutorial
/// <summary> /// <summary>
/// Demonstrates how to load and use a simple OpenGL shader program. Example is incomplete (documentation). /// Demonstrates how to load and use a simple OpenGL shader program. Example is incomplete (documentation).
/// </summary> /// </summary>
[Example("First shader", ExampleCategory.OpenGL, "GLSL", Documentation="SimpleGLSL")] [Example("First shader", ExampleCategory.OpenGL, "2.x", Documentation = "SimpleGLSL")]
public class T10_GLSL_Cube : GameWindow public class T10_GLSL_Cube : GameWindow
{ {
#region --- Fields --- #region --- Fields ---

View file

@ -22,7 +22,7 @@ namespace Examples.Tutorial
/// <summary>Demonstrates Swizzled DXT5 Parallax Mapping /// <summary>Demonstrates Swizzled DXT5 Parallax Mapping
/// The idea is described in more detail right here: http://www.opentk.com/node/394 /// The idea is described in more detail right here: http://www.opentk.com/node/394
/// </summary> /// </summary>
[Example("Swizzled Parallax Mapping", ExampleCategory.OpenGL, "GLSL", Documentation = "SwizzledParallax")] [Example("Swizzled Parallax Mapping", ExampleCategory.OpenGL, "2.x", Documentation = "SwizzledParallax")]
public class T12_GLSL_Parallax: GameWindow public class T12_GLSL_Parallax: GameWindow
{ {
public T12_GLSL_Parallax( ) public T12_GLSL_Parallax( )

View file

@ -35,7 +35,7 @@ using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial namespace Examples.Tutorial
{ {
[Example("OpenGL 3.0", ExampleCategory.OpenGL, "3.0", Documentation="HelloGL3")] [Example("OpenGL 3.0", ExampleCategory.OpenGL, "3.x", Documentation="HelloGL3")]
public class HelloGL3 : GameWindow public class HelloGL3 : GameWindow
{ {
string vertexShaderSource = @" string vertexShaderSource = @"
@ -65,7 +65,7 @@ void main(void)
precision highp float; precision highp float;
const vec3 ambient = vec3(0.1, 0.1, 0.1); const vec3 ambient = vec3(0.1, 0.1, 0.1);
const vec3 lightVecNormalized = normalize(vec3(0.5, 0.5, 2)); const vec3 lightVecNormalized = normalize(vec3(0.5, 0.5, 2.0));
const vec3 lightColor = vec3(0.9, 0.9, 0.7); const vec3 lightColor = vec3(0.9, 0.9, 0.7);
in vec3 normal; in vec3 normal;
@ -85,7 +85,8 @@ void main(void)
projectionMatrixLocation, projectionMatrixLocation,
vaoHandle, vaoHandle,
positionVboHandle, positionVboHandle,
normalVboHandle; normalVboHandle,
eboHandle;
Vector3[] positionVboData = new Vector3[]{ Vector3[] positionVboData = new Vector3[]{
new Vector3(-1.0f, -1.0f, 1.0f), new Vector3(-1.0f, -1.0f, 1.0f),
@ -122,7 +123,19 @@ void main(void)
protected override void OnLoad (System.EventArgs e) protected override void OnLoad (System.EventArgs e)
{ {
// Create shaders VSync = VSyncMode.On;
CreateShaders();
CreateVBOs();
CreateVAOs();
// Other state
GL.Enable(EnableCap.DepthTest);
GL.ClearColor(System.Drawing.Color.MidnightBlue);
}
void CreateShaders()
{
vertexShaderHandle = GL.CreateShader(ShaderType.VertexShader); vertexShaderHandle = GL.CreateShader(ShaderType.VertexShader);
fragmentShaderHandle = GL.CreateShader(ShaderType.FragmentShader); fragmentShaderHandle = GL.CreateShader(ShaderType.FragmentShader);
@ -131,7 +144,7 @@ void main(void)
GL.CompileShader(vertexShaderHandle); GL.CompileShader(vertexShaderHandle);
GL.CompileShader(fragmentShaderHandle); GL.CompileShader(fragmentShaderHandle);
Debug.WriteLine(GL.GetShaderInfoLog(vertexShaderHandle)); Debug.WriteLine(GL.GetShaderInfoLog(vertexShaderHandle));
Debug.WriteLine(GL.GetShaderInfoLog(fragmentShaderHandle)); Debug.WriteLine(GL.GetShaderInfoLog(fragmentShaderHandle));
@ -154,14 +167,13 @@ void main(void)
float aspectRatio = ClientSize.Width / (float)(ClientSize.Height); float aspectRatio = ClientSize.Width / (float)(ClientSize.Height);
Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspectRatio, 1, 100, out projectionMatrix); Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspectRatio, 1, 100, out projectionMatrix);
modelviewMatrix = Matrix4.LookAt(new Vector3(0, 3, 5), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); modelviewMatrix = Matrix4.LookAt(new Vector3(0, 3, 5), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
GL.UniformMatrix4(projectionMatrixLocation, false, ref projectionMatrix); GL.UniformMatrix4(projectionMatrixLocation, false, ref projectionMatrix);
GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix); GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
}
// Create vertex buffer void CreateVBOs()
GL.GenVertexArrays(1, out vaoHandle); {
GL.BindVertexArray(vaoHandle);
GL.GenBuffers(1, out positionVboHandle); GL.GenBuffers(1, out positionVboHandle);
GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
@ -174,18 +186,38 @@ void main(void)
new IntPtr(positionVboData.Length * Vector3.SizeInBytes), new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
positionVboData, BufferUsageHint.StaticDraw); positionVboData, BufferUsageHint.StaticDraw);
GL.GenBuffers(1, out eboHandle);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
GL.BufferData(BufferTarget.ElementArrayBuffer,
new IntPtr(sizeof(uint) * indicesVboData.Length),
indicesVboData, BufferUsageHint.StaticDraw);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
}
void CreateVAOs()
{
// GL3 allows us to store the vertex layout in a "vertex array object" (VAO).
// This means we do not have to re-issue VertexAttribPointer calls
// every time we try to use a different vertex layout - these calls are
// stored in the VAO so we simply need to bind the correct VAO.
GL.GenVertexArrays(1, out vaoHandle);
GL.BindVertexArray(vaoHandle);
GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(0);
GL.EnableVertexAttribArray(1); GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
GL.BindAttribLocation(shaderProgramHandle, 0, "in_position"); GL.BindAttribLocation(shaderProgramHandle, 0, "in_position");
GL.EnableVertexAttribArray(1);
GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
GL.BindAttribLocation(shaderProgramHandle, 1, "in_normal"); GL.BindAttribLocation(shaderProgramHandle, 1, "in_normal");
// Other state GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
GL.Enable(EnableCap.DepthTest);
GL.ClearColor(System.Drawing.Color.MidnightBlue); GL.BindVertexArray(0);
} }
protected override void OnUpdateFrame(FrameEventArgs e) protected override void OnUpdateFrame(FrameEventArgs e)
@ -193,7 +225,7 @@ void main(void)
Matrix4 rotation = Matrix4.CreateRotationY((float)e.Time); Matrix4 rotation = Matrix4.CreateRotationY((float)e.Time);
Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix); Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix);
GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix); GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
if (Keyboard[OpenTK.Input.Key.Escape]) if (Keyboard[OpenTK.Input.Key.Escape])
Exit(); Exit();
} }
@ -204,8 +236,9 @@ void main(void)
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.BindVertexArray(vaoHandle);
GL.DrawElements(BeginMode.Triangles, indicesVboData.Length, GL.DrawElements(BeginMode.Triangles, indicesVboData.Length,
DrawElementsType.UnsignedInt, indicesVboData); DrawElementsType.UnsignedInt, IntPtr.Zero);
SwapBuffers(); SwapBuffers();
} }

View file

@ -1,27 +1,15 @@
#region --- License --- // This code is in the Public Domain. It is provided "as is"
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos // without express or implied warranty of any kind.
* See license.txt for license info
*/
#endregion
#region --- Using directives ---
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
#endregion
namespace Examples.WinForms namespace Examples.WinForms
{ {
[Example("Simple GLControl", ExampleCategory.OpenTK, "GLControl", 1, Documentation="SimpleGLControl")] [Example("GLControl Simple", ExampleCategory.OpenTK, "GLControl", 1, Documentation="GLControlSimple")]
public partial class SimpleForm : Form public partial class SimpleForm : Form
{ {
public SimpleForm() public SimpleForm()

Binary file not shown.

View file

@ -1,43 +1,16 @@
#region License // This code is in the Public Domain. It is provided "as is"
// // without express or implied warranty of any kind.
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2009 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
using System; using System;
using System.Collections.Generic; using System.Drawing;
using System.Text;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
using OpenTK.Input; using OpenTK.Input;
using System.Drawing;
namespace Examples namespace Examples
{ {
[Example("Fullscreen Antialiasing", ExampleCategory.OpenTK, "GameWindow", Documentation = "GameWindowFsaa")] [Example("GameWindow MSAA", ExampleCategory.OpenTK, "GameWindow", 2, Documentation = "GameWindowMsaa")]
public class FullscreenAntialias : GameWindow public class FullscreenAntialias : GameWindow
{ {
public FullscreenAntialias() public FullscreenAntialias()

Binary file not shown.

View file

@ -1,15 +1,8 @@
#region --- License --- // This code is in the Public Domain. It is provided "as is"
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos // without express or implied warranty of any kind.
* See license.txt for license info
*/
#endregion
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using System.Diagnostics;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
using OpenTK.Input; using OpenTK.Input;
@ -19,7 +12,7 @@ namespace Examples.Tutorial
/// <summary> /// <summary>
/// Demonstrates the GameWindow class. /// Demonstrates the GameWindow class.
/// </summary> /// </summary>
[Example("Simple Window", ExampleCategory.OpenTK, "GameWindow", Documentation="SimpleWindow")] [Example("GameWindow Simple", ExampleCategory.OpenTK, "GameWindow", 1, Documentation = "GameWindowSimple")]
public class SimpleWindow : GameWindow public class SimpleWindow : GameWindow
{ {
public SimpleWindow() : base(800, 600) public SimpleWindow() : base(800, 600)

Binary file not shown.

View file

@ -0,0 +1,318 @@
// This code is in the Public Domain. It is provided "as is"
// without express or implied warranty of any kind.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates how to decouple rendering from the main thread.
/// Note that all OpenGL function calls should take place at the rendering thread -
/// OpenGL will not be available on the main thread at all!
/// </summary>
[Example("GameWindow Threaded", ExampleCategory.OpenTK, "GameWindow", 3, Documentation = "GameWindowThreaded")]
public class ThreadedRendering : GameWindow
{
bool viewport_changed = true;
int viewport_width, viewport_height;
bool position_changed = true;
int position_x, position_y;
float position_dx, position_dy;
bool exit = false;
Thread rendering_thread;
object update_lock = new object();
const float GravityAccel = -9.81f;
struct Particle
{
public Vector2 Position;
public Vector2 Velocity;
public Color4 Color;
}
List<Particle> Particles = new List<Particle>();
Random rand = new Random();
public ThreadedRendering()
: base(800, 600)
{
Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e)
{
if (e.Key == Key.Escape)
this.Exit();
};
Keyboard.KeyUp += delegate(object sender, KeyboardKeyEventArgs e)
{
if (e.Key == Key.F11)
if (this.WindowState == WindowState.Fullscreen)
this.WindowState = WindowState.Normal;
else
this.WindowState = WindowState.Fullscreen;
};
Resize += delegate(object sender, EventArgs e)
{
// Note that we cannot call any OpenGL methods directly. What we can do is set
// a flag and respond to it from the rendering thread.
lock (update_lock)
{
viewport_changed = true;
viewport_width = Width;
viewport_height = Height;
}
};
Move += delegate(object sender, EventArgs e)
{
// Note that we cannot call any OpenGL methods directly. What we can do is set
// a flag and respond to it from the rendering thread.
lock (update_lock)
{
position_changed = true;
position_dx = (position_x - X) / (float)Width;
position_dy = (position_y - Y) / (float)Height;
position_x = X;
position_y = Y;
}
};
// Make sure initial position are correct, otherwise we'll give a huge
// initial velocity to the balls.
position_x = X;
position_y = Y;
}
#region OnLoad
/// <summary>
/// Setup OpenGL and load resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
Context.MakeCurrent(null); // Release the OpenGL context so it can be used on the new thread.
rendering_thread = new Thread(RenderLoop);
rendering_thread.IsBackground = true;
rendering_thread.Start();
}
#endregion
#region OnUnload
/// <summary>
/// Release resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnUnload(EventArgs e)
{
exit = true; // Set a flag that the rendering thread should stop running.
rendering_thread.Join();
base.OnUnload(e);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Add your game logic here.
/// </summary>
/// <param name="e">Contains timing information.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
// Nothing to do!
}
#endregion
#region OnRenderFrame
/// <summary>
/// Ignored. All rendering is performed on our own rendering function.
/// </summary>
/// <param name="e">Contains timing information.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnRenderFrame(FrameEventArgs e)
{
// Nothing to do. Release the CPU to other threads.
Thread.Sleep(1);
}
#endregion
#region RenderLoop
void RenderLoop()
{
MakeCurrent(); // The context now belongs to this thread. No other thread may use it!
VSync = VSyncMode.On;
for (int i = 0; i < 64; i++)
{
Particle p = new Particle();
p.Position = new Vector2((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1);
p.Color.R = (float)rand.NextDouble();
p.Color.G = (float)rand.NextDouble();
p.Color.B = (float)rand.NextDouble();
Particles.Add(p);
}
// Since we don't use OpenTK's timing mechanism, we need to keep time ourselves;
Stopwatch render_watch = new Stopwatch();
Stopwatch update_watch = new Stopwatch();
update_watch.Start();
render_watch.Start();
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.PointSmooth);
GL.PointSize(16);
while (!exit)
{
Update(update_watch.Elapsed.TotalSeconds);
update_watch.Reset();
update_watch.Start();
Render(render_watch.Elapsed.TotalSeconds);
render_watch.Reset(); // Stopwatch may be inaccurate over larger intervals.
render_watch.Start(); // Plus, timekeeping is easier if we always start counting from 0.
SwapBuffers();
}
Context.MakeCurrent(null);
}
#endregion
#region Update
void Update(double time)
{
lock (update_lock)
{
// When the user moves the window we make the particles react to
// this movement. The reaction is semi-random and not physically
// correct. It looks quite good, however.
if (position_changed)
{
for (int i = 0; i < Particles.Count; i++)
{
Particle p = Particles[i];
p.Velocity += new Vector2(
16 * (position_dx + 0.05f * (float)(rand.NextDouble() - 0.5)),
32 * (position_dy + 0.05f * (float)(rand.NextDouble() - 0.5)));
Particles[i] = p;
}
position_changed = false;
}
}
// For simplicity, we use simple Euler integration to simulate particle movement.
// This is not accurate, especially under varying timesteps (as is the case here).
// A better solution would have been time-corrected Verlet integration, as
// described here:
// http://www.gamedev.net/reference/programming/features/verlet/
for (int i = 0; i < Particles.Count; i++)
{
Particle p = Particles[i];
p.Velocity.X = Math.Abs(p.Position.X) >= 1 ?-p.Velocity.X * 0.92f : p.Velocity.X * 0.97f;
p.Velocity.Y = Math.Abs(p.Position.Y) >= 1 ? -p.Velocity.Y * 0.92f : p.Velocity.Y * 0.97f;
if (p.Position.Y > -0.99)
{
p.Velocity.Y += (float)(GravityAccel * time);
}
else
{
if (Math.Abs(p.Velocity.Y) < 0.02)
{
p.Velocity.Y = 0;
p.Position.Y = -1;
}
else
{
p.Velocity.Y *= 0.9f;
}
}
p.Position += p.Velocity * (float)time;
if (p.Position.Y <= -1)
p.Position.Y = -1;
Particles[i] = p;
}
}
#endregion
#region Render
/// <summary>
/// This is our main rendering function, which executes on the rendering thread.
/// </summary>
public void Render(double time)
{
lock (update_lock)
{
if (viewport_changed)
{
GL.Viewport(0, 0, viewport_width, viewport_height);
viewport_changed = false;
}
}
Matrix4 perspective =
Matrix4.CreateOrthographic(2, 2, -1, 1);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Begin(BeginMode.Points);
foreach (Particle p in Particles)
{
GL.Color4(p.Color);
GL.Vertex2(p.Position);
}
GL.End();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (GameWindow example = new ThreadedRendering())
{
// Get the title and category of this example using reflection.
Utilities.SetWindowTitle(example);
example.Run();
}
}
#endregion
}
}

View file

@ -1,275 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2010 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.Diagnostics;
using System.Drawing;
using System.Threading;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates how to decouple rendering from the main thread.
/// Note that all OpenGL function calls should take place at the rendering thread -
/// OpenGL will not be available on the main thread at all!
/// </summary>
[Example("Threaded Rendering", ExampleCategory.OpenTK, "GameWindow", Documentation = "ThreadedRendering")]
public class ThreadedRendering : GameWindow
{
bool viewport_changed = true;
int viewport_width, viewport_height;
bool exit = false;
Thread rendering_thread;
object update_lock = new object();
const float rotation_speed = 180.0f;
float angle;
float aspect_ratio;
readonly VertexPositionColor[] CubeVertices = new VertexPositionColor[]
{
new VertexPositionColor(-1.0f, -1.0f, 1.0f, Color.DarkRed),
new VertexPositionColor( 1.0f, -1.0f, 1.0f, Color.DarkRed),
new VertexPositionColor( 1.0f, 1.0f, 1.0f, Color.Gold),
new VertexPositionColor(-1.0f, 1.0f, 1.0f, Color.Gold),
new VertexPositionColor(-1.0f, -1.0f, -1.0f, Color.DarkRed),
new VertexPositionColor( 1.0f, -1.0f, -1.0f, Color.DarkRed),
new VertexPositionColor( 1.0f, 1.0f, -1.0f, Color.Gold),
new VertexPositionColor(-1.0f, 1.0f, -1.0f, Color.Gold)
};
readonly short[] CubeElements = new short[]
{
0, 1, 2, 2, 3, 0, // front face
3, 2, 6, 6, 7, 3, // top face
7, 6, 5, 5, 4, 7, // back face
4, 0, 3, 3, 7, 4, // left face
0, 1, 5, 5, 4, 0, // bottom face
1, 5, 6, 6, 2, 1, // right face
};
public ThreadedRendering()
: base(800, 600)
{
Keyboard.KeyDown += Keyboard_KeyDown;
}
#region Keyboard_KeyDown
/// <summary>
/// Occurs when a key is pressed.
/// </summary>
/// <param name="sender">The KeyboardDevice which generated this event.</param>
/// <param name="e">The key that was pressed.</param>
void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
{
if (e.Key == Key.Escape)
this.Exit();
if (e.Key == Key.F11)
if (this.WindowState == WindowState.Fullscreen)
this.WindowState = WindowState.Normal;
else
this.WindowState = WindowState.Fullscreen;
}
#endregion
#region OnLoad
/// <summary>
/// Setup OpenGL and load resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
Context.MakeCurrent(null); // Release the OpenGL context so it can be used on the new thread.
rendering_thread = new Thread(RenderLoop);
rendering_thread.IsBackground = true;
rendering_thread.Start();
}
#endregion
#region OnUnload
/// <summary>
/// Release resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnUnload(EventArgs e)
{
exit = true; // Set a flag that the rendering thread should stop running.
rendering_thread.Join();
base.OnUnload(e);
}
#endregion
#region OnResize
/// <summary>
/// Respond to resize events here.
/// </summary>
/// <param name="e">Contains information on the new GameWindow size.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnResize(EventArgs e)
{
// Note that we cannot call any OpenGL methods directly. What we can do is set
// a flag and respond to it from the rendering thread.
lock (update_lock)
{
viewport_changed = true;
viewport_width = Width;
viewport_height = Height;
}
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Add your game logic here.
/// </summary>
/// <param name="e">Contains timing information.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
// Nothing to do!
}
#endregion
#region OnRenderFrame
/// <summary>
/// Ignored. All rendering is performed on our own rendering function.
/// </summary>
/// <param name="e">Contains timing information.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnRenderFrame(FrameEventArgs e)
{
}
#endregion
#region RenderLoop
void RenderLoop()
{
MakeCurrent(); // The context now belongs to this thread. No other thread may use it!
VSync = VSyncMode.On;
// Since we don't use OpenTK's timing mechanism, we need to keep time ourselves;
Stopwatch watch = new Stopwatch();
watch.Start();
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
while (!exit)
{
Render(watch.Elapsed.TotalSeconds);
watch.Reset(); // Stopwatch may be inaccurate over larger intervals.
watch.Start(); // Plus, timekeeping is easier if we always start counting from 0.
SwapBuffers();
}
}
#endregion
#region Render
/// <summary>
/// This is our main rendering function, which executes on the rendering thread.
/// </summary>
public void Render(double time)
{
lock (update_lock)
{
if (viewport_changed)
{
GL.Viewport(0, 0, viewport_width, viewport_height);
aspect_ratio = viewport_width / (float)viewport_height;
viewport_changed = false;
}
}
Matrix4 perspective =
Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
angle += rotation_speed * (float)time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
GL.Begin(BeginMode.Triangles);
for (int i = 0; i < CubeElements.Length; i++)
{
int element = CubeElements[i];
uint color = CubeVertices[element].Color;
GL.Color4((byte)(color), (byte)(color >> 8), (byte)(color >> 16), (byte)(color >> 24));
GL.Vertex3(CubeVertices[element].Position);
}
GL.End();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (GameWindow example = new ThreadedRendering())
{
// Get the title and category of this example using reflection.
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,29 +1,5 @@
#region License // This code is in the Public Domain. It is provided "as is"
// // without express or implied warranty of any kind.
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2008 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;
using System.Diagnostics; using System.Diagnostics;
@ -49,45 +25,52 @@ namespace Examples.Tests
{ {
public static void Main() public static void Main()
{ {
PrintType(new Simple()); TestType(new Simple());
PrintType(new Generic<Simple>()); TestType(new Generic<Simple>());
PrintType(new Generic<Enum>()); TestType(new Generic<Enum>());
PrintType(new Complex()); TestType(new Complex());
PrintType(new Complex<Enum>()); TestType(new Complex<Enum>());
PrintType(new Complex2()); TestType(new Complex2());
PrintType(new Complex3()); TestType(new Complex3());
PrintType(new Complex4()); TestType(new Complex4());
PrintType(new Class()); TestType(new Class());
PrintType(new Class<Simple>()); TestType(new Class<Simple>());
} }
static bool CheckBlittable<T>(T type) // Tests whether specified type is blittable and prints its marshalled size if so.
{ static void TestType<T>(T instance)
return BlittableValueType.Check(type); {
} PrintType<T>();
static int GetStride<T>(T type) Trace.Write(BlittableValueType.Check(instance) ? "is blittable " : "is not blittable ");
{
return BlittableValueType.StrideOf(type); try
} {
// StrideOf() will throw an ArgumentException if the type is not blittable.
static void PrintType<T>(T instance) Trace.Write(String.Format("({0} bytes)", BlittableValueType.StrideOf(instance)));
{ }
Type type = typeof(T); catch (Exception e)
string typename = type.GetFields()[0].FieldType.ToString(); {
Trace.Write(String.Format("({0})", e.GetType().Name));
Trace.Write(type.IsClass ? "class " : type.IsEnum ? "enum " : type.IsInterface ? "interface " : "struct "); }
Trace.Write(type.Name);
if (type.IsGenericType)
Trace.Write(String.Format("<{0}>", type.GetGenericArguments()[0].Name));
Trace.Write(" { ");
Trace.Write(typename.Substring(typename.LastIndexOf('.') + 1));
Trace.Write(" } ");
Trace.Write(CheckBlittable(instance) ? "is blittable " : "is not blittable ");
try { Trace.Write(String.Format("({0} bytes)", GetStride(instance))); }
catch (Exception e) { Trace.Write(String.Format("({0})", e.GetType().Name)); }
Trace.WriteLine(""); Trace.WriteLine("");
}
// Prints a simple description for the type.
static void PrintType<T>()
{
Type type = typeof(T);
string typename = type.GetFields()[0].FieldType.ToString();
Trace.Write(type.IsClass ? "class " : type.IsEnum ? "enum " : type.IsInterface ? "interface " : "struct ");
Trace.Write(type.Name);
if (type.IsGenericType)
Trace.Write(String.Format("<{0}>", type.GetGenericArguments()[0].Name));
Trace.Write(" { ");
Trace.Write(typename.Substring(typename.LastIndexOf('.') + 1));
Trace.Write(" } ");
} }
} }
} }

Binary file not shown.

View file

@ -1,8 +1,5 @@
#region --- License --- // This code is in the Public Domain. It is provided "as is"
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos // without express or implied warranty of any kind.
* See license.txt for license info
*/
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

Binary file not shown.

View file

@ -0,0 +1,72 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2010 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.Diagnostics;
using OpenTK.Graphics;
using OpenTK;
using System.Windows.Forms;
namespace Examples.Tests
{
[Example("Test GraphicsModes", ExampleCategory.OpenTK, "Test", Documentation = "TestGraphicsModes")]
public class TestGraphicsModes
{
static void Main()
{
Dictionary<GraphicsMode, GraphicsMode> modes = new Dictionary<GraphicsMode, GraphicsMode>();
Trace.WriteLine("Cl (RGBA): Color format (total bits and bits per channel).");
Trace.WriteLine("Dp : Depth buffer bits.");
Trace.WriteLine("St : Stencil buffer bits.");
Trace.WriteLine("AA : Sample count for anti-aliasing.");
Trace.WriteLine("Stereo : Stereoscoping rendering supported.");
Trace.WriteLine("");
Trace.WriteLine("Cl (RGBA), Dp, St, AA, Stereo");
Trace.WriteLine("-----------------------------");
foreach (ColorFormat color in new ColorFormat[] { 32, 24, 16, 8 })
foreach (int depth in new int[] { 24, 16 })
foreach (int stencil in new int[] { 8, 0 })
foreach (int samples in new int[] { 0, 2, 4, 6, 8, 16 })
foreach (bool stereo in new bool[] { false, true })
{
try
{
GraphicsMode mode = new GraphicsMode(color, depth, stencil, samples, 0, 2, stereo);
if (!modes.ContainsKey(mode))
modes.Add(mode, mode);
}
catch
{ }
}
foreach (GraphicsMode mode in modes.Keys)
Trace.WriteLine(String.Format("{0}, {1:00}, {2:00}, {3:00}, {4}", mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.Stereo));
}
}
}

View file

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("The Open Toolkit Library Examples")] [assembly: AssemblyTitle("OpenTK.Examples")]
[assembly: AssemblyDescription("Examples showcasing OpenTK and OpenGL")] [assembly: AssemblyDescription("Examples showcasing OpenTK and OpenGL")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Open Toolkit Library")] [assembly: AssemblyCompany("The Open Toolkit Library")]
[assembly: AssemblyProduct("The Open Toolkit Library")] [assembly: AssemblyProduct("The Open Toolkit Library")]
[assembly: AssemblyCopyright("Copyright © 2006-2009 the Open Toolkit Library")] [assembly: AssemblyCopyright("Copyright © 2006-2010 the Open Toolkit Library")]
[assembly: AssemblyTrademark("OpenTK")] [assembly: AssemblyTrademark("OpenTK")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -29,8 +29,8 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.9.9.4")] [assembly: AssemblyVersion("1.0.0.201")]
[assembly: AssemblyFileVersion("0.9.9.4")] [assembly: AssemblyFileVersion("1.0.0.201")]
#if SIGN_ASSEMBLY #if SIGN_ASSEMBLY
[assembly: AssemblyKeyFile(@"../../../OpenTK.snk")] [assembly: AssemblyKeyFile(@"../../../OpenTK.snk")]

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4200 // Runtime Version:2.0.50727.4927
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -66,730 +66,5 @@ namespace OpenTK.Examples.Properties {
return ((System.Drawing.Icon)(obj)); return ((System.Drawing.Icon)(obj));
} }
} }
/// <summary>
/// Looks up a localized string similar to #region License
/////
///// The Open Toolkit Library License
/////
///// Copyright (c) 2006 - 2008 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 &quot;Software&quot;), 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 person [rest of string was truncated]&quot;;.
/// </summary>
internal static string Color4Serialization {
get {
return ResourceManager.GetString("Color4Serialization", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region License
/////
///// The Open Toolkit Library License
/////
///// Copyright (c) 2006 - 2009 the Open Toolkit library.
/////
///// Permission is hereby granted, free of charge, to any person obtaining a copy
///// of this software and associated documentation files (the &quot;Software&quot;), 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 Softwa [rest of string was truncated]&quot;;.
/// </summary>
internal static string DisplayLists {
get {
return ResourceManager.GetString("DisplayLists", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region License
/////
///// The Open Toolkit Library License
/////
///// Copyright (c) 2006 - 2009 the Open Toolkit library.
/////
///// Permission is hereby granted, free of charge, to any person obtaining a copy
///// of this software and associated documentation files (the &quot;Software&quot;), 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 Softwa [rest of string was truncated]&quot;;.
/// </summary>
internal static string EFXReverb {
get {
return ResourceManager.GetString("EFXReverb", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Data;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///using System.Threading;
///using System.Reflection;
///
///using OpenTK;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///using System.Text.RegularExpressions;
///
///namespace Examples.WinForms
///{
/// [Examp [rest of string was truncated]&quot;;.
/// </summary>
internal static string Extensions {
get {
return ResourceManager.GetString("Extensions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.IO;
///using System.Drawing;
///using System.Diagnostics;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Input;
///
///namespace Examples.Tutorial
///{
///#if false
/// /// &lt;summary&gt;
/// /// Shows how to render and scroll large amounts of text.
/// /// &lt;/summary&gt;
/// [Example(&quot;Font rende [rest of string was truncated]&quot;;.
/// </summary>
internal static string FontRenderingAdvanced {
get {
return ResourceManager.GetString("FontRenderingAdvanced", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region License
/////
///// The Open Toolkit Library License
/////
///// Copyright (c) 2006 - 2009 the Open Toolkit library.
/////
///// Permission is hereby granted, free of charge, to any person obtaining a copy
///// of this software and associated documentation files (the &quot;Software&quot;), 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 Softwa [rest of string was truncated]&quot;;.
/// </summary>
internal static string FontRenderingBasic {
get {
return ResourceManager.GetString("FontRenderingBasic", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {\rtf1\ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}{\f2\fswiss\fcharset161{\*\fname Arial;}Arial Greek;}{\f3\fswiss\fprq2\fcharset161{\*\fname Arial;}Arial Greek;}{\f4\fmodern\fprq1\fcharset0 Consolas;}}
///{\colortbl ;\red0\green0\blue255;\red43\green145\blue175;}
///{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\qc\lang1033\b\f0\fs32 Font rendering\par
///\b0\f1\fs20\par
///\lang1032\f2\par
///\pard\lang1033\b\f1\fs24 Overview\par
///\par
///\b0\f [rest of string was truncated]&quot;;.
/// </summary>
internal static string FontRenderingBasicDoc {
get {
return ResourceManager.GetString("FontRenderingBasicDoc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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 details.
/// */
///#endregion
///
///using System;
///using System.Diagnostics;
///using System.Drawing;
///
///using OpenTK;
///using OpenTK.Input;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///
///namespace Examples.Tutorial
///{
/// [Example(&quot;Framebuffer Objects&quot;, ExampleCategory.OpenGL, &quot;FBO&quot;, Documentation=&quot;F [rest of string was truncated]&quot;;.
/// </summary>
internal static string FramebufferObject {
get {
return ResourceManager.GetString("FramebufferObject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {\rtf1\ansi\ansicpg1253\deff0\deflang1032\deflangfe1032{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}{\f2\fswiss\fcharset161{\*\fname Arial;}Arial Greek;}}
///{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\qc\lang1033\b\f0\fs32 Framebuffer Objects\par
///\b0\f1\fs20\par
///\lang1032\f2\par
///\pard\lang1033\b\f1\fs24 Overview\par
///\par
///\b0\fs22 This sample demonstrates Framebuffer objects (FBOs) via the EXT_framebuffer_object extension. FBOs provide an efficient method to perfo [rest of string was truncated]&quot;;.
/// </summary>
internal static string FramebufferObjectDoc {
get {
return ResourceManager.GetString("FramebufferObjectDoc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Diagnostics;
///using System.Drawing;
///using System.Threading;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Input;
///
///namespace Examples.Tests
///{
/// [Example(&quot;GameWindow states&quot;, ExampleCategory.OpenTK, &quot;Test&quot;, Documentation=&quot;GameWindowStates&quot;)]
/// public class GameWindowStat [rest of string was truncated]&quot;;.
/// </summary>
internal static string GameWindowStates {
get {
return ResourceManager.GetString("GameWindowStates", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* This source file is released under the MIT license. See License.txt for more information.
/// * Coded by Erik Ylvisaker and Stefanos Apostolopoulos.
/// */
///#endregion
///
///#region --- Using directives ---
///
///using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Data;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///using System.Diagnostics;
///using System.Threading;
///
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Platform;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string GLControlGameLoop {
get {
return ResourceManager.GetString("GLControlGameLoop", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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
///
///#region --- Using Directives ---
///
///using System;
///using System.Collections.Generic;
///using System.Windows.Forms;
///using System.Threading;
///using System.Drawing;
///
///using OpenTK;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///
///#endregion
///
///names [rest of string was truncated]&quot;;.
/// </summary>
internal static string ImmediateMode {
get {
return ResourceManager.GetString("ImmediateMode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Data;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///
///using OpenTK;
///using OpenTK.Platform;
///using OpenTK.Input;
///using System.Diagnostics;
///using System.Threading;
///
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///
///namespace Examples.Tests
///{
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string InputLogger {
get {
return ResourceManager.GetString("InputLogger", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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.
/// *
/// * Written by Christoph Brandtner
/// */
///#endregion
///
///using System;
///using System.Windows.Forms;
///using System.Diagnostics;
///using System.Drawing;
///using System.Drawing.Imaging;
///using System.IO;
///
///using OpenTK;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///u [rest of string was truncated]&quot;;.
/// </summary>
internal static string JuliaSetFractal {
get {
return ResourceManager.GetString("JuliaSetFractal", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Data;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///
///namespace Examples.WinForms
///{
/// [Example(&quot;Multiple GLControls&quot;, ExampleCategory.OpenTK, &quot;GLControl&quot;, 3, Documentation=&quot;MultipleGLControls&quot;)]
/// public partial class MultipleGLControlsForm : Form
/// {
/// public MultipleGLControlsForm()
/// {
/// InitializeCompone [rest of string was truncated]&quot;;.
/// </summary>
internal static string MultipleGLControls {
get {
return ResourceManager.GetString("MultipleGLControls", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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 details.
/// */
///#endregion
///
///using System;
///using System.Diagnostics;
///using System.Threading;
///using System.IO;
///
///using OpenTK.Audio;
///using OpenTK.Audio.OpenAL;
///
///namespace Examples
///{
/// [Example(&quot;Playback&quot;, ExampleCategory.OpenAL, &quot;1.1&quot;, Documentation=&quot;Playback&quot;)]
/// public class Playback
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string Playback {
get {
return ResourceManager.GetString("Playback", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to /*
/// * Copyright (c) 2006, Creative Labs Inc.
/// * All rights reserved.
/// *
/// * Redistribution and use in source and binary forms, with or without modification, are permitted provided
/// * that the following conditions are met:
/// *
/// * * Redistributions of source code must retain the above copyright notice, this list of conditions and
/// * the following disclaimer.
/// * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
/// * and the following [rest of string was truncated]&quot;;.
/// </summary>
internal static string PlayStatic {
get {
return ResourceManager.GetString("PlayStatic", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///#region --- Using directives ---
///
///using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Data;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///
///#endregion
///
///namespace Examples.WinForms
///{
/// [Example(&quot;Simple GLControl&quot;, ExampleCategory.OpenTK, &quot;GLControl&quot;, 1, D [rest of string was truncated]&quot;;.
/// </summary>
internal static string SimpleGLControl {
get {
return ResourceManager.GetString("SimpleGLControl", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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
///
///#region --- Using Directives ---
///
///using System;
///using System.Collections.Generic;
///using System.ComponentModel;
///using System.Drawing;
///using System.Text;
///using System.Windows.Forms;
///using System.Threading;
///using System.Diagnostics;
///using System.IO; [rest of string was truncated]&quot;;.
/// </summary>
internal static string SimpleGLSL {
get {
return ResourceManager.GetString("SimpleGLSL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Drawing;
///using System.Diagnostics;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Input;
///
///namespace Examples.Tutorial
///{
/// /// &lt;summary&gt;
/// /// Demonstrates the GameWindow class.
/// /// &lt;/summary&gt;
/// [Example(&quot;Simple Window&quot;, ExampleCategory.OpenTK, &quot;GameWindow&quot;, Docu [rest of string was truncated]&quot;;.
/// </summary>
internal static string SimpleWindow {
get {
return ResourceManager.GetString("SimpleWindow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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 details.
/// */
///#endregion
///
///using System;
///using System.Diagnostics;
///using System.Collections.Generic;
///using System.Text;
///using System.Threading;
///using System.ComponentModel;
///
///using OpenTK.Audio;
///using OpenTK.Audio.OpenAL;
///
///namespace Examples.OpenAL
///{
/// // Not working correctly (sound pops [rest of string was truncated]&quot;;.
/// </summary>
internal static string StreamingPlayback {
get {
return ResourceManager.GetString("StreamingPlayback", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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 details.
/// */
///#endregion
///
///using System;
///using System.Diagnostics;
///
///using OpenTK.Audio;
///using OpenTK.Audio.OpenAL;
///
///using AlContext = System.IntPtr;
///using AlDevice = System.IntPtr;
///
///namespace Examples
///{
/// [Example(&quot;AudioContext Test&quot;, ExampleCategory.OpenTK, &quot;Test&quot;, 0, false)]
/// class [rest of string was truncated]&quot;;.
/// </summary>
internal static string TestAudioContext {
get {
return ResourceManager.GetString("TestAudioContext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #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.
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Windows.Forms;
///using System.Diagnostics;
///using System.Threading;
///
///using OpenTK;
///
///namespace Examples.Tests
///{
/// [Example(&quot;Test Resolution Changes&quot;, ExampleCategory.OpenTK, &quot;Test&quot;, Documentation= [rest of string was truncated]&quot;;.
/// </summary>
internal static string TestResolutionChanges {
get {
return ResourceManager.GetString("TestResolutionChanges", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Diagnostics;
///using System.IO;
///
///using System.Drawing;
///using System.Drawing.Imaging;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Graphics;
///
///namespace Examples.Tutorial
///{
/// /// &lt;summary&gt;
/// /// Demonstrates simple OpenGL Texturing.
/// /// &lt;/summary&gt;
/// [Example(&quot;T [rest of string was truncated]&quot;;.
/// </summary>
internal static string Textures {
get {
return ResourceManager.GetString("Textures", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Drawing;
///using System.Threading;
///
///using OpenTK;
///using System.Diagnostics;
///using OpenTK.Input;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///
///namespace Examples.Tutorial
///{
/// /// &lt;summary&gt;
/// /// Demonstrates Vertex Arrays (in system memory). Example is incomplete (document [rest of string was truncated]&quot;;.
/// </summary>
internal static string VertexArrays {
get {
return ResourceManager.GetString("VertexArrays", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///#region --- Using directives ---
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Runtime.InteropServices;
///using System.Threading;
///
///using OpenTK;
///using OpenTK.Graphics;
///using OpenTK.Graphics.OpenGL;
///using OpenTK.Platform;
///
///#endregion
///
///namespace Examples.Tutorial
///{
/// [Example(&quot;Static Vertex Buffer Objects&quot;, ExampleCategory.Ope [rest of string was truncated]&quot;;.
/// </summary>
internal static string VertexBufferObject {
get {
return ResourceManager.GetString("VertexBufferObject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #region --- License ---
////* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
/// * See license.txt for license info
/// */
///#endregion
///
///using System;
///using System.Collections.Generic;
///using System.Text;
///using System.Drawing;
///
///using OpenTK;
///using OpenTK.Graphics.OpenGL;
///using Examples.Shapes;
///
///namespace Examples.Tutorial
///{
/// /// &lt;summary&gt;
/// /// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation).
/// /// &lt;/summary&gt;
/// [Example(&quot;Vertex Lighting&quot;, ExampleCategor [rest of string was truncated]&quot;;.
/// </summary>
internal static string VertexLighting {
get {
return ResourceManager.GetString("VertexLighting", resourceCulture);
}
}
} }
} }

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@ -118,88 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Color4Serialization" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Test\Color4Serialization.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="DisplayLists" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.1\DisplayLists.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="EFXReverb" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenAL\EFX\EFXReverb.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="Extensions" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Test\Extensions.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="FontRenderingAdvanced" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Fonts\FontRenderingAdvanced.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="FontRenderingBasicDoc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Fonts\FontRenderingBasic.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value>
</data>
<data name="FontRenderingBasic" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Fonts\FontRenderingBasic.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="FramebufferObject" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\EXT\FramebufferObject.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="FramebufferObjectDoc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\EXT\FramebufferObject.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value>
</data>
<data name="GameWindowStates" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Test\GameWindowStates.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="GLControlGameLoop" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\GLControl\GLControlGameLoop.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="ImmediateMode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.1\ImmediateMode.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="InputLogger" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Test\InputLogger.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="JuliaSetFractal" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\GLSL\JuliaSetFractal.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="MultipleGLControls" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\GLControl\MultipleGLControls.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="Playback" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenAL\1.1\Playback.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="PlayStatic" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenAL\1.1\PlayStatic.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="SimpleGLControl" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\GLControl\SimpleGLControl.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="SimpleWindow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\GameWindow\SimpleWindow.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="StreamingPlayback" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenAL\1.1\StreamingPlayback.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="TestAudioContext" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenAL\Test\TestAudioContext.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="TestResolutionChanges" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenTK\Test\TestResolutionChanges.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="Textures" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.1\Textures.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="VertexArrays" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.1\VertexArrays.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="VertexBufferObject" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.5\VertexBufferObject.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="VertexLighting" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\1.1\VertexLighting.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="SimpleGLSL" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\OpenGL\GLSL\SimpleGLSL.cs;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="App" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="App" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\App.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>../Resources/App.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

View file

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("The Open Toolkit Library GLControl Module")] [assembly: AssemblyTitle("OpenTK.GLControl")]
[assembly: AssemblyDescription("Provides integration with System.Windows.Forms.")] [assembly: AssemblyDescription("Provides integration with System.Windows.Forms.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Open Toolkit Library")] [assembly: AssemblyCompany("The Open Toolkit Library")]
[assembly: AssemblyProduct("The Open Toolkit Library")] [assembly: AssemblyProduct("The Open Toolkit Library")]
[assembly: AssemblyCopyright("Copyright © 2006-2009 the Open Toolkit Library")] [assembly: AssemblyCopyright("Copyright © 2006-2010 the Open Toolkit Library")]
[assembly: AssemblyTrademark("OpenTK")] [assembly: AssemblyTrademark("OpenTK")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -32,12 +32,14 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.4")] [assembly: AssemblyVersion("1.0.0.201")]
[assembly: AssemblyFileVersion("0.9.9.4")] [assembly: AssemblyFileVersion("1.0.0.201")]
[assembly: System.CLSCompliant(true)] [assembly: System.CLSCompliant(true)]
[assembly: System.Security.AllowPartiallyTrustedCallers] [assembly: System.Security.AllowPartiallyTrustedCallers]
#if NET40
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
#endif
#if SIGN_ASSEMBLY #if SIGN_ASSEMBLY
[assembly: AssemblyKeyFile(@"../../../OpenTK.snk")] [assembly: AssemblyKeyFile(@"../../../OpenTK.snk")]

View file

@ -2,7 +2,7 @@
// //
// The Open Toolkit Library License // The Open Toolkit Library License
// //
// Copyright (c) 2006 - 2009 the Open Toolkit library. // Copyright (c) 2006 - 2010 the Open Toolkit library.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@ -57,9 +57,10 @@ namespace OpenTK
static BlittableValueType() static BlittableValueType()
{ {
Type = typeof(T); Type = typeof(T);
if (Type.IsValueType) if (Type.IsValueType && !Type.IsGenericType)
{ {
// Does this support generic types? On Mono 2.4.3 it does // Does this support generic types? On Mono 2.4.3 it does
// On .Net it doesn't.
// http://msdn.microsoft.com/en-us/library/5s4920fa.aspx // http://msdn.microsoft.com/en-us/library/5s4920fa.aspx
stride = Marshal.SizeOf(typeof(T)); stride = Marshal.SizeOf(typeof(T));
} }
@ -70,7 +71,7 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary> /// <summary>
/// Gets the size of the type in bytes. /// Gets the size of the type in bytes or 0 for non-blittable types.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This property returns 0 for non-blittable types. /// This property returns 0 for non-blittable types.
@ -82,6 +83,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// Checks whether the current typename T is blittable. /// Checks whether the current typename T is blittable.
/// </summary> /// </summary>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check() public static bool Check()
{ {
return Check(Type); return Check(Type);
@ -91,6 +93,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">A System.Type to check.</param> /// <param name="type">A System.Type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check(Type type) public static bool Check(Type type)
{ {
if (!CheckStructLayoutAttribute(type)) if (!CheckStructLayoutAttribute(type))
@ -125,7 +128,7 @@ namespace OpenTK
} }
Debug.Unindent(); Debug.Unindent();
return true; return Stride != 0;
} }
// Checks whether the specified struct defines [StructLayout(LayoutKind.Sequential, Pack=1)] // Checks whether the specified struct defines [StructLayout(LayoutKind.Sequential, Pack=1)]
@ -164,6 +167,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">An instance of the type to check.</param> /// <param name="type">An instance of the type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check<T>(T type) public static bool Check<T>(T type)
{ {
return BlittableValueType<T>.Check(); return BlittableValueType<T>.Check();
@ -173,6 +177,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">An instance of the type to check.</param> /// <param name="type">An instance of the type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check<T>(T[] type) public static bool Check<T>(T[] type)
{ {
return BlittableValueType<T>.Check(); return BlittableValueType<T>.Check();
@ -182,6 +187,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">An instance of the type to check.</param> /// <param name="type">An instance of the type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check<T>(T[,] type) public static bool Check<T>(T[,] type)
{ {
return BlittableValueType<T>.Check(); return BlittableValueType<T>.Check();
@ -191,6 +197,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">An instance of the type to check.</param> /// <param name="type">An instance of the type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
public static bool Check<T>(T[, ,] type) public static bool Check<T>(T[, ,] type)
{ {
return BlittableValueType<T>.Check(); return BlittableValueType<T>.Check();
@ -200,6 +207,7 @@ namespace OpenTK
/// Checks whether type is a blittable value type. /// Checks whether type is a blittable value type.
/// </summary> /// </summary>
/// <param name="type">An instance of the type to check.</param> /// <param name="type">An instance of the type to check.</param>
/// <returns>True if T is blittable; false otherwise.</returns>
[CLSCompliant(false)] [CLSCompliant(false)]
public static bool Check<T>(T[][] type) public static bool Check<T>(T[][] type)
{ {
@ -211,7 +219,7 @@ namespace OpenTK
#region StrideOf #region StrideOf
/// <summary> /// <summary>
/// Returns the size of the specified value type in bytes. /// Returns the size of the specified value type in bytes or 0 if the type is not blittable.
/// </summary> /// </summary>
/// <typeparam name="T">The value type. Must be blittable.</typeparam> /// <typeparam name="T">The value type. Must be blittable.</typeparam>
/// <param name="type">An instance of the value type.</param> /// <param name="type">An instance of the value type.</param>
@ -226,7 +234,7 @@ namespace OpenTK
} }
/// <summary> /// <summary>
/// Returns the size of a single array element in bytes. /// Returns the size of a single array element in bytes or 0 if the element is not blittable.
/// </summary> /// </summary>
/// <typeparam name="T">The value type.</typeparam> /// <typeparam name="T">The value type.</typeparam>
/// <param name="type">An instance of the value type.</param> /// <param name="type">An instance of the value type.</param>
@ -241,7 +249,7 @@ namespace OpenTK
} }
/// <summary> /// <summary>
/// Returns the size of a single array element in bytes. /// Returns the size of a single array element in bytes or 0 if the element is not blittable.
/// </summary> /// </summary>
/// <typeparam name="T">The value type.</typeparam> /// <typeparam name="T">The value type.</typeparam>
/// <param name="type">An instance of the value type.</param> /// <param name="type">An instance of the value type.</param>
@ -256,7 +264,7 @@ namespace OpenTK
} }
/// <summary> /// <summary>
/// Returns the size of a single array element in bytes. /// Returns the size of a single array element in bytes or 0 if the element is not blittable.
/// </summary> /// </summary>
/// <typeparam name="T">The value type.</typeparam> /// <typeparam name="T">The value type.</typeparam>
/// <param name="type">An instance of the value type.</param> /// <param name="type">An instance of the value type.</param>

View file

@ -397,8 +397,9 @@ namespace OpenTK
// On some platforms, ProcessEvents() does not return while the user is resizing or moving // On some platforms, ProcessEvents() does not return while the user is resizing or moving
// the window. We can avoid this issue by raising UpdateFrame and RenderFrame events // the window. We can avoid this issue by raising UpdateFrame and RenderFrame events
// whenever we encounter a size or move event. // whenever we encounter a size or move event.
Move += DispatchUpdateAndRenderFrame; // Note: hack disabled. Threaded rendering isprovides a better solution to this issue.
Resize += DispatchUpdateAndRenderFrame; //Move += DispatchUpdateAndRenderFrame;
//Resize += DispatchUpdateAndRenderFrame;
Debug.Print("Entering main loop."); Debug.Print("Entering main loop.");
update_watch.Start(); update_watch.Start();

View file

@ -1,4 +1,4 @@
#region --- License --- #region --- License ---
/* Licensed under the MIT/X11 license. /* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team. * Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution. * This notice may not be removed from any source distribution.
@ -115,8 +115,18 @@ namespace OpenTK.Graphics
implementation = factory.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); implementation = factory.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags);
// Note: this approach does not allow us to mix native and EGL contexts in the same process. // Note: this approach does not allow us to mix native and EGL contexts in the same process.
// This should not be a problem, as this use-case is not interesting for regular applications. // This should not be a problem, as this use-case is not interesting for regular applications.
// Note 2: some platforms may not support a direct way of getting the current context
// (this happens e.g. with DummyGLContext). In that case, we use a slow fallback which
// iterates through all known contexts and checks if any is current (check GetCurrentContext
// declaration).
if (GetCurrentContext == null) if (GetCurrentContext == null)
GetCurrentContext = factory.CreateGetCurrentGraphicsContext(); {
GetCurrentContextDelegate temp = factory.CreateGetCurrentGraphicsContext();
if (temp != null)
{
GetCurrentContext = temp;
}
}
} }
available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this));
@ -189,7 +199,13 @@ namespace OpenTK.Graphics
// A small hack to create a shared context with the first available context. // A small hack to create a shared context with the first available context.
foreach (WeakReference r in GraphicsContext.available_contexts.Values) foreach (WeakReference r in GraphicsContext.available_contexts.Values)
{ {
return (IGraphicsContext)r.Target; // Fix for bug 1874: if a GraphicsContext gets finalized
// (but not disposed), it won't be removed from available_contexts
// making this return null even if another valid context exists.
// The workaround is to simply ignore null targets.
IGraphicsContext target = r.Target as IGraphicsContext;
if (target != null)
return target;
} }
} }
return null; return null;
@ -253,7 +269,24 @@ namespace OpenTK.Graphics
#region public static IGraphicsContext CurrentContext #region public static IGraphicsContext CurrentContext
internal delegate ContextHandle GetCurrentContextDelegate(); internal delegate ContextHandle GetCurrentContextDelegate();
internal static GetCurrentContextDelegate GetCurrentContext; internal static GetCurrentContextDelegate GetCurrentContext = delegate
{
// Note: this is a slow, generic fallback for use with DummyGLContext.
// Most other platforms can query the current context directly (via
// [Wgl|Glx|Agl|Egl].GetCurrentContext()) so the GraphicsContext
// constructor will replace this implementation with a platform-specific
// one, if it exists.
foreach (WeakReference weak_ref in available_contexts.Values)
{
IGraphicsContext context = (IGraphicsContext)weak_ref.Target;
if (context.IsCurrent)
{
return (context as IGraphicsContextInternal).Context;
}
}
return ContextHandle.Zero;
};
/// <summary> /// <summary>
/// Gets the GraphicsContext that is current in the calling thread. /// Gets the GraphicsContext that is current in the calling thread.
@ -409,6 +442,20 @@ namespace OpenTK.Graphics
{ {
implementation.Update(window); implementation.Update(window);
} }
/// <summary>
/// Loads all OpenGL entry points.
/// </summary>
/// <exception cref="OpenTK.Graphics.GraphicsContextException">
/// Occurs when this instance is not current on the calling thread.
/// </exception>
public void LoadAll()
{
if (GraphicsContext.CurrentContext != this)
throw new GraphicsContextException();
implementation.LoadAll();
}
#endregion #endregion
@ -422,20 +469,6 @@ namespace OpenTK.Graphics
get { return implementation; } get { return implementation; }
} }
/// <summary>
/// Loads all OpenGL extensions.
/// </summary>
/// <exception cref="OpenTK.Graphics.GraphicsContextException">
/// Occurs when this instance is not the current GraphicsContext on the calling thread.
/// </exception>
void IGraphicsContextInternal.LoadAll()
{
if (GraphicsContext.CurrentContext != this)
throw new GraphicsContextException();
(implementation as IGraphicsContextInternal).LoadAll();
}
/// <summary> /// <summary>
/// Gets a handle to the OpenGL rendering context. /// Gets a handle to the OpenGL rendering context.
/// </summary> /// </summary>

View file

@ -14,7 +14,7 @@ using System.Diagnostics;
namespace OpenTK.Graphics namespace OpenTK.Graphics
{ {
/// <summary>Defines the format for graphics operations.</summary> /// <summary>Defines the format for graphics operations.</summary>
public class GraphicsMode public class GraphicsMode : IEquatable<GraphicsMode>
{ {
ColorFormat color_format, accumulator_format; ColorFormat color_format, accumulator_format;
int depth, stencil, buffers, samples; int depth, stencil, buffers, samples;
@ -180,21 +180,7 @@ namespace OpenTK.Graphics
{ {
get get
{ {
if (index == null) LazySelectGraphicsMode();
{
GraphicsMode mode;
mode = implementation.SelectGraphicsMode(ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
Index = mode.Index;
ColorFormat = mode.ColorFormat;
Depth = mode.Depth;
Stencil = mode.Stencil;
Samples = mode.Samples;
AccumulatorFormat = mode.AccumulatorFormat;
Buffers = mode.Buffers;
Stereo = mode.Stereo;
}
return index; return index;
} }
set { index = value; } set { index = value; }
@ -209,7 +195,11 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public ColorFormat ColorFormat public ColorFormat ColorFormat
{ {
get { return color_format; } get
{
LazySelectGraphicsMode();
return color_format;
}
private set { color_format = value; } private set { color_format = value; }
} }
@ -222,7 +212,11 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public ColorFormat AccumulatorFormat public ColorFormat AccumulatorFormat
{ {
get { return accumulator_format; } get
{
LazySelectGraphicsMode();
return accumulator_format;
}
private set { accumulator_format = value; } private set { accumulator_format = value; }
} }
@ -236,7 +230,11 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public int Depth public int Depth
{ {
get { return depth; } get
{
LazySelectGraphicsMode();
return depth;
}
private set { depth = value; } private set { depth = value; }
} }
@ -250,7 +248,11 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public int Stencil public int Stencil
{ {
get { return stencil; } get
{
LazySelectGraphicsMode();
return stencil;
}
private set { stencil = value; } private set { stencil = value; }
} }
@ -263,7 +265,11 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public int Samples public int Samples
{ {
get { return samples; } get
{
LazySelectGraphicsMode();
return samples;
}
private set { samples = value; } private set { samples = value; }
} }
@ -276,8 +282,12 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public bool Stereo public bool Stereo
{ {
get { return this.stereo; } get
private set { this.stereo = value; } {
LazySelectGraphicsMode();
return stereo;
}
private set { stereo = value; }
} }
#endregion #endregion
@ -290,8 +300,12 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public int Buffers public int Buffers
{ {
get { return this.buffers; } get
private set { this.buffers = value; } {
LazySelectGraphicsMode();
return buffers;
}
private set { buffers = value; }
} }
#endregion #endregion
@ -320,6 +334,30 @@ namespace OpenTK.Graphics
#endregion #endregion
#region --- Private Methods ---
// Queries the implementation for the actual graphics mode if this hasn't been done already.
// This method allows for lazy evaluation of the actual GraphicsMode and should be called
// by all GraphicsMode properties.
void LazySelectGraphicsMode()
{
if (index == null)
{
GraphicsMode mode = implementation.SelectGraphicsMode(color_format, depth, stencil, samples, accumulator_format, buffers, stereo);
Index = mode.Index;
ColorFormat = mode.ColorFormat;
Depth = mode.Depth;
Stencil = mode.Stencil;
Samples = mode.Samples;
AccumulatorFormat = mode.AccumulatorFormat;
Buffers = mode.Buffers;
Stereo = mode.Stereo;
}
}
#endregion
#region --- Overrides --- #region --- Overrides ---
/// <summary>Returns a System.String describing the current GraphicsFormat.</summary> /// <summary>Returns a System.String describing the current GraphicsFormat.</summary>
@ -330,6 +368,43 @@ namespace OpenTK.Graphics
Index, ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo); Index, ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
} }
/// <summary>
/// Returns the hashcode for this instance.
/// </summary>
/// <returns>A <see cref="System.Int32"/> hashcode for this instance.</returns>
public override int GetHashCode()
{
return Index.GetHashCode();
}
/// <summary>
/// Indicates whether obj is equal to this instance.
/// </summary>
/// <param name="obj">An object instance to compare for equality.</param>
/// <returns>True, if obj equals this instance; false otherwise.</returns>
public override bool Equals(object obj)
{
if (obj is GraphicsMode)
{
return Equals((GraphicsMode)obj);
}
return false;
}
#endregion
#region IEquatable<GraphicsMode> Members
/// <summary>
/// Indicates whether other represents the same mode as this instance.
/// </summary>
/// <param name="other">The GraphicsMode to compare to.</param>
/// <returns>True, if other is equal to this instance; false otherwise.</returns>
public bool Equals(GraphicsMode other)
{
return Index.HasValue && Index == other.Index;
}
#endregion #endregion
} }
} }

View file

@ -64,6 +64,11 @@ namespace OpenTK.Graphics
/// <para>This method only affects the debug version of OpenTK.dll.</para> /// <para>This method only affects the debug version of OpenTK.dll.</para>
/// </remarks> /// </remarks>
bool ErrorChecking { get; set; } bool ErrorChecking { get; set; }
/// <summary>
/// Loads all OpenGL entry points. Requires this instance to be current on the calling thread.
/// </summary>
void LoadAll();
} }
// Functions for internal use by OpenTK. // Functions for internal use by OpenTK.
@ -80,7 +85,7 @@ namespace OpenTK.Graphics
IGraphicsContext Implementation { get; } IGraphicsContext Implementation { get; }
/// <summary> /// <summary>
/// Prepares the entry points for OpenGL. /// Loads all OpenGL entry points. Requires this instance to be current on the calling thread.
/// </summary> /// </summary>
void LoadAll(); void LoadAll();

View file

@ -9126,6 +9126,10 @@ namespace OpenTK.Graphics.OpenGL
Rg16ui = ((int)0x823A), Rg16ui = ((int)0x823A),
Rg32i = ((int)0x823B), Rg32i = ((int)0x823B),
Rg32ui = ((int)0x823C), Rg32ui = ((int)0x823C),
CompressedRgbS3tcDxt1Ext = ((int)0x83F0),
CompressedRgbaS3tcDxt1Ext = ((int)0x83F1),
CompressedRgbaS3tcDxt3Ext = ((int)0x83F2),
CompressedRgbaS3tcDxt5Ext = ((int)0x83F3),
CompressedAlpha = ((int)0x84E9), CompressedAlpha = ((int)0x84E9),
CompressedLuminance = ((int)0x84EA), CompressedLuminance = ((int)0x84EA),
CompressedLuminanceAlpha = ((int)0x84EB), CompressedLuminanceAlpha = ((int)0x84EB),

View file

@ -755,12 +755,18 @@ namespace OpenTK.Graphics.OpenGL
#endregion #endregion
#region public static void DeleteTexture(int id) #region DeleteTexture
public static void DeleteTexture(int id) public static void DeleteTexture(int id)
{ {
DeleteTextures(1, ref id); DeleteTextures(1, ref id);
} }
[CLSCompliant(false)]
public static void DeleteTexture(uint id)
{
DeleteTextures(1, ref id);
}
#endregion #endregion

View file

@ -138,7 +138,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="v">The Vector3d to copy components from.</param> /// <param name="v">The Vector3d to copy components from.</param>
/// <param name="w">The w component of the new Vector4.</param> /// <param name="w">The w component of the new Vector4.</param>
public Vector4d(Vector3 v, double w) public Vector4d(Vector3d v, double w)
{ {
X = v.X; X = v.X;
Y = v.Y; Y = v.Y;

View file

@ -9,6 +9,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace OpenTK.Platform.Dummy namespace OpenTK.Platform.Dummy
@ -23,6 +25,7 @@ namespace OpenTK.Platform.Dummy
// This mode is not real. To receive a real mode we'd have to create a temporary context, which is not desirable! // This mode is not real. To receive a real mode we'd have to create a temporary context, which is not desirable!
bool vsync; bool vsync;
static int handle_count; static int handle_count;
Thread current_thread;
#region --- Constructors --- #region --- Constructors ---
@ -51,8 +54,31 @@ namespace OpenTK.Platform.Dummy
} }
public override void SwapBuffers() { } public override void SwapBuffers() { }
public override void MakeCurrent(IWindowInfo info) { }
public override bool IsCurrent { get { return true; } } public override void MakeCurrent(IWindowInfo info)
{
Thread new_thread = Thread.CurrentThread;
// A context may be current only on one thread at a time.
if (current_thread != null && new_thread != current_thread)
{
throw new GraphicsContextException(
"Cannot make context current on two threads at the same time");
}
if (info != null)
{
current_thread = Thread.CurrentThread;
}
else
{
current_thread = null;
}
}
public override bool IsCurrent
{
get { return current_thread != null && current_thread == Thread.CurrentThread; }
}
public override IntPtr GetAddress(string function) { return IntPtr.Zero; } public override IntPtr GetAddress(string function) { return IntPtr.Zero; }
@ -61,13 +87,8 @@ namespace OpenTK.Platform.Dummy
public override void Update(IWindowInfo window) public override void Update(IWindowInfo window)
{ } { }
#endregion
#region IGraphicsContextInternal Members
public override void LoadAll() public override void LoadAll()
{ { }
}
#endregion #endregion

View file

@ -484,11 +484,6 @@ namespace OpenTK.Platform.MacOS
#region IGraphicsContextInternal Members #region IGraphicsContextInternal Members
public override void LoadAll()
{
base.LoadAll();
}
private const string Library = "libdl.dylib"; private const string Library = "libdl.dylib";
[DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")] [DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")]

View file

@ -141,8 +141,10 @@ namespace OpenTK.Platform.Windows
if (sharedContext != null) if (sharedContext != null)
{ {
Debug.Print("Sharing state with context {0}", sharedContext.ToString()); Marshal.GetLastWin32Error();
Wgl.Imports.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, Handle.Handle); Debug.Write("Sharing state with context {0}: ", sharedContext.ToString());
bool result = Wgl.Imports.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, Handle.Handle);
Debug.WriteLine(result ? "success!" : "failed with win32 error " + Marshal.GetLastWin32Error());
} }
} }
} }
@ -225,10 +227,6 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
#endregion
#region --- IGLContextInternal Members ---
#region void LoadAll() #region void LoadAll()
public override void LoadAll() public override void LoadAll()
@ -242,6 +240,10 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
#endregion
#region --- IGLContextInternal Members ---
#region IWindowInfo IGLContextInternal.Info #region IWindowInfo IGLContextInternal.Info
/* /*
IWindowInfo IGraphicsContextInternal.Info IWindowInfo IGraphicsContextInternal.Info

View file

@ -103,13 +103,13 @@ namespace OpenTK.Platform.Windows
// don't move it below the CreateWindow calls. // don't move it below the CreateWindow calls.
WindowProcedureDelegate = WindowProcedure; WindowProcedureDelegate = WindowProcedure;
// This timer callback is called periodically when the window enters a sizing / moving modal loop. //// This timer callback is called periodically when the window enters a sizing / moving modal loop.
ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time) //ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time)
{ //{
// Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events. // // Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events.
if (Move != null) // if (Move != null)
Move(this, EventArgs.Empty); // Move(this, EventArgs.Empty);
}; //};
// To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be // To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be
// bound to the top-level window, but rather to a child window docked in the parent. // bound to the top-level window, but rather to a child window docked in the parent.

View file

@ -1,4 +1,4 @@
#region License #region License
// //
// The Open Toolkit Library License // The Open Toolkit Library License
// //
@ -159,6 +159,8 @@ namespace OpenTK.Platform.Windows
{ {
WinWindowInfo window = (WinWindowInfo)native_window.WindowInfo; WinWindowInfo window = (WinWindowInfo)native_window.WindowInfo;
// See http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
// for more details
Debug.Write("Selecting pixel format (ARB)... "); Debug.Write("Selecting pixel format (ARB)... ");
if (Wgl.Delegates.wglChoosePixelFormatARB == null || Wgl.Delegates.wglGetPixelFormatAttribivARB == null) if (Wgl.Delegates.wglChoosePixelFormatARB == null || Wgl.Delegates.wglGetPixelFormatAttribivARB == null)
{ {
@ -170,10 +172,10 @@ namespace OpenTK.Platform.Windows
{ {
(int)WGL_ARB_pixel_format.AccelerationArb, (int)WGL_ARB_pixel_format.AccelerationArb,
(int)WGL_ARB_pixel_format.AlphaBitsArb,
(int)WGL_ARB_pixel_format.RedBitsArb, (int)WGL_ARB_pixel_format.RedBitsArb,
(int)WGL_ARB_pixel_format.GreenBitsArb, (int)WGL_ARB_pixel_format.GreenBitsArb,
(int)WGL_ARB_pixel_format.BlueBitsArb, (int)WGL_ARB_pixel_format.BlueBitsArb,
(int)WGL_ARB_pixel_format.AlphaBitsArb,
(int)WGL_ARB_pixel_format.ColorBitsArb, (int)WGL_ARB_pixel_format.ColorBitsArb,
(int)WGL_ARB_pixel_format.DepthBitsArb, (int)WGL_ARB_pixel_format.DepthBitsArb,
@ -182,10 +184,10 @@ namespace OpenTK.Platform.Windows
(int)WGL_ARB_multisample.SampleBuffersArb, (int)WGL_ARB_multisample.SampleBuffersArb,
(int)WGL_ARB_multisample.SamplesArb, (int)WGL_ARB_multisample.SamplesArb,
(int)WGL_ARB_pixel_format.AccumAlphaBitsArb,
(int)WGL_ARB_pixel_format.AccumRedBitsArb, (int)WGL_ARB_pixel_format.AccumRedBitsArb,
(int)WGL_ARB_pixel_format.AccumGreenBitsArb, (int)WGL_ARB_pixel_format.AccumGreenBitsArb,
(int)WGL_ARB_pixel_format.AccumBlueBitsArb, (int)WGL_ARB_pixel_format.AccumBlueBitsArb,
(int)WGL_ARB_pixel_format.AccumAlphaBitsArb,
(int)WGL_ARB_pixel_format.AccumBitsArb, (int)WGL_ARB_pixel_format.AccumBitsArb,
(int)WGL_ARB_pixel_format.DoubleBufferArb, (int)WGL_ARB_pixel_format.DoubleBufferArb,
@ -198,12 +200,13 @@ namespace OpenTK.Platform.Windows
int[] attribs_values = new int[] int[] attribs_values = new int[]
{ {
(int)WGL_ARB_pixel_format.AccelerationArb, (int)WGL_ARB_pixel_format.FullAccelerationArb, (int)WGL_ARB_pixel_format.AccelerationArb, (int)WGL_ARB_pixel_format.FullAccelerationArb,
(int)WGL_ARB_pixel_format.DrawToWindowArb, 1,
(int)WGL_ARB_pixel_format.RedBitsArb, color.Red, (int)WGL_ARB_pixel_format.RedBitsArb, color.Red,
(int)WGL_ARB_pixel_format.GreenBitsArb, color.Green, (int)WGL_ARB_pixel_format.GreenBitsArb, color.Green,
(int)WGL_ARB_pixel_format.BlueBitsArb, color.Blue, (int)WGL_ARB_pixel_format.BlueBitsArb, color.Blue,
(int)WGL_ARB_pixel_format.AlphaBitsArb, color.Alpha, (int)WGL_ARB_pixel_format.AlphaBitsArb, color.Alpha,
(int)WGL_ARB_pixel_format.ColorBitsArb, color.BitsPerPixel, (int)WGL_ARB_pixel_format.ColorBitsArb, color.BitsPerPixel - color.Alpha, // Should not contain alpha bpp (see spec)
(int)WGL_ARB_pixel_format.DepthBitsArb, depth, (int)WGL_ARB_pixel_format.DepthBitsArb, depth,
(int)WGL_ARB_pixel_format.StencilBitsArb, stencil, (int)WGL_ARB_pixel_format.StencilBitsArb, stencil,
@ -215,30 +218,38 @@ namespace OpenTK.Platform.Windows
(int)WGL_ARB_pixel_format.AccumGreenBitsArb, accum.Green, (int)WGL_ARB_pixel_format.AccumGreenBitsArb, accum.Green,
(int)WGL_ARB_pixel_format.AccumBlueBitsArb, accum.Blue, (int)WGL_ARB_pixel_format.AccumBlueBitsArb, accum.Blue,
(int)WGL_ARB_pixel_format.AccumAlphaBitsArb, accum.Alpha, (int)WGL_ARB_pixel_format.AccumAlphaBitsArb, accum.Alpha,
(int)WGL_ARB_pixel_format.AccumBitsArb, accum.BitsPerPixel, (int)WGL_ARB_pixel_format.AccumBitsArb, accum.BitsPerPixel, // Spec doesn't mention wether alpha bpp should be included...
(int)WGL_ARB_pixel_format.DoubleBufferArb, 1, (int)WGL_ARB_pixel_format.DoubleBufferArb, buffers > 1 ? 1 : 0,
(int)WGL_ARB_pixel_format.StereoArb, stereo ? 1 : 0, (int)WGL_ARB_pixel_format.StereoArb, stereo ? 1 : 0,
0, 0 0, 0
}; };
int[] pixel = new int[1], num_formats = new int[1]; int[] pixel = new int[1], num_formats = new int[1];
Wgl.Arb.ChoosePixelFormat(window.DeviceContext, attribs_values, null, 1, pixel, num_formats); bool success = Wgl.Arb.ChoosePixelFormat(window.DeviceContext, attribs_values, null, 1, pixel, num_formats);
if (num_formats[0] == 0 || pixel[0] == 0) if (!success || num_formats[0] == 0 || pixel[0] == 0)
{ {
// Try again without an accumulator. Many modern cards cannot accelerate multisampled formats with accumulator buffers. // Try again without an accumulator. Many modern cards cannot accelerate multisampled formats with accumulator buffers.
attribs_values[10 * 2 + 1] = attribs_values[11 * 2 + 1] = attribs_values[12 * 2 + 1] = attribs_values[13 * 2 + 1] = attribs_values[14 * 2 + 1] = 0; int index_of_accum = Array.IndexOf(attribs_values, (int)WGL_ARB_pixel_format.AccumRedBitsArb);
attribs_values[index_of_accum + 1] = attribs_values[index_of_accum + 3] =
attribs_values[index_of_accum + 5] = attribs_values[index_of_accum + 7] =
attribs_values[index_of_accum + 9] = 0;
Wgl.Arb.ChoosePixelFormat(window.DeviceContext, attribs_values, null, 1, pixel, num_formats); Wgl.Arb.ChoosePixelFormat(window.DeviceContext, attribs_values, null, 1, pixel, num_formats);
} }
if (num_formats[0] == 0 || pixel[0] == 0) if (!success || num_formats[0] == 0 || pixel[0] == 0)
{ {
Debug.WriteLine("failed"); Debug.WriteLine("failed (no suitable pixel format).");
return null; return null;
} }
// Find out what we really got as a format: // Find out what we really got as a format:
Wgl.Arb.GetPixelFormatAttrib(window.DeviceContext, pixel[0], 0, attribs.Length, attribs, values); success = Wgl.Arb.GetPixelFormatAttrib(window.DeviceContext, pixel[0], 0, attribs.Length - 1, attribs, values);
if (!success)
{
Debug.WriteLine("failed (pixel format attributes could not be determined).");
return null;
}
GraphicsMode mode = new GraphicsMode(new IntPtr(pixel[0]), GraphicsMode mode = new GraphicsMode(new IntPtr(pixel[0]),
new ColorDepth(values[1], values[2], values[3], values[4]), new ColorDepth(values[1], values[2], values[3], values[4]),
values[6], values[6],
@ -258,3 +269,4 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
} }
} }

View file

@ -114,6 +114,8 @@ namespace OpenTK.Platform.Windows
stick.Details.PovType |= PovType.Continuous; stick.Details.PovType |= PovType.Continuous;
} }
#warning "Implement joystick name detection for WinMM."
stick.Description = String.Format("Joystick/Joystick #{0} ({1} axes, {2} buttons)", number, stick.Axis.Count, stick.Button.Count);
// Todo: Try to get the device name from the registry. Oh joy! // Todo: Try to get the device name from the registry. Oh joy!
//string key_path = String.Format("{0}\\{1}\\{2}", RegistryJoyConfig, caps.RegKey, RegstryJoyCurrent); //string key_path = String.Format("{0}\\{1}\\{2}", RegistryJoyConfig, caps.RegKey, RegstryJoyCurrent);
//RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path, false); //RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path, false);

View file

@ -72,7 +72,8 @@ namespace OpenTK.Platform.X11
static API() static API()
{ {
Debug.Print("Initializing threaded X11: {0}.", Functions.XInitThreads().ToString()); int has_threaded_x = Functions.XInitThreads();
Debug.Print("Initializing threaded X11: {0}.", has_threaded_x.ToString());
defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero); defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero);
@ -85,7 +86,7 @@ namespace OpenTK.Platform.X11
} }
Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount); Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount);
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); //AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
} }
static void CurrentDomain_ProcessExit(object sender, EventArgs e) static void CurrentDomain_ProcessExit(object sender, EventArgs e)

View file

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
namespace OpenTK.Platform.X11 namespace OpenTK.Platform.X11
{ {
internal class X11XrandrDisplayDevice : IDisplayDeviceDriver internal class X11DisplayDevice : IDisplayDeviceDriver
{ {
static object display_lock = new object(); static object display_lock = new object();
// Store a mapping between resolutions and their respective // Store a mapping between resolutions and their respective
@ -29,10 +29,12 @@ namespace OpenTK.Platform.X11
static Dictionary<DisplayDevice, int> deviceToScreen = new Dictionary<DisplayDevice, int>(); static Dictionary<DisplayDevice, int> deviceToScreen = new Dictionary<DisplayDevice, int>();
// Keep the time when the config of each screen was last updated. // Keep the time when the config of each screen was last updated.
static List<IntPtr> lastConfigUpdate = new List<IntPtr>(); static List<IntPtr> lastConfigUpdate = new List<IntPtr>();
static bool xinerama_supported, xrandr_supported, xf86_supported;
#region --- Constructors --- #region --- Constructors ---
static X11XrandrDisplayDevice() static X11DisplayDevice()
{ {
using (new XLock(API.DefaultDisplay)) using (new XLock(API.DefaultDisplay))
{ {
@ -40,32 +42,12 @@ namespace OpenTK.Platform.X11
bool xinerama_supported = false; bool xinerama_supported = false;
try try
{ {
// Try to use Xinerama to obtain the geometry of all output devices. xinerama_supported = QueryXinerama(devices);
int event_base, error_base; }
if (NativeMethods.XineramaQueryExtension(API.DefaultDisplay, out event_base, out error_base) && catch
NativeMethods.XineramaIsActive(API.DefaultDisplay)) {
{ Debug.Print("Xinerama query failed.");
IList<XineramaScreenInfo> screens = NativeMethods.XineramaQueryScreens(API.DefaultDisplay);
bool first = true;
foreach (XineramaScreenInfo screen in screens)
{
DisplayDevice dev = new DisplayDevice();
dev.Bounds = new Rectangle(screen.X, screen.Y, screen.Width, screen.Height);
if (first)
{
// We consider the first device returned by Xinerama as the primary one.
// Makes sense conceptually, but is there a way to verify this?
dev.IsPrimary = true;
first = false;
}
devices.Add(dev);
// It seems that all X screens are equal to 0 is Xinerama is enabled, at least on Nvidia (verify?)
deviceToScreen.Add(dev, 0 /*screen.ScreenNumber*/);
xinerama_supported = true;
}
}
} }
catch { Debug.Print("Xinerama query failed."); }
if (!xinerama_supported) if (!xinerama_supported)
{ {
@ -80,86 +62,145 @@ namespace OpenTK.Platform.X11
} }
} }
// Get available resolutions. Then, for each resolution get all available rates. try
foreach (DisplayDevice dev in devices)
{ {
int screen = deviceToScreen[dev]; xrandr_supported = QueryXRandR(devices);
}
catch { }
IntPtr timestamp_of_last_update; if (!xrandr_supported)
Functions.XRRTimes(API.DefaultDisplay, screen, out timestamp_of_last_update); {
lastConfigUpdate.Add(timestamp_of_last_update); Debug.Print("XRandR query failed, falling back to XF86.");
try
List<DisplayResolution> available_res = new List<DisplayResolution>();
// Add info for a new screen.
screenResolutionToIndex.Add(new Dictionary<DisplayResolution, int>());
int[] depths = FindAvailableDepths(screen);
int resolution_count = 0;
foreach (XRRScreenSize size in FindAvailableResolutions(screen))
{ {
if (size.Width == 0 || size.Height == 0) xf86_supported = QueryXF86(devices);
{
Debug.Print("[Warning] XRandR returned an invalid resolution ({0}) for display device {1}", size, screen);
continue;
}
short[] rates = null;
rates = Functions.XRRRates(API.DefaultDisplay, screen, resolution_count);
// It seems that XRRRates returns 0 for modes that are larger than the screen
// can support, as well as for all supported modes. On Ubuntu 7.10 the tool
// "Screens and Graphics" does report these modes, though.
foreach (short rate in rates)
{
// Note: some X servers (like Xming on Windows) do not report any rates other than 0.
// If we only have 1 rate, add it even if it is 0.
if (rate != 0 || rates.Length == 1)
foreach (int depth in depths)
available_res.Add(new DisplayResolution(0, 0, size.Width, size.Height, depth, (float)rate));
}
// Keep the index of this resolution - we will need it for resolution changes later.
foreach (int depth in depths)
{
// Note that Xinerama may return multiple devices for a single screen. XRandR will
// not distinguish between the two as far as resolutions are supported (since XRandR
// operates on X screens, not display devices) - we need to be careful not to add the
// same resolution twice!
DisplayResolution res = new DisplayResolution(0, 0, size.Width, size.Height, depth, 0);
if (!screenResolutionToIndex[screen].ContainsKey(res))
screenResolutionToIndex[screen].Add(res, resolution_count);
}
++resolution_count;
} }
catch { }
if (!xf86_supported)
// The resolution of the current DisplayDevice is discovered through XRRConfigCurrentConfiguration. {
// Its refresh rate is discovered by the FindCurrentRefreshRate call. Debug.Print("XF86 query failed, no DisplayDevice support available.");
// Its depth is discovered by the FindCurrentDepth call. }
float current_refresh_rate = FindCurrentRefreshRate(screen);
int current_depth = FindCurrentDepth(screen);
IntPtr screen_config = Functions.XRRGetScreenInfo(API.DefaultDisplay, Functions.XRootWindow(API.DefaultDisplay, screen));
ushort current_rotation; // Not needed.
int current_resolution_index = Functions.XRRConfigCurrentConfiguration(screen_config, out current_rotation);
if (dev.Bounds == Rectangle.Empty)
dev.Bounds = new Rectangle(0, 0, available_res[current_resolution_index].Width, available_res[current_resolution_index].Height);
dev.BitsPerPixel = current_depth;
dev.RefreshRate = current_refresh_rate;
dev.AvailableResolutions = available_res;
deviceToDefaultResolution.Add(dev, current_resolution_index);
} }
} }
} }
internal X11XrandrDisplayDevice() { } internal X11DisplayDevice() { }
#endregion #endregion
#region --- Private Methods --- #region --- Private Methods ---
static bool QueryXinerama(List<DisplayDevice> devices)
{
// Try to use Xinerama to obtain the geometry of all output devices.
int event_base, error_base;
if (NativeMethods.XineramaQueryExtension(API.DefaultDisplay, out event_base, out error_base) &&
NativeMethods.XineramaIsActive(API.DefaultDisplay))
{
IList<XineramaScreenInfo> screens = NativeMethods.XineramaQueryScreens(API.DefaultDisplay);
bool first = true;
foreach (XineramaScreenInfo screen in screens)
{
DisplayDevice dev = new DisplayDevice();
dev.Bounds = new Rectangle(screen.X, screen.Y, screen.Width, screen.Height);
if (first)
{
// We consider the first device returned by Xinerama as the primary one.
// Makes sense conceptually, but is there a way to verify this?
dev.IsPrimary = true;
first = false;
}
devices.Add(dev);
// It seems that all X screens are equal to 0 is Xinerama is enabled, at least on Nvidia (verify?)
deviceToScreen.Add(dev, 0 /*screen.ScreenNumber*/);
}
}
return true;
}
static bool QueryXRandR(List<DisplayDevice> devices)
{
// Get available resolutions. Then, for each resolution get all available rates.
foreach (DisplayDevice dev in devices)
{
int screen = deviceToScreen[dev];
IntPtr timestamp_of_last_update;
Functions.XRRTimes(API.DefaultDisplay, screen, out timestamp_of_last_update);
lastConfigUpdate.Add(timestamp_of_last_update);
List<DisplayResolution> available_res = new List<DisplayResolution>();
// Add info for a new screen.
screenResolutionToIndex.Add(new Dictionary<DisplayResolution, int>());
int[] depths = FindAvailableDepths(screen);
int resolution_count = 0;
foreach (XRRScreenSize size in FindAvailableResolutions(screen))
{
if (size.Width == 0 || size.Height == 0)
{
Debug.Print("[Warning] XRandR returned an invalid resolution ({0}) for display device {1}", size, screen);
continue;
}
short[] rates = null;
rates = Functions.XRRRates(API.DefaultDisplay, screen, resolution_count);
// It seems that XRRRates returns 0 for modes that are larger than the screen
// can support, as well as for all supported modes. On Ubuntu 7.10 the tool
// "Screens and Graphics" does report these modes, though.
foreach (short rate in rates)
{
// Note: some X servers (like Xming on Windows) do not report any rates other than 0.
// If we only have 1 rate, add it even if it is 0.
if (rate != 0 || rates.Length == 1)
foreach (int depth in depths)
available_res.Add(new DisplayResolution(0, 0, size.Width, size.Height, depth, (float)rate));
}
// Keep the index of this resolution - we will need it for resolution changes later.
foreach (int depth in depths)
{
// Note that Xinerama may return multiple devices for a single screen. XRandR will
// not distinguish between the two as far as resolutions are supported (since XRandR
// operates on X screens, not display devices) - we need to be careful not to add the
// same resolution twice!
DisplayResolution res = new DisplayResolution(0, 0, size.Width, size.Height, depth, 0);
if (!screenResolutionToIndex[screen].ContainsKey(res))
screenResolutionToIndex[screen].Add(res, resolution_count);
}
++resolution_count;
}
// The resolution of the current DisplayDevice is discovered through XRRConfigCurrentConfiguration.
// Its refresh rate is discovered by the FindCurrentRefreshRate call.
// Its depth is discovered by the FindCurrentDepth call.
float current_refresh_rate = FindCurrentRefreshRate(screen);
int current_depth = FindCurrentDepth(screen);
IntPtr screen_config = Functions.XRRGetScreenInfo(API.DefaultDisplay, Functions.XRootWindow(API.DefaultDisplay, screen));
ushort current_rotation; // Not needed.
int current_resolution_index = Functions.XRRConfigCurrentConfiguration(screen_config, out current_rotation);
if (dev.Bounds == Rectangle.Empty)
dev.Bounds = new Rectangle(0, 0, available_res[current_resolution_index].Width, available_res[current_resolution_index].Height);
dev.BitsPerPixel = current_depth;
dev.RefreshRate = current_refresh_rate;
dev.AvailableResolutions = available_res;
deviceToDefaultResolution.Add(dev, current_resolution_index);
}
return true;
}
static bool QueryXF86(List<DisplayDevice> devices)
{
return false;
}
#region static int[] FindAvailableDepths(int screen) #region static int[] FindAvailableDepths(int screen)
static int[] FindAvailableDepths(int screen) static int[] FindAvailableDepths(int screen)
@ -206,14 +247,8 @@ namespace OpenTK.Platform.X11
#endregion #endregion
#endregion static bool ChangeResolutionXRandR(DisplayDevice device, DisplayResolution resolution)
#region --- IDisplayDeviceDriver Members ---
public bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
{ {
// If resolution is null, restore the default resolution (new_resolution_index = 0).
using (new XLock(API.DefaultDisplay)) using (new XLock(API.DefaultDisplay))
{ {
int screen = deviceToScreen[device]; int screen = deviceToScreen[device];
@ -228,19 +263,46 @@ namespace OpenTK.Platform.X11
[new DisplayResolution(0, 0, resolution.Width, resolution.Height, resolution.BitsPerPixel, 0)]; [new DisplayResolution(0, 0, resolution.Width, resolution.Height, resolution.BitsPerPixel, 0)];
else else
new_resolution_index = deviceToDefaultResolution[device]; new_resolution_index = deviceToDefaultResolution[device];
Debug.Print("Changing size of screen {0} from {1} to {2}", Debug.Print("Changing size of screen {0} from {1} to {2}",
screen, current_resolution_index, new_resolution_index); screen, current_resolution_index, new_resolution_index);
return 0 == Functions.XRRSetScreenConfigAndRate(API.DefaultDisplay, screen_config, root, new_resolution_index, return 0 == Functions.XRRSetScreenConfigAndRate(API.DefaultDisplay, screen_config, root, new_resolution_index,
current_rotation, (short)(resolution != null ? resolution.RefreshRate : 0), lastConfigUpdate[screen]); current_rotation, (short)(resolution != null ? resolution.RefreshRate : 0), lastConfigUpdate[screen]);
} }
} }
static bool ChangeResolutionXF86(DisplayDevice device, DisplayResolution resolution)
{
return false;
}
#endregion
#region --- IDisplayDeviceDriver Members ---
public bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
{
// If resolution is null, restore the default resolution (new_resolution_index = 0).
if (xrandr_supported)
{
return ChangeResolutionXRandR(device, resolution);
}
else if (xf86_supported)
{
return ChangeResolutionXF86(device, resolution);
}
else
{
return false;
}
}
public bool TryRestoreResolution(DisplayDevice device) public bool TryRestoreResolution(DisplayDevice device)
{ {
return TryChangeResolution(device, null); return TryChangeResolution(device, null);
//System.Diagnostics.Process.Start("xrandr", "-s -0").WaitForExit(); // Hack, but works ;)
} }
#endregion #endregion

View file

@ -52,7 +52,7 @@ namespace OpenTK.Platform.X11
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver() public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
{ {
return new X11XrandrDisplayDevice(); return new X11DisplayDevice();
} }
public virtual IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) public virtual IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)

View file

@ -386,10 +386,6 @@ namespace OpenTK.Platform.X11
#endregion #endregion
#endregion
#region --- IGLContextInternal Members ---
#region LoadAll #region LoadAll
public override void LoadAll() public override void LoadAll()
@ -403,7 +399,11 @@ namespace OpenTK.Platform.X11
#endregion #endregion
#region IWindowInfo IGLContextInternal.Info #endregion
#region --- IGLContextInternal Members ---
#region IWindowInfo IGLContextInternal.Info
//IWindowInfo IGraphicsContextInternal.Info { get { return window; } } //IWindowInfo IGraphicsContextInternal.Info { get { return window; } }

View file

@ -164,6 +164,9 @@ namespace OpenTK.Platform.X11
if (window.WindowHandle == IntPtr.Zero) if (window.WindowHandle == IntPtr.Zero)
throw new ApplicationException("XCreateWindow call failed (returned 0)."); throw new ApplicationException("XCreateWindow call failed (returned 0).");
if (title != null)
Functions.XStoreName(window.Display, window.WindowHandle, title);
} }
// Set the window hints // Set the window hints
@ -181,6 +184,15 @@ namespace OpenTK.Platform.X11
Functions.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { _atom_wm_destroy }, 1); Functions.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { _atom_wm_destroy }, 1);
} }
// Set the initial window size to ensure X, Y, Width, Height and the rest
// return the correct values inside the constructor and the Load event.
XEvent e = new XEvent();
e.ConfigureEvent.x = x;
e.ConfigureEvent.y = y;
e.ConfigureEvent.width = width;
e.ConfigureEvent.height = height;
RefreshWindowBounds(ref e);
driver = new X11Input(window); driver = new X11Input(window);
Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle)); Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle));

View file

@ -48,7 +48,7 @@ namespace OpenTK.Platform.X11
visual = SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo); visual = SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo);
if (visual == IntPtr.Zero) if (visual == IntPtr.Zero)
throw new GraphicsContextException("Requested GraphicsMode not available."); throw new GraphicsModeException("Requested GraphicsMode not available.");
XVisualInfo info = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo)); XVisualInfo info = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo));

View file

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("The Open Toolkit Library")] [assembly: AssemblyTitle("OpenTK")]
[assembly: AssemblyDescription("Open source game development toolkit for .Net/Mono.")] [assembly: AssemblyDescription("Open source game development toolkit for .Net/Mono.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Open Toolkit Library")] [assembly: AssemblyCompany("The Open Toolkit Library")]
@ -32,12 +32,15 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("0.9.9.4")] [assembly: AssemblyVersion("1.0.0.201")]
[assembly: AssemblyFileVersion("0.9.9.4")] [assembly: AssemblyFileVersion("1.0.0.201")]
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
[assembly: System.Security.AllowPartiallyTrustedCallers] [assembly: System.Security.AllowPartiallyTrustedCallers]
#if NET40
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
#endif
#if SIGN_ASSEMBLY #if SIGN_ASSEMBLY
[assembly: AssemblyKeyFile(@"../../../OpenTK.snk")] [assembly: AssemblyKeyFile(@"../../../OpenTK.snk")]
#endif #endif