Removed OpenTK Examples

This commit is contained in:
varon 2016-07-15 13:33:15 +02:00
parent 0d9b1115f3
commit b1b543849e
165 changed files with 0 additions and 19732 deletions

View file

@ -9,11 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "Source\OpenTK\Ope
{C426C9D1-8857-4E52-BAC7-4C05EE6070AB} = {C426C9D1-8857-4E52-BAC7-4C05EE6070AB}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Examples", "Source\Examples\OpenTK.Examples.csproj", "{868E37B3-0000-0000-0000-000000000000}"
ProjectSection(ProjectDependencies) = postProject
{75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLControl", "Source\GLControl\OpenTK.GLControl.csproj", "{A625BE88-0000-0000-0000-000000000000}"
ProjectSection(ProjectDependencies) = postProject
{75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8}
@ -25,7 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Installer.Nsis", "Ins
{650C6F3D-33B5-4216-9536-956AB42C0624} = {650C6F3D-33B5-4216-9536-956AB42C0624}
{A625BE88-0000-0000-0000-000000000000} = {A625BE88-0000-0000-0000-000000000000}
{75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8}
{868E37B3-0000-0000-0000-000000000000} = {868E37B3-0000-0000-0000-000000000000}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Docs", "Documentation\Build.Docs.csproj", "{650C6F3D-33B5-4216-9536-956AB42C0624}"
@ -51,7 +45,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Installer.Zip", "Inst
{650C6F3D-33B5-4216-9536-956AB42C0624} = {650C6F3D-33B5-4216-9536-956AB42C0624}
{A625BE88-0000-0000-0000-000000000000} = {A625BE88-0000-0000-0000-000000000000}
{75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8}
{868E37B3-0000-0000-0000-000000000000} = {868E37B3-0000-0000-0000-000000000000}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Installer.Nuget", "Installers\Nuget\Build.Installer.Nuget.csproj", "{ADC34399-7613-44D2-90B2-19250F12FE7B}"
@ -97,15 +90,6 @@ Global
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU

View file

@ -1,51 +0,0 @@
Waiting for the Barbarians
What are we waiting for, assembled in the forum?
The barbarians are to arrive today.
Why such inaction in the Senate?
Why do the Senators sit and pass no laws?
Because the barbarians are to arrive today.
What laws can the Senators pass any more?
When the barbarians come they will make the laws.
Why did our emperor wake up so early,
and sits at the greatest gate of the city,
on the throne, solemn, wearing the crown?
Because the barbarians are to arrive today.
And the emperor waits to receive
their chief. Indeed he has prepared
to give him a scroll. Therein he inscribed
many titles and names of honor.
Why have our two consuls and the praetors come out
today in their red, embroidered togas;
why do they wear amethyst-studded bracelets,
and rings with brilliant, glittering emeralds;
why are they carrying costly canes today,
wonderfully carved with silver and gold?
Because the barbarians are to arrive today,
and such things dazzle the barbarians.
Why don't the worthy orators come as always
to make their speeches, to have their say?
Because the barbarians are to arrive today;
and they get bored with eloquence and orations.
Why all of a sudden this unrest
and confusion. (How solemn the faces have become).
Why are the streets and squares clearing quickly,
and all return to their homes, so deep in thought?
Because night is here but the barbarians have not come.
And some people arrived from the borders,
and said that there are no longer any barbarians.
And now what shall become of us without any barbarians?
Those people were some kind of solution.
- Constantine P. Cavafy (1904)

View file

@ -1,9 +0,0 @@
// Copyright (c) 2008 the OpenTK Team. See license.txt for legal bla
uniform samplerCube Earth;
varying vec3 Normal;
void main()
{
gl_FragColor = textureCube( Earth, Normal.xyz );
}

View file

@ -1,10 +0,0 @@
// Copyright (c) 2008 the OpenTK Team. See license.txt for legal bla
// MUST be written to for FS
varying vec3 Normal;
void main()
{
gl_Position = ftransform();
Normal = /*gl_NormalMatrix * */ gl_Normal ;
}

View file

@ -1,66 +0,0 @@
#version 110
// www.OpenTK.net GLSL Julia Set (c) 2008 Christoph Brandtner
// uniforms from OpenGL
uniform sampler1D COLORTABLE;
uniform float CETX;
uniform float CETY;
uniform float SCALINGX;
uniform float SCALINGY;
uniform float OFFSETX;
uniform float OFFSETY;
// GLSL internal variables.
const int MAXIterations = 16; // must be greater than zero, 16 is a good blend between detail and speed
float XPos;
float YPos;
float XQuad;
float YQuad; // half precision floating point could be used on those 4 floats for speed, but will throw a warning.
int TableIndex;
int LoopCount;
// this function reduces duplicate code
void Iterate(void)
{
YPos = 2.0 * XPos * YPos + CETY;
XPos = XQuad - YQuad + CETX;
XQuad = pow(XPos, 2.0);
YQuad = pow(YPos, 2.0);
TableIndex++;
if ( (XQuad + YQuad) > 4.0 ) LoopCount = MAXIterations; // skip further iterations for this Pixel
LoopCount++;
}
// Shader entry point, this is executed per Pixel
void main(void)
{
XPos = gl_FragCoord.x / SCALINGX - OFFSETX;
YPos = gl_FragCoord.y / SCALINGY - OFFSETY;
XQuad = pow(XPos, 2.0);
YQuad = pow(YPos, 2.0);
TableIndex = -1;
LoopCount = 0;
// the loop is unrolled for SM 2.0 compatibility
if ( LoopCount <= MAXIterations ) Iterate(); // TableIndex==0
if ( LoopCount > 1 ) discard; // attempt to early-out, will affect ~1/3 of all Pixels
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate();
if ( LoopCount <= MAXIterations ) Iterate(); // TableIndex==16
float FinalTableIndex = float( TableIndex ) / float( MAXIterations );
gl_FragColor = texture1D( COLORTABLE, FinalTableIndex ); // lookup texture for output
// gl_FragColor.rgb = vec3(FinalTableIndex); // Debug: output greyscale
}

View file

@ -1,41 +0,0 @@
#version 120
// www.OpenTK.net GLSL Julia Set (c) 2008 Christoph Brandtner
uniform sampler1D COLORTABLE;
uniform float CETX;
uniform float CETY;
uniform float SCALINGX;
uniform float SCALINGY;
uniform float OFFSETX;
uniform float OFFSETY;
const int MAXIterations = 32; // *must* be > 0
void main(void)
{
float XPos = gl_FragCoord.x / SCALINGX - OFFSETX;
float YPos = gl_FragCoord.y / SCALINGY - OFFSETY;
float XQuad = pow( XPos, 2.0 );
float YQuad = pow( YPos, 2.0 );
int TableIndex = -1;
int LoopCount = 0;
while ( LoopCount <= MAXIterations )
{
YPos = 2.0 * XPos * YPos + CETY;
XPos = XQuad - YQuad + CETX;
XQuad = pow( XPos, 2.0 );
YQuad = pow( YPos, 2.0 );
TableIndex++;
if ( (XQuad + YQuad) > 4.0 )
{
if (TableIndex == 0)
discard;
LoopCount = MAXIterations;
}
LoopCount++;
}
float FinalTableIndex = float( TableIndex ) / float( MAXIterations );
gl_FragColor = texture1D( COLORTABLE, FinalTableIndex ); // lookup texture for output
// gl_FragColor.rgb = vec3( FinalTableIndex ); // Debug: output greyscale
}

View file

@ -1,4 +0,0 @@
void main(void)
{
gl_Position = ftransform(); // gl_ModelViewProjectionMatrix * gl_Vertex;
}

View file

@ -1,57 +0,0 @@
// Copyright (c) 2008 the OpenTK Team. See license.txt for legal bla
// Material uniforms
uniform sampler2D Material_DiffuseAndHeight;
uniform sampler2D Material_NormalAndGloss;
uniform vec3 Material_ScaleBiasShininess; // x=Scale, y=Bias, z=Shininess
// Light uniforms
uniform vec3 Light_DiffuseColor;
uniform vec3 Light_SpecularColor;
// from VS
varying vec3 VaryingLightVector;
varying vec3 VaryingEyeVector;
vec3 normal;
void main()
{
vec3 lightVector = normalize( VaryingLightVector );
vec3 eyeVector = normalize( VaryingEyeVector );
// first, find the parallax displacement by reading only the height map
float parallaxOffset = texture2D( Material_DiffuseAndHeight, gl_TexCoord[0].st ).a *
Material_ScaleBiasShininess.x - Material_ScaleBiasShininess.y;
vec2 newTexCoords = gl_TexCoord[0].st + ( parallaxOffset * eyeVector.xy ); // displace texcoords according to viewer
// knowing the displacement, read RGB, Normal and Gloss
vec3 diffuseColor = texture2D( Material_DiffuseAndHeight, newTexCoords.st ).rgb;
vec4 temp = texture2D( Material_NormalAndGloss, newTexCoords.st );
// build a usable normal vector
normal.xy = temp.ag * 2.0 - 1.0; // swizzle alpha and green to x/y and scale to [-1..+1]
normal.z = sqrt( 1.0 - normal.x*normal.x - normal.y*normal.y ); // z = sqrt(1-x^2-y^2)
// move other properties to be better readable
float gloss = temp.r;
// float alpha = temp.b;
// if ( alpha < 0.2 ) // optimization: should move this test before reading RGB texture
// discard;
// tweaked phong lighting
float lambert = max( dot( lightVector, normal ), 0.0 );
gl_FragColor = vec4( Light_DiffuseColor * diffuseColor, 1.0 ) *
lambert;
if ( lambert > 0.0 )
{
float specular = pow(
clamp( dot( reflect( -lightVector, normal ), eyeVector ), 0.0, 1.0 ),
Material_ScaleBiasShininess.z );
gl_FragColor += vec4( Light_SpecularColor * diffuseColor, 1.0 ) * ( specular * gloss );
}
}

View file

@ -1,35 +0,0 @@
// Copyright (c) 2008 the OpenTK Team. See license.txt for legal bla
// custom vertex attribute
attribute vec3 AttributeTangent;
// world uniforms
uniform vec3 Light_Position;
uniform vec3 Camera_Position;
// MUST be written to for FS
varying vec3 VaryingLightVector;
varying vec3 VaryingEyeVector;
void main()
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec3 nor = normalize( gl_NormalMatrix * gl_Normal );
vec3 tan = normalize( gl_NormalMatrix * AttributeTangent );
vec3 bi = cross(nor, tan);
// need positions in tangent space
vec3 vertex = vec3( gl_ModelViewMatrix * gl_Vertex );
vec3 temp = Light_Position - vertex;
VaryingLightVector.x = dot(temp, tan); // optimization, calculate dot products rather than building TBN matrix
VaryingLightVector.y = dot(temp, bi);
VaryingLightVector.z = dot(temp, nor);
temp = Camera_Position - vertex;
VaryingEyeVector.x = dot(temp, tan);
VaryingEyeVector.y = dot(temp, bi);
VaryingEyeVector.z = dot(temp, nor);
}

View file

@ -1,8 +0,0 @@
#version 120
flat varying vec4 vColor;
void main(void)
{
gl_FragColor = vColor;
}

View file

@ -1,9 +0,0 @@
#version 120
flat varying vec4 vColor; // must be flat, cannot have this interpolated in any way
void main(void)
{
vColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; // ftransform();
}

View file

@ -1,5 +0,0 @@
/* Copies incoming fragment color without change. */
void main()
{
gl_FragColor = gl_Color;
}

View file

@ -1,8 +0,0 @@
/* Copies incoming vertex color without change.
* Applies the transformation matrix to vertex position.
*/
void main()
{
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

View file

@ -1,18 +0,0 @@
The files named "Swizzled *.dds" for the Parallax mapping demo originate from
http://www.TyphoonLabs.com ShaderDesigner application. Used with permission.
The Textures have been altered from the layout:
Diffuse R, Diffuse G, Diffuse B, Gloss
Normal X, Normal Y, Normal Z, Height
to
Diffuse R, Diffuse G, Diffuse B, Height
Gloss, Normal Y, Gloss, Normal X
Additionally, the Textures in this folder have been compressed with a lossy
algorithm (S3TC) and do not reflect the quality of the source Textures.
Please refer to the above website for unaltered versions of the textures,
or licensing information.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

View file

@ -1,90 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using OpenTK;
namespace Examples
{
class DependencyLoader : IDisposable
{
bool disposed;
readonly List<IntPtr> LoadedLibraries = new List<IntPtr>();
enum TargetCpu
{
x86,
x86_64,
}
static readonly TargetCpu Cpu = IntPtr.Size == 4 ? TargetCpu.x86 : TargetCpu.x86_64;
public void LoadDependencies()
{
string path = Path.Combine("Dependencies", Cpu == TargetCpu.x86 ? "x86" : "x64");
if (Directory.Exists(path))
{
if (Configuration.RunningOnWindows)
{
foreach (var file in Directory.GetFiles(path, "*.dll"))
{
IntPtr lib = NativeMethods.LoadLibrary(file);
if (lib == IntPtr.Zero)
{
Debug.Print("Failed to load dependency {0} with {1}", file,
Marshal.GetLastWin32Error());
}
else
{
LoadedLibraries.Add(lib);
Debug.Print("Loaded dependency {0}", file);
}
}
}
}
}
static class NativeMethods
{
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern IntPtr LoadLibrary(string dllName);
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern int FreeLibrary(IntPtr dll);
}
#region IDisposable Members
void Dispose(bool manual)
{
if (!disposed)
{
if (manual)
{
foreach (var lib in LoadedLibraries)
{
NativeMethods.FreeLibrary(lib);
}
}
disposed = true;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~DependencyLoader()
{
Dispose(false);
}
#endregion
}
}

View file

@ -1,59 +0,0 @@
#region --- License ---
/* Copyright (c) 2006-2008 the OpenTK team
* See license.txt for licensing details
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace Examples
{
[AttributeUsage(AttributeTargets.Class)]
public class ExampleAttribute : System.Attribute
{
string title;
bool visible = true;
public string Title { get { return title; } internal set { title = value; } }
public readonly ExampleCategory Category;
public readonly string Subcategory;
public int Difficulty;
public string Documentation;
public bool Visible { get { return visible; } set { visible = value; } }
public ExampleAttribute(string title, ExampleCategory category, string subcategory)
: this(title, category, subcategory, Int32.MaxValue, true) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty)
: this(title, category, subcategory, difficulty, true) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, bool visible)
: this(title, category, subcategory, Int32.MaxValue, visible) { }
public ExampleAttribute(string title, ExampleCategory category, string subcategory, int difficulty, bool visible)
{
this.Title = title;
this.Category = category;
this.Subcategory = subcategory;
this.Difficulty = difficulty;
this.Visible = visible;
}
public override string ToString()
{
if (Difficulty != 0)
return String.Format("{0} {1}: {2}", Category, Difficulty, Title);
return String.Format("{0}: {1}", Category, Title);
}
}
public enum ExampleCategory
{
OpenTK = 0,
OpenGL,
OpenAL,
OpenCL,
OpenGLES
}
}

View file

@ -1,321 +0,0 @@
namespace Examples
{
partial class ExampleBrowser
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.treeViewSamples = new System.Windows.Forms.TreeView();
this.contextMenuStripSamples = new System.Windows.Forms.ContextMenuStrip(this.components);
this.runSampleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.viewDescriptionToolStripMenuItem = 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.tabDescription = new System.Windows.Forms.TabPage();
this.richTextBoxDescription = new System.Windows.Forms.RichTextBox();
this.contextMenuStripDescription = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabSource = new System.Windows.Forms.TabPage();
this.richTextBoxSource = new System.Windows.Forms.RichTextBox();
this.contextMenuStripSource = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.tabPageOutput = new System.Windows.Forms.TabPage();
this.textBoxOutput = new System.Windows.Forms.TextBox();
this.contextMenuStripOutput = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolTipSamples = new System.Windows.Forms.ToolTip(this.components);
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.contextMenuStripSamples.SuspendLayout();
this.tabControlSample.SuspendLayout();
this.tabDescription.SuspendLayout();
this.contextMenuStripDescription.SuspendLayout();
this.tabSource.SuspendLayout();
this.contextMenuStripSource.SuspendLayout();
this.tabPageOutput.SuspendLayout();
this.contextMenuStripOutput.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.treeViewSamples);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tabControlSample);
this.splitContainer1.Size = new System.Drawing.Size(784, 564);
this.splitContainer1.SplitterDistance = 261;
this.splitContainer1.TabIndex = 0;
//
// treeViewSamples
//
this.treeViewSamples.ContextMenuStrip = this.contextMenuStripSamples;
this.treeViewSamples.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeViewSamples.FullRowSelect = true;
this.treeViewSamples.HideSelection = false;
this.treeViewSamples.HotTracking = true;
this.treeViewSamples.ImageIndex = 0;
this.treeViewSamples.ImageList = this.imageListSampleCategories;
this.treeViewSamples.Indent = 32;
this.treeViewSamples.Location = new System.Drawing.Point(0, 0);
this.treeViewSamples.Name = "treeViewSamples";
this.treeViewSamples.SelectedImageIndex = 0;
this.treeViewSamples.Size = new System.Drawing.Size(261, 564);
this.treeViewSamples.TabIndex = 0;
this.toolTipSamples.SetToolTip(this.treeViewSamples, "Right-click a sample for more options.");
this.treeViewSamples.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.treeViewSamples_AfterExpand);
this.treeViewSamples.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewSamples_AfterSelect);
this.treeViewSamples.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeViewSamples_NodeMouseDoubleClick);
this.treeViewSamples.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViewSamples_KeyDown);
this.treeViewSamples.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeViewSamples_MouseDown);
//
// contextMenuStripSamples
//
this.contextMenuStripSamples.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.runSampleToolStripMenuItem,
this.toolStripMenuItem1,
this.viewDescriptionToolStripMenuItem,
this.viewSourceToolStripMenuItem});
this.contextMenuStripSamples.Name = "contextMenuStripSamples";
this.contextMenuStripSamples.Size = new System.Drawing.Size(170, 76);
this.contextMenuStripSamples.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripSamples_ItemClicked);
//
// runSampleToolStripMenuItem
//
this.runSampleToolStripMenuItem.Name = "runSampleToolStripMenuItem";
this.runSampleToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
this.runSampleToolStripMenuItem.Text = "&Run Sample";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(166, 6);
//
// viewDescriptionToolStripMenuItem
//
this.viewDescriptionToolStripMenuItem.Name = "viewDescriptionToolStripMenuItem";
this.viewDescriptionToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
this.viewDescriptionToolStripMenuItem.Text = "View Description";
//
// viewSourceToolStripMenuItem
//
this.viewSourceToolStripMenuItem.Name = "viewSourceToolStripMenuItem";
this.viewSourceToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
this.viewSourceToolStripMenuItem.Text = "View Source Code";
//
// imageListSampleCategories
//
this.imageListSampleCategories.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.imageListSampleCategories.ImageSize = new System.Drawing.Size(35, 35);
this.imageListSampleCategories.TransparentColor = System.Drawing.Color.Transparent;
//
// tabControlSample
//
this.tabControlSample.Controls.Add(this.tabDescription);
this.tabControlSample.Controls.Add(this.tabSource);
this.tabControlSample.Controls.Add(this.tabPageOutput);
this.tabControlSample.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControlSample.Location = new System.Drawing.Point(0, 0);
this.tabControlSample.Name = "tabControlSample";
this.tabControlSample.SelectedIndex = 0;
this.tabControlSample.Size = new System.Drawing.Size(519, 564);
this.tabControlSample.TabIndex = 0;
//
// tabDescription
//
this.tabDescription.Controls.Add(this.richTextBoxDescription);
this.tabDescription.Location = new System.Drawing.Point(4, 22);
this.tabDescription.Name = "tabDescription";
this.tabDescription.Padding = new System.Windows.Forms.Padding(3);
this.tabDescription.Size = new System.Drawing.Size(511, 538);
this.tabDescription.TabIndex = 0;
this.tabDescription.Text = "Description";
this.tabDescription.UseVisualStyleBackColor = true;
//
// richTextBoxDescription
//
this.richTextBoxDescription.ContextMenuStrip = this.contextMenuStripDescription;
this.richTextBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBoxDescription.Location = new System.Drawing.Point(3, 3);
this.richTextBoxDescription.Name = "richTextBoxDescription";
this.richTextBoxDescription.ReadOnly = true;
this.richTextBoxDescription.Size = new System.Drawing.Size(505, 532);
this.richTextBoxDescription.TabIndex = 0;
this.richTextBoxDescription.Text = "";
this.richTextBoxDescription.MouseDown += new System.Windows.Forms.MouseEventHandler(this.richTextBoxDescription_MouseDown);
//
// contextMenuStripDescription
//
this.contextMenuStripDescription.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem});
this.contextMenuStripDescription.Name = "contextMenuStripDescription";
this.contextMenuStripDescription.Size = new System.Drawing.Size(103, 26);
this.contextMenuStripDescription.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripDescription_ItemClicked);
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(102, 22);
this.copyToolStripMenuItem.Text = "&Copy";
//
// tabSource
//
this.tabSource.Controls.Add(this.richTextBoxSource);
this.tabSource.Location = new System.Drawing.Point(4, 22);
this.tabSource.Name = "tabSource";
this.tabSource.Padding = new System.Windows.Forms.Padding(3);
this.tabSource.Size = new System.Drawing.Size(511, 538);
this.tabSource.TabIndex = 1;
this.tabSource.Text = "Source Code";
this.tabSource.UseVisualStyleBackColor = true;
//
// richTextBoxSource
//
this.richTextBoxSource.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(242)))), ((int)(((byte)(240)))));
this.richTextBoxSource.ContextMenuStrip = this.contextMenuStripSource;
this.richTextBoxSource.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBoxSource.Location = new System.Drawing.Point(3, 3);
this.richTextBoxSource.Name = "richTextBoxSource";
this.richTextBoxSource.ReadOnly = true;
this.richTextBoxSource.Size = new System.Drawing.Size(505, 532);
this.richTextBoxSource.TabIndex = 0;
this.richTextBoxSource.Text = "";
this.richTextBoxSource.MouseDown += new System.Windows.Forms.MouseEventHandler(this.richTextBoxSource_MouseDown);
//
// contextMenuStripSource
//
this.contextMenuStripSource.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem1});
this.contextMenuStripSource.Name = "contextMenuStripSource";
this.contextMenuStripSource.Size = new System.Drawing.Size(103, 26);
this.contextMenuStripSource.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripSource_ItemClicked);
//
// copyToolStripMenuItem1
//
this.copyToolStripMenuItem1.Name = "copyToolStripMenuItem1";
this.copyToolStripMenuItem1.Size = new System.Drawing.Size(102, 22);
this.copyToolStripMenuItem1.Text = "&Copy";
//
// tabPageOutput
//
this.tabPageOutput.Controls.Add(this.textBoxOutput);
this.tabPageOutput.Location = new System.Drawing.Point(4, 22);
this.tabPageOutput.Name = "tabPageOutput";
this.tabPageOutput.Padding = new System.Windows.Forms.Padding(3);
this.tabPageOutput.Size = new System.Drawing.Size(511, 538);
this.tabPageOutput.TabIndex = 2;
this.tabPageOutput.Text = "Output";
this.tabPageOutput.UseVisualStyleBackColor = true;
//
// textBoxOutput
//
this.textBoxOutput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(242)))), ((int)(((byte)(240)))));
this.textBoxOutput.ContextMenuStrip = this.contextMenuStripOutput;
this.textBoxOutput.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBoxOutput.Location = new System.Drawing.Point(3, 3);
this.textBoxOutput.MaxLength = 1048576;
this.textBoxOutput.Multiline = true;
this.textBoxOutput.Name = "textBoxOutput";
this.textBoxOutput.ReadOnly = true;
this.textBoxOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBoxOutput.Size = new System.Drawing.Size(505, 532);
this.textBoxOutput.TabIndex = 0;
//
// contextMenuStripOutput
//
this.contextMenuStripOutput.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem2});
this.contextMenuStripOutput.Name = "contextMenuStripOutput";
this.contextMenuStripOutput.Size = new System.Drawing.Size(103, 26);
//
// copyToolStripMenuItem2
//
this.copyToolStripMenuItem2.Name = "copyToolStripMenuItem2";
this.copyToolStripMenuItem2.Size = new System.Drawing.Size(102, 22);
this.copyToolStripMenuItem2.Text = "&Copy";
//
// ExampleBrowser
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 564);
this.Controls.Add(this.splitContainer1);
this.Name = "ExampleBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "The Open Toolkit Sample Browser";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.contextMenuStripSamples.ResumeLayout(false);
this.tabControlSample.ResumeLayout(false);
this.tabDescription.ResumeLayout(false);
this.contextMenuStripDescription.ResumeLayout(false);
this.tabSource.ResumeLayout(false);
this.contextMenuStripSource.ResumeLayout(false);
this.tabPageOutput.ResumeLayout(false);
this.tabPageOutput.PerformLayout();
this.contextMenuStripOutput.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TabControl tabControlSample;
private System.Windows.Forms.TabPage tabDescription;
private System.Windows.Forms.TabPage tabSource;
private System.Windows.Forms.RichTextBox richTextBoxDescription;
private System.Windows.Forms.RichTextBox richTextBoxSource;
private System.Windows.Forms.TreeView treeViewSamples;
private System.Windows.Forms.ImageList imageListSampleCategories;
private System.Windows.Forms.ContextMenuStrip contextMenuStripDescription;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStripSource;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem1;
private System.Windows.Forms.ContextMenuStrip contextMenuStripSamples;
private System.Windows.Forms.ToolStripMenuItem runSampleToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem viewDescriptionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem viewSourceToolStripMenuItem;
private System.Windows.Forms.ToolTip toolTipSamples;
private System.Windows.Forms.TabPage tabPageOutput;
private System.Windows.Forms.TextBox textBoxOutput;
private System.Windows.Forms.ContextMenuStrip contextMenuStripOutput;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem2;
}
}

View file

@ -1,447 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2009 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.Reflection;
using System.Windows.Forms;
using OpenTK.Examples.Properties;
using System.Threading;
using System.IO;
namespace Examples
{
public partial class ExampleBrowser : Form
{
#region Fields
//PrivateFontCollection font_collection = new PrivateFontCollection();
bool show_warning = true;
readonly string SourcePath;
#endregion
#region Constructors
public ExampleBrowser()
{
SourcePath =
FindSourcePath(Directory.GetCurrentDirectory()) ??
FindSourcePath(Assembly.GetExecutingAssembly().Location);
Font = SystemFonts.DialogFont;
InitializeComponent();
Icon = Resources.App;
// Windows 6 (Vista) and higher come with Consolas, a high-quality monospace font. Use that or fallback to
// the generic monospace font on other systems.
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT &&
System.Environment.OSVersion.Version.Major >= 6)
{
textBoxOutput.Font = richTextBoxSource.Font = new Font("Consolas", 10.0f, FontStyle.Regular);
}
else
{
textBoxOutput.Font = richTextBoxSource.Font =
new Font(FontFamily.GenericMonospace, 10.0f, FontStyle.Regular);
}
}
#endregion
#region Protected Members
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Add those by hand, because using the designer results in an empty
// image list when cross-compiling on Mono.
imageListSampleCategories.Images.Add("OpenAL", Resources.OpenAL);
imageListSampleCategories.Images.Add("OpenGL", Resources.OpenGL);
imageListSampleCategories.Images.Add("OpenGLES", Resources.OpenGLES);
imageListSampleCategories.Images.Add("OpenCL", Resources.OpenCL);
imageListSampleCategories.Images.Add("OpenTK", Resources.OpenTK);
imageListSampleCategories.Images.Add("1.x", Resources.v1x);
imageListSampleCategories.Images.Add("2.x", Resources.v2x);
imageListSampleCategories.Images.Add("3.x", Resources.v3x);
imageListSampleCategories.Images.Add("4.x", Resources.v4x);
treeViewSamples.TreeViewNodeSorter = new SamplesTreeViewSorter();
LoadSamplesFromAssembly(Assembly.GetExecutingAssembly());
}
protected override void OnShown(EventArgs e)
{
if (show_warning)
{
//MessageBox.Show("The new Sample Browser is not complete. Please report any issues at http://www.opentk.com/project/issues.",
// "Work in Progress", MessageBoxButtons.OK, MessageBoxIcon.Information);
show_warning = false;
}
}
#endregion
#region Private Members
#region Events
#region TreeView
private void treeViewSamples_AfterSelect(object sender, TreeViewEventArgs e)
{
const string no_docs = "Documentation has not been entered.";
const string no_source = "Source code has not been entered.";
if (SourcePath != null && e.Node.Tag != null &&
!String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation))
{
string docs = null;
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))
richTextBoxDescription.Text = String.Format("File {0} not found.", sample_rtf);
else
richTextBoxDescription.Rtf = docs;
if (String.IsNullOrEmpty(source))
richTextBoxSource.Text = String.Format("File {0} not found.", sample_cs);
else
richTextBoxSource.Text = source;
}
else
{
richTextBoxDescription.Text = no_docs;
richTextBoxSource.Text = no_source;
}
}
private void treeViewSamples_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Tag != null)
{
ActivateNode(e.Node);
}
}
private void treeViewSamples_KeyDown(object sender, KeyEventArgs e)
{
// The enter key activates a node (either expands/collapses or executes its sample).
switch (e.KeyCode)
{
case Keys.Enter:
ActivateNode(treeViewSamples.SelectedNode);
e.Handled = true;
e.SuppressKeyPress = true;
break;
}
}
private void treeViewSamples_MouseDown(object sender, MouseEventArgs e)
{
// Make sure that right-clicking a new node will select that node before displaying
// the context menu. Without this, right-clicking a node does not select it, which
// is completely disorienting.
// As a bonus, make any mouse button select the underlying node,
TreeNode node = treeViewSamples.HitTest(e.Location).Node;
if (node != null)
treeViewSamples.SelectedNode = node;
// Middle click selects and activates a node (either expands/collapses or executes its sample).
// Right button displays the context menu.
// All other mouse buttons simply select the underlying node.
switch (e.Button)
{
case MouseButtons.Middle:
ActivateNode(node);
break;
case MouseButtons.Right:
treeViewSamples.ContextMenuStrip.Show(sender as Control, e.Location);
break;
}
}
private void treeViewSamples_AfterExpand(object sender, TreeViewEventArgs e)
{
foreach (TreeNode child in e.Node.Nodes)
child.EnsureVisible();
}
private void contextMenuStripSamples_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
switch (e.ClickedItem.Text)
{
case "&Run Sample": RunSample(this, (ExampleInfo)treeViewSamples.SelectedNode.Tag); break;
case "View Description": tabControlSample.SelectedTab = tabDescription; break;
case "View Source Code": tabControlSample.SelectedTab = tabSource; break;
}
}
#endregion
#region Description
private void richTextBoxDescription_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
richTextBoxDescription.ContextMenuStrip.Show(sender as Control, e.X, e.Y);
}
}
private void contextMenuStripDescription_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.Text == "&Copy")
{
Clipboard.SetText(richTextBoxDescription.SelectedRtf, TextDataFormat.Rtf);
}
}
#endregion
#region Source Code
private void richTextBoxSource_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
richTextBoxSource.ContextMenuStrip.Show(sender as Control, e.X, e.Y);
}
}
private void contextMenuStripSource_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.Text == "&Copy")
{
Clipboard.SetText(richTextBoxSource.SelectedText, TextDataFormat.Text);
}
}
#endregion
#endregion
#region Actions
void LoadSamplesFromAssembly(Assembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
object[] attributes = type.GetCustomAttributes(false);
ExampleAttribute example = null;
foreach (object attr in attributes)
{
if (attr is ExampleAttribute)
{
example = (ExampleAttribute)attr;
if (example.Visible)
{
// Add this example to the sample TreeView.
// First check whether the ExampleCategory exists in the tree (and add it if it doesn't).
// Then add the example as a child node on this category.
if (!treeViewSamples.Nodes.ContainsKey(example.Category.ToString()))
{
int category_index = GetImageIndexForSample(imageListSampleCategories, example.Category.ToString(), String.Empty);
treeViewSamples.Nodes.Add(example.Category.ToString(), String.Format("{0} samples", example.Category),
category_index, category_index);
}
int image_index = GetImageIndexForSample(imageListSampleCategories, example.Category.ToString(), example.Subcategory);
TreeNode node = new TreeNode(example.Title, image_index, image_index);
node.Name = example.Title;
node.Tag = new ExampleInfo(type, example);
treeViewSamples.Nodes[example.Category.ToString()].Nodes.Add(node);
}
}
}
}
treeViewSamples.Sort();
}
void ActivateNode(TreeNode node)
{
if (node == null)
return;
if (node.Tag == null)
{
if (node.IsExpanded)
node.Collapse();
else
node.Expand();
}
else
{
tabControlSample.SelectedTab = tabPageOutput;
textBoxOutput.Clear();
RunSample(node.TreeView.TopLevelControl, (ExampleInfo)node.Tag);
}
}
static int GetImageIndexForSample(ImageList list, string category, string subcategory)
{
if (list == null)
throw new ArgumentNullException("list");
foreach (string extension in new string[] { "", ".png", ".jpg" })
{
string name = subcategory.ToString() + extension;
if (list.Images.ContainsKey(name))
return list.Images.IndexOfKey(name);
name = category.ToString() + extension;
if (list.Images.ContainsKey(name))
return list.Images.IndexOfKey(name);
}
return -1;
}
void RunSample(Control parent, ExampleInfo e)
{
if (e == null)
return;
try
{
if (parent != null)
{
parent.Visible = false;
Application.DoEvents();
}
Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title));
Trace.WriteLine(String.Empty);
var info = new ProcessStartInfo
{
FileName = Application.ExecutablePath,//.Replace("vshost.exe", String.Empty),
Arguments = e.Example.ToString()
};
var process = Process.Start(info);
process.WaitForExit();
}
finally
{
if (parent != null)
{
try
{
textBoxOutput.Text = File.ReadAllText("debug.log");
}
catch (Exception ex)
{
Debug.Print(ex.ToString());
}
parent.Visible = true;
parent.Focus();
Application.DoEvents();
}
}
}
// Tries to detect the path that contains the source for the examples.
static string FindSourcePath(string guess)
{
guess = Path.GetDirectoryName(guess);
// Typically, our working directory is either "[opentk]/Binaries/OpenTK/[config]" or "[opentk]".
// The desired source path is "[opentk]/Source/Examples/[ExampleCategory]"
if (CheckPath(ref guess))
return guess; // We were in [opentk] after all
for (int i = 0; i < 3; i++)
{
DirectoryInfo dir = Directory.GetParent(guess);
if (dir == null || !dir.Exists)
break;
guess = dir.FullName;
}
if (CheckPath(ref guess))
return guess; // We were in [opentk]/Binaries/OpenTK/[config] after all
return null;
}
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
}
}

View file

@ -1,138 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStripSamples.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>616, 17</value>
</metadata>
<metadata name="imageListSampleCategories.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTipSamples.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>810, 17</value>
</metadata>
<metadata name="contextMenuStripDescription.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>219, 17</value>
</metadata>
<metadata name="contextMenuStripSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>430, 17</value>
</metadata>
<metadata name="contextMenuStripOutput.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>945, 17</value>
</metadata>
</root>

View file

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Examples
{
/// <summary>
/// Contains the information necessary to display and launch an example thorugh the ExampleLauncer.
/// </summary>
class ExampleInfo
{
public readonly Type Example;
public readonly ExampleAttribute Attribute;
public ExampleInfo(Type example, ExampleAttribute attr)
{
Example = example;
Attribute = attr;
}
public override string ToString()
{
return Attribute.ToString();
}
}
}

View file

@ -1,23 +0,0 @@
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing details.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace Examples
{
/// <summary>
/// This interface is is used by the ExampleLauncher to identify OpenTK examples,
/// your applications do not need to implement or use it.
/// </summary>
interface IExample
{
void Launch();
}
}

View file

@ -1,128 +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.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using OpenTK;
namespace Examples
{
static class Program
{
static void LaunchExample(string type)
{
try
{
if (File.Exists("debug.log"))
File.Delete("debug.log");
if (File.Exists("trace.log"))
File.Delete("trace.log");
}
catch (Exception e)
{
Trace.WriteLine(String.Format("Could not access debug.log", e.ToString()));
}
ToolkitOptions options = ToolkitOptions.Default;
if (type.Contains("GLControl") || type.Contains("Form"))
{
// SDL does not currently support embedding in foreign windows
// such as GLControl. We need to use a native OpenTK.Platform
// backend in that case. This hack is specific to the example-browser
// architecture - you do not need to do anything like this in your
// own code (it will just work).
options = new ToolkitOptions
{
Backend = PlatformBackend.PreferNative
};
}
using (TextWriterTraceListener dbg = new TextWriterTraceListener("debug.log"))
using (Toolkit.Init(options))
{
Trace.Listeners.Add(dbg);
try
{
var example = Type.GetType(type);
if (example != null)
{
example.InvokeMember("Main",
BindingFlags.InvokeMethod | BindingFlags.Static |
BindingFlags.Public | BindingFlags.NonPublic,
null, null, null);
}
}
catch (Exception e)
{
Trace.WriteLine(String.Format("Exception occured in example {0}: {1}",
type, e.ToString()));
}
Trace.Listeners.Remove(dbg);
dbg.Flush();
dbg.Close();
}
}
[STAThread]
public static void Main(string[] args)
{
if (args.Length > 0)
{
LaunchExample(args[0]);
}
else
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (Form browser = new ExampleBrowser())
{
Application.Run(browser);
}
}
catch (System.Security.SecurityException e)
{
MessageBox.Show("The Example Launcher failed to start, due to insufficient permissions. This may happen if you execute the application from a network share.", "OpenTK Example Launcher failed to start.",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Trace.WriteLine(e.ToString());
}
}
}
}
}

View file

@ -1,283 +0,0 @@
namespace Examples
{
partial class Parrot
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.comboBox_RecorderSelection = new System.Windows.Forms.ComboBox();
this.groupBox_RecorderParameters = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.numericUpDown_PlaybackGain = new System.Windows.Forms.NumericUpDown();
this.label_MONO16BIT = new System.Windows.Forms.Label();
this.label_RINGBUFFER = new System.Windows.Forms.Label();
this.label_FREQUENCY = new System.Windows.Forms.Label();
this.numericUpDown_BufferLength = new System.Windows.Forms.NumericUpDown();
this.numericUpDown_Frequency = new System.Windows.Forms.NumericUpDown();
this.groupBox_RecordingControls = new System.Windows.Forms.GroupBox();
this.label_SamplesConsumed = new System.Windows.Forms.Label();
this.button_Start = new System.Windows.Forms.Button();
this.timer_GetSamples = new System.Windows.Forms.Timer(this.components);
this.groupBox_RecorderParameters.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_PlaybackGain)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_BufferLength)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_Frequency)).BeginInit();
this.groupBox_RecordingControls.SuspendLayout();
this.SuspendLayout();
//
// comboBox_RecorderSelection
//
this.comboBox_RecorderSelection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBox_RecorderSelection.FormattingEnabled = true;
this.comboBox_RecorderSelection.Location = new System.Drawing.Point(6, 19);
this.comboBox_RecorderSelection.Name = "comboBox_RecorderSelection";
this.comboBox_RecorderSelection.Size = new System.Drawing.Size(216, 21);
this.comboBox_RecorderSelection.TabIndex = 0;
//
// groupBox_RecorderParameters
//
this.groupBox_RecorderParameters.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox_RecorderParameters.Controls.Add(this.label2);
this.groupBox_RecorderParameters.Controls.Add(this.label1);
this.groupBox_RecorderParameters.Controls.Add(this.numericUpDown_PlaybackGain);
this.groupBox_RecorderParameters.Controls.Add(this.label_MONO16BIT);
this.groupBox_RecorderParameters.Controls.Add(this.label_RINGBUFFER);
this.groupBox_RecorderParameters.Controls.Add(this.label_FREQUENCY);
this.groupBox_RecorderParameters.Controls.Add(this.numericUpDown_BufferLength);
this.groupBox_RecorderParameters.Controls.Add(this.numericUpDown_Frequency);
this.groupBox_RecorderParameters.Controls.Add(this.comboBox_RecorderSelection);
this.groupBox_RecorderParameters.Location = new System.Drawing.Point(12, 12);
this.groupBox_RecorderParameters.Name = "groupBox_RecorderParameters";
this.groupBox_RecorderParameters.Size = new System.Drawing.Size(228, 168);
this.groupBox_RecorderParameters.TabIndex = 2;
this.groupBox_RecorderParameters.TabStop = false;
this.groupBox_RecorderParameters.Text = "Recording Device Setup";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 132);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(74, 13);
this.label2.TabIndex = 105;
this.label2.Text = "Sample format";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 102);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(96, 13);
this.label1.TabIndex = 104;
this.label1.Text = "Playback gain (dB)";
//
// numericUpDown_PlaybackGain
//
this.numericUpDown_PlaybackGain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown_PlaybackGain.Location = new System.Drawing.Point(145, 100);
this.numericUpDown_PlaybackGain.Maximum = new decimal(new int[] {
64,
0,
0,
0});
this.numericUpDown_PlaybackGain.Minimum = new decimal(new int[] {
1,
0,
0,
65536});
this.numericUpDown_PlaybackGain.Name = "numericUpDown_PlaybackGain";
this.numericUpDown_PlaybackGain.Size = new System.Drawing.Size(76, 20);
this.numericUpDown_PlaybackGain.TabIndex = 103;
this.numericUpDown_PlaybackGain.ThousandsSeparator = true;
this.numericUpDown_PlaybackGain.Value = new decimal(new int[] {
4,
0,
0,
0});
//
// label_MONO16BIT
//
this.label_MONO16BIT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label_MONO16BIT.AutoSize = true;
this.label_MONO16BIT.Location = new System.Drawing.Point(142, 132);
this.label_MONO16BIT.Name = "label_MONO16BIT";
this.label_MONO16BIT.Size = new System.Drawing.Size(64, 13);
this.label_MONO16BIT.TabIndex = 102;
this.label_MONO16BIT.Text = "Mono 16-bit";
//
// label_RINGBUFFER
//
this.label_RINGBUFFER.AutoSize = true;
this.label_RINGBUFFER.Location = new System.Drawing.Point(6, 76);
this.label_RINGBUFFER.Name = "label_RINGBUFFER";
this.label_RINGBUFFER.Size = new System.Drawing.Size(89, 13);
this.label_RINGBUFFER.TabIndex = 101;
this.label_RINGBUFFER.Text = "Buffer length (ms)";
//
// label_FREQUENCY
//
this.label_FREQUENCY.AutoSize = true;
this.label_FREQUENCY.Location = new System.Drawing.Point(6, 50);
this.label_FREQUENCY.Name = "label_FREQUENCY";
this.label_FREQUENCY.Size = new System.Drawing.Size(85, 13);
this.label_FREQUENCY.TabIndex = 100;
this.label_FREQUENCY.Text = "Sample rate (Hz)";
//
// numericUpDown_BufferLength
//
this.numericUpDown_BufferLength.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown_BufferLength.Location = new System.Drawing.Point(145, 74);
this.numericUpDown_BufferLength.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDown_BufferLength.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown_BufferLength.Name = "numericUpDown_BufferLength";
this.numericUpDown_BufferLength.Size = new System.Drawing.Size(76, 20);
this.numericUpDown_BufferLength.TabIndex = 2;
this.numericUpDown_BufferLength.ThousandsSeparator = true;
this.numericUpDown_BufferLength.Value = new decimal(new int[] {
50,
0,
0,
0});
//
// numericUpDown_Frequency
//
this.numericUpDown_Frequency.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown_Frequency.Location = new System.Drawing.Point(145, 48);
this.numericUpDown_Frequency.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numericUpDown_Frequency.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown_Frequency.Name = "numericUpDown_Frequency";
this.numericUpDown_Frequency.Size = new System.Drawing.Size(76, 20);
this.numericUpDown_Frequency.TabIndex = 1;
this.numericUpDown_Frequency.ThousandsSeparator = true;
this.numericUpDown_Frequency.Value = new decimal(new int[] {
16000,
0,
0,
0});
//
// groupBox_RecordingControls
//
this.groupBox_RecordingControls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox_RecordingControls.Controls.Add(this.label_SamplesConsumed);
this.groupBox_RecordingControls.Controls.Add(this.button_Start);
this.groupBox_RecordingControls.Location = new System.Drawing.Point(12, 186);
this.groupBox_RecordingControls.Name = "groupBox_RecordingControls";
this.groupBox_RecordingControls.Size = new System.Drawing.Size(228, 78);
this.groupBox_RecordingControls.TabIndex = 3;
this.groupBox_RecordingControls.TabStop = false;
this.groupBox_RecordingControls.Text = "Talk to the parrot";
//
// label_SamplesConsumed
//
this.label_SamplesConsumed.AutoSize = true;
this.label_SamplesConsumed.Location = new System.Drawing.Point(6, 52);
this.label_SamplesConsumed.Name = "label_SamplesConsumed";
this.label_SamplesConsumed.Size = new System.Drawing.Size(108, 13);
this.label_SamplesConsumed.TabIndex = 103;
this.label_SamplesConsumed.Text = "Samples consumed: -";
//
// button_Start
//
this.button_Start.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button_Start.Location = new System.Drawing.Point(35, 19);
this.button_Start.Name = "button_Start";
this.button_Start.Size = new System.Drawing.Size(159, 24);
this.button_Start.TabIndex = 3;
this.button_Start.Text = "Start recording";
this.button_Start.UseVisualStyleBackColor = true;
this.button_Start.Click += new System.EventHandler(this.button_Start_Click);
//
// timer_GetSamples
//
this.timer_GetSamples.Tick += new System.EventHandler(this.timer_UpdateSamples_Tick);
//
// Parrot
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(252, 276);
this.Controls.Add(this.groupBox_RecordingControls);
this.Controls.Add(this.groupBox_RecorderParameters);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "Parrot";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "OpenAL Parrot";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Parrot_FormClosing);
this.groupBox_RecorderParameters.ResumeLayout(false);
this.groupBox_RecorderParameters.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_PlaybackGain)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_BufferLength)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_Frequency)).EndInit();
this.groupBox_RecordingControls.ResumeLayout(false);
this.groupBox_RecordingControls.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox comboBox_RecorderSelection;
private System.Windows.Forms.GroupBox groupBox_RecorderParameters;
private System.Windows.Forms.Label label_RINGBUFFER;
private System.Windows.Forms.Label label_FREQUENCY;
private System.Windows.Forms.NumericUpDown numericUpDown_BufferLength;
private System.Windows.Forms.NumericUpDown numericUpDown_Frequency;
private System.Windows.Forms.GroupBox groupBox_RecordingControls;
private System.Windows.Forms.Label label_SamplesConsumed;
private System.Windows.Forms.Button button_Start;
private System.Windows.Forms.Label label_MONO16BIT;
private System.Windows.Forms.Timer timer_GetSamples;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown numericUpDown_PlaybackGain;
private System.Windows.Forms.Label label2;
}
}

View file

@ -1,239 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2009 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
using OpenTK;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
namespace Examples
{
[Example("Parrot Audio Capture", ExampleCategory.OpenAL, "1.1", Documentation = "Parrot")]
public partial class Parrot : Form
{
#region Fields
AudioContext audio_context;
AudioCapture audio_capture;
int src;
short[] buffer = new short[512];
const byte SampleToByte = 2;
#endregion
#region Constructors
public Parrot()
{
InitializeComponent();
this.Text = "OpenAL Parrot (" + (IntPtr.Size == 4 ? "x86" : "x64") + ")";
// Add available capture devices to the combo box.
IList<string> recorders = AudioCapture.AvailableDevices;
for (int i = 0; i < recorders.Count; i++)
{
if (!String.IsNullOrEmpty(recorders[i]))
comboBox_RecorderSelection.Items.Add(recorders[i]);
}
if (comboBox_RecorderSelection.Items.Count > 0)
comboBox_RecorderSelection.SelectedIndex = 0;
}
#endregion
#region Events
private void button_Start_Click(object sender, EventArgs e)
{
if (audio_capture == null || !audio_capture.IsRunning)
{
button_Start.Text = "Stop Recording";
groupBox_RecorderParameters.Enabled = false;
this.StartRecording();
}
else
{
button_Start.Text = "Start Recording";
groupBox_RecorderParameters.Enabled = true;
this.StopRecording();
}
}
private void timer_UpdateSamples_Tick(object sender, EventArgs e)
{
this.UpdateSamples();
}
private void Parrot_FormClosing(object sender, FormClosingEventArgs e)
{
this.StopRecording();
}
#endregion
#region Private Members
void StartRecording()
{
try
{
audio_context = new AudioContext();
}
catch (AudioException ae)
{
MessageBox.Show("Fatal: Cannot continue without a playback device.\nException caught when opening playback device.\n" + ae.Message);
Application.Exit();
}
AL.Listener(ALListenerf.Gain, (float)numericUpDown_PlaybackGain.Value);
src = AL.GenSource();
int sampling_rate = (int)numericUpDown_Frequency.Value;
double buffer_length_ms = (double)numericUpDown_BufferLength.Value;
int buffer_length_samples = (int)((double)numericUpDown_BufferLength.Value * sampling_rate * 0.001 / BlittableValueType.StrideOf(buffer));
try
{
audio_capture = new AudioCapture((string)comboBox_RecorderSelection.SelectedItem,
sampling_rate, ALFormat.Mono16, buffer_length_samples);
}
catch (AudioDeviceException ade)
{
MessageBox.Show("Exception caught when opening recording device.\n" + ade.Message);
audio_capture = null;
}
if (audio_capture == null)
return;
audio_capture.Start();
timer_GetSamples.Start();
timer_GetSamples.Interval = (int)(buffer_length_ms / 2 + 0.5); // Tick when half the buffer is full.
}
void StopRecording()
{
timer_GetSamples.Stop();
if (audio_capture != null)
{
audio_capture.Stop();
audio_capture.Dispose();
audio_capture = null;
}
if (audio_context != null)
{
int r;
AL.GetSource(src, ALGetSourcei.BuffersQueued, out r);
ClearBuffers(r);
AL.DeleteSource(src);
audio_context.Dispose();
audio_context = null;
}
}
void UpdateSamples()
{
if (audio_capture == null)
return;
int available_samples = audio_capture.AvailableSamples;
if (available_samples * SampleToByte > buffer.Length * BlittableValueType.StrideOf(buffer))
{
buffer = new short[MathHelper.NextPowerOfTwo(
(int)(available_samples * SampleToByte / (double)BlittableValueType.StrideOf(buffer) + 0.5))];
}
if (available_samples > 0)
{
audio_capture.ReadSamples(buffer, available_samples);
int buf = AL.GenBuffer();
AL.BufferData(buf, ALFormat.Mono16, buffer, (int)(available_samples * BlittableValueType.StrideOf(buffer)), audio_capture.SampleFrequency);
AL.SourceQueueBuffer(src, buf);
label_SamplesConsumed.Text = "Samples consumed: " + available_samples;
if (AL.GetSourceState(src) != ALSourceState.Playing)
AL.SourcePlay(src);
}
ClearBuffers(0);
}
void ClearBuffers(int input)
{
if (audio_context == null || audio_context == null)
return;
int[] freedbuffers;
if (input == 0)
{
int BuffersProcessed;
AL.GetSource(src, ALGetSourcei.BuffersProcessed, out BuffersProcessed);
if (BuffersProcessed == 0)
return;
freedbuffers = AL.SourceUnqueueBuffers(src, BuffersProcessed);
}
else
{
freedbuffers = AL.SourceUnqueueBuffers(src, input);
}
AL.DeleteBuffers(freedbuffers);
}
#endregion
#region Main
[STAThread]
static void Main()
{
using (Parrot parrot = new Parrot())
{
parrot.ShowDialog();
}
}
#endregion
}
}

View file

@ -1,132 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="label_RINGBUFFER.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label_SamplesConsumed.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label_SamplesConsumed.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="timer_GetSamples.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -1,83 +0,0 @@
/*
* 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 disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Threading;
using OpenTK.Audio;
namespace Examples
{
#if false
[Example("PlayStatic Sample", ExampleCategory.OpenAL)]
public partial class PlayStatic
{
public static void Main()
{
AudioContext context = new AudioContext();
Sound sound = new Sound("Data\\Audio\\Asterisk.wav");
uint buffer;
uint source;
int state;
Trace.WriteLine("PlayStatic Test Application\n");
// Generate an AL Buffer
AL.GenBuffers(out buffer);
// Load Wave file into OpenAL Buffer
AL.BufferData(buffer, sound.ReadToEnd());
// Generate a Source to playback the Buffer
AL.GenSources(out source);
// Attach Source to Buffer
AL.Source(source, ALSourcei.Buffer, (int)buffer);
// Play Source
AL.SourcePlay(source);
Trace.WriteLine("Playing Source ");
do
{
Thread.Sleep(100);
Trace.Write(".");
// Get Source State
AL.GetSource(source, ALGetSourcei.SourceState, out state);
} while ((ALSourceState)state == ALSourceState.Playing);
Trace.WriteLine();
// Clean up by deleting Source(s) and Buffer(s)
AL.SourceStop(source);
AL.DeleteSources(ref source);
AL.DeleteBuffers(ref buffer);
return;
}
}
#endif
}

View file

@ -1,112 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Threading;
using System.IO;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
#pragma warning disable 219 // variable assigned but never used, we do that on purpose
namespace Examples
{
[Example("Playback", ExampleCategory.OpenAL, "1.1", Documentation="Playback")]
public class Playback
{
static readonly string filename = Path.Combine(Path.Combine("Data", "Audio"), "the_ring_that_fell.wav");
// Loads a wave/riff audio file.
public static byte[] LoadWave(Stream stream, out int channels, out int bits, out int rate)
{
if (stream == null)
throw new ArgumentNullException("stream");
using (BinaryReader reader = new BinaryReader(stream))
{
// RIFF header
string signature = new string(reader.ReadChars(4));
if (signature != "RIFF")
throw new NotSupportedException("Specified stream is not a wave file.");
int riff_chunck_size = reader.ReadInt32();
string format = new string(reader.ReadChars(4));
if (format != "WAVE")
throw new NotSupportedException("Specified stream is not a wave file.");
// WAVE header
string format_signature = new string(reader.ReadChars(4));
if (format_signature != "fmt ")
throw new NotSupportedException("Specified wave file is not supported.");
int format_chunk_size = reader.ReadInt32();
int audio_format = reader.ReadInt16();
int num_channels = reader.ReadInt16();
int sample_rate = reader.ReadInt32();
int byte_rate = reader.ReadInt32();
int block_align = reader.ReadInt16();
int bits_per_sample = reader.ReadInt16();
string data_signature = new string(reader.ReadChars(4));
if (data_signature != "data")
throw new NotSupportedException("Specified wave file is not supported.");
int data_chunk_size = reader.ReadInt32();
channels = num_channels;
bits = bits_per_sample;
rate = sample_rate;
return reader.ReadBytes((int)reader.BaseStream.Length);
}
}
public static ALFormat GetSoundFormat(int channels, int bits)
{
switch (channels)
{
case 1: return bits == 8 ? ALFormat.Mono8 : ALFormat.Mono16;
case 2: return bits == 8 ? ALFormat.Stereo8 : ALFormat.Stereo16;
default: throw new NotSupportedException("The specified sound format is not supported.");
}
}
public static void Main()
{
using (AudioContext context = new AudioContext())
{
int buffer = AL.GenBuffer();
int source = AL.GenSource();
int state;
int channels, bits_per_sample, sample_rate;
byte[] sound_data = LoadWave(File.Open(filename, FileMode.Open), out channels, out bits_per_sample, out sample_rate);
AL.BufferData(buffer, GetSoundFormat(channels, bits_per_sample), sound_data, sound_data.Length, sample_rate);
AL.Source(source, ALSourcei.Buffer, buffer);
AL.SourcePlay(source);
Trace.Write("Playing");
// Query the source to find out when it stops playing.
do
{
Thread.Sleep(250);
Trace.Write(".");
AL.GetSource(source, ALGetSourcei.SourceState, out state);
}
while ((ALSourceState)state == ALSourceState.Playing);
Trace.WriteLine("");
AL.SourceStop(source);
AL.DeleteSource(source);
AL.DeleteBuffer(buffer);
}
}
}
}

View file

@ -1,94 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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).
//[Example("Streaming Playback", ExampleCategory.OpenAL)]
public class StreamingPlayback
{
const string filename = "Data\\Audio\\the_ring_that_fell.wav";
const int buffer_size = (int)(0.5*44100);
const int buffer_count = 4;
//static object openal_lock = new object(); // Should be global in your app.
public static void Main()
{
using (AudioContext context = new AudioContext())
{
int source = AL.GenSource();
int[] buffers = AL.GenBuffers(buffer_count);
int state;
Trace.WriteLine("Testing WaveReader({0}).ReadSamples()", filename);
Trace.Write("Playing");
//foreach (int buffer in buffers)
// AL.BufferData(buffer, sound.ReadSamples(buffer_size));
AL.SourceQueueBuffers(source, buffers.Length, buffers);
AL.SourcePlay(source);
int processed_count, queued_count;
do
{
//Trace.Write(".");
do
{
AL.GetSource(source, ALGetSourcei.BuffersProcessed, out processed_count);
//Thread.Sleep(1);
}
while (processed_count == 0);
Trace.WriteLine(processed_count);
//while (processed_count > 0)
//{
// int buffer = AL.SourceUnqueueBuffer(source);
// if (buffer != 0 && !sound.EndOfFile)
// {
// Trace.WriteLine(" " + buffer.ToString());
// AL.BufferData(buffer, sound.ReadSamples(buffer_size));
// AL.SourceQueueBuffer(source, buffer);
// }
// --processed_count;
//}
AL.GetSource(source, ALGetSourcei.BuffersQueued, out queued_count);
if (queued_count > 0)
{
AL.GetSource(source, ALGetSourcei.SourceState, out state);
if ((ALSourceState)state != ALSourceState.Playing)
{
AL.SourcePlay(source);
Trace.WriteLine("r");
}
}
else
break;
}
while (true);
AL.SourceStop(source);
AL.DeleteSource(source);
AL.DeleteBuffers(buffers);
}
Trace.WriteLine("");
}
}
}

View file

@ -1,98 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2009 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
using System;
using System.Diagnostics;
using System.Threading;
using System.IO;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
namespace Examples
{
[Example("EFX: Reverb", ExampleCategory.OpenAL, "EFX", Documentation="EFXReverb")]
public class ReverbExample
{
static readonly string filename = Path.Combine(Path.Combine("Data", "Audio"), "the_ring_that_fell.wav");
public static void Main()
{
using (AudioContext context = new AudioContext())
{
Trace.WriteLine("Testing WaveReader({0}).ReadToEnd()", filename);
EffectsExtension efx = new EffectsExtension();
int buffer = AL.GenBuffer();
int source = AL.GenSource();
int state;
int effect = efx.GenEffect();
int slot = efx.GenAuxiliaryEffectSlot();
efx.BindEffect(effect, EfxEffectType.Reverb);
efx.Effect(effect, EfxEffectf.ReverbDecayTime, 3.0f);
efx.Effect(effect, EfxEffectf.ReverbDecayHFRatio, 0.91f);
efx.Effect(effect, EfxEffectf.ReverbDensity, 0.7f);
efx.Effect(effect, EfxEffectf.ReverbDiffusion, 0.9f);
efx.Effect(effect, EfxEffectf.ReverbRoomRolloffFactor, 3.1f);
efx.Effect(effect, EfxEffectf.ReverbReflectionsGain, 0.723f);
efx.Effect(effect, EfxEffectf.ReverbReflectionsDelay, 0.03f);
efx.Effect(effect, EfxEffectf.ReverbGain, 0.23f);
efx.AuxiliaryEffectSlot(slot, EfxAuxiliaryi.EffectslotEffect, effect);
int channels, bits, rate;
byte[] data = Playback.LoadWave(File.Open(filename, FileMode.Open), out channels, out bits, out rate);
AL.BufferData(buffer, Playback.GetSoundFormat(channels, bits), data, data.Length, rate);
AL.Source(source, ALSourcef.ConeOuterGain, 1.0f);
AL.Source(source, ALSourcei.Buffer, buffer);
AL.SourcePlay(source);
Trace.Write("Playing");
// Query the source to find out when it stops playing.
do
{
Thread.Sleep(250);
Trace.Write(".");
AL.GetSource(source, ALGetSourcei.SourceState, out state);
}
while ((ALSourceState)state == ALSourceState.Playing);
Trace.WriteLine("");
AL.SourceStop(source);
AL.DeleteSource(source);
AL.DeleteBuffer(buffer);
efx.DeleteEffect(effect);
efx.DeleteAuxiliaryEffectSlot(slot);
}
}
}
}

View file

@ -1,632 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2009 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using OpenTK;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
namespace Examples
{
/// <summary>
/// A text-based diagnosis program for OpenAL.
/// The constructors will call the OpenAL commands, the Print() methods just show the information.
/// </summary>
[Example("OpenAL diagnostics", ExampleCategory.OpenAL, "Test", 0, true)]
class OpenALDiagnostics
{
public static void checkForErrors()
{
{
IntPtr device = Alc.GetContextsDevice(Alc.GetCurrentContext());
AlcError error = Alc.GetError(device);
if (error != AlcError.NoError)
Trace.WriteLine("ALC ERROR: (" + error + ") " + Alc.GetString(device, (AlcGetString)error));
}
{
ALError error = AL.GetError();
if (error != ALError.NoError)
Trace.WriteLine("AL ERROR: (" + error + ") " + AL.GetErrorString(error));
}
}
[STAThread]
static void Main()
{
Trace.Listeners.RemoveAt(0);
Trace.Listeners.Add(new ConsoleTraceListener());
Trace.WriteLine("This application is currently running as " + (IntPtr.Size == 4 ? "x86" : "x64"));
DeviceDiagnostic DevDiag = new DeviceDiagnostic();
DevDiag.Print();
DevDiag = null;
using (AudioContext A = new AudioContext())
{
AlcDiagnostic AlcDiag = new AlcDiagnostic(Alc.GetContextsDevice(Alc.GetCurrentContext()));
checkForErrors();
AlcDiag.Print();
AlcDiag = null;
ALDiagnostic ALdiag = new ALDiagnostic(A);
checkForErrors();
ALdiag.Print();
ALdiag = null;
EfxDiagnostic EfxDiag = new EfxDiagnostic();
checkForErrors();
EfxDiag.Print();
EfxDiag = null;
XRamDiagnostic XRamDiag = new XRamDiagnostic();
checkForErrors();
XRamDiag.Print();
XRamDiag = null;
RecorderDiagnostic rec = new RecorderDiagnostic();
rec.Print();
rec = null;
}
// Trace.WriteLine("All done. Press Enter to exit.");
// Console.ReadLine();
}
}
class DeviceDiagnostic
{
#region Fields
public readonly IList<string> AllPlaybackDevices;
public readonly IList<string> AllRecordingDevices;
public readonly string DefaultPlaybackDevice;
public readonly string DefaultRecordingDevice;
#endregion Fields
public DeviceDiagnostic()
{
Trace.WriteLine("--- Device related errors ---");
AllPlaybackDevices = AudioContext.AvailableDevices;
AllRecordingDevices = AudioCapture.AvailableDevices;
DefaultPlaybackDevice = AudioContext.DefaultDevice;
DefaultRecordingDevice = AudioCapture.DefaultDevice;
}
public void Print()
{
Trace.WriteLine("--- Device related analysis ---");
Trace.Indent();
{
Trace.WriteLine("Default playback device: " + DefaultPlaybackDevice);
Trace.WriteLine("All known playback devices:");
Trace.Indent();
{
foreach (string s in AllPlaybackDevices)
Trace.WriteLine(s);
}
Trace.Unindent();
Trace.WriteLine("Default recording device: " + DefaultRecordingDevice);
Trace.WriteLine("All known recording devices:");
Trace.Indent();
{
foreach (string s in AllRecordingDevices)
Trace.WriteLine(s);
}
Trace.Unindent();
}
Trace.Unindent();
}
}
class AlcDiagnostic
{
#region Fields
private string[] Alc_Extension_C_Names = new string[]
{
"ALC_ENUMERATE_ALL_EXT",
"ALC_ENUMERATION_EXT",
"ALC_EXT_ASA",
"ALC_EXT_ASA_DISTORTION",
"ALC_EXT_ASA_ROGER_BEEP",
"ALC_EXT_BRS_GAME_LICENSE_REQUIRED",
"ALC_EXT_capture",
"ALC_EXT_DEDICATED",
"ALC_EXT_EFX",
};
public readonly int MajorVersion;
public readonly int MinorVersion;
public readonly int EfxMajorVersion;
public readonly int EfxMinorVersion;
public readonly int EfxMaxAuxiliarySends;
public readonly string ExtensionString;
public readonly Dictionary<string, bool> Extensions = new Dictionary<string, bool>();
#endregion Fields
public AlcDiagnostic(IntPtr dev)
{
Trace.WriteLine("--- Alc related errors ---");
Alc.GetInteger(dev, AlcGetInteger.MajorVersion, 1, out MajorVersion);
Alc.GetInteger(dev, AlcGetInteger.MinorVersion, 1, out MinorVersion);
Alc.GetInteger(dev, AlcGetInteger.EfxMajorVersion, 1, out EfxMajorVersion);
Alc.GetInteger(dev, AlcGetInteger.EfxMinorVersion, 1, out EfxMinorVersion);
Alc.GetInteger(dev, AlcGetInteger.EfxMaxAuxiliarySends, 1, out EfxMaxAuxiliarySends);
ExtensionString = Alc.GetString(dev, AlcGetString.Extensions);
foreach (string s in Alc_Extension_C_Names)
Extensions.Add(s, Alc.IsExtensionPresent(dev, s));
}
public void Print()
{
Trace.WriteLine("--- Alc related analysis ---");
Trace.Indent();
{
Trace.WriteLine("Alc Version: " + MajorVersion + "." + MinorVersion);
Trace.WriteLine("Efx Version: " + EfxMajorVersion + "." + EfxMinorVersion);
Trace.WriteLine("Efx max. Auxiliary sends: " + EfxMaxAuxiliarySends);
Trace.WriteLine("Alc Extension string: " + ExtensionString);
Trace.WriteLine("Confirmed Alc Extensions:");
Trace.Indent();
{
foreach (KeyValuePair<string, bool> pair in Extensions)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
}
Trace.Unindent();
}
}
class ALDiagnostic
{
#region Fields
private string[] AL_Extension_Names = new string[]
{
"AL_EXT_ALAW",
"AL_EXT_BFORMAT",
"AL_EXT_double",
"AL_EXT_EXPONENT_DISTANCE",
"AL_EXT_float32",
"AL_EXT_FOLDBACK",
"AL_EXT_IMA4",
"AL_EXT_LINEAR_DISTANCE",
"AL_EXT_MCFORMATS",
"AL_EXT_mp3",
"AL_EXT_MULAW",
"AL_EXT_OFFSET",
"AL_EXT_vorbis",
"AL_LOKI_quadriphonic",
"EAX-RAM",
"EAX",
"EAX1.0",
"EAX2.0",
"EAX3.0",
"EAX3.0EMULATED",
"EAX4.0",
"EAX4.0EMULATED",
"EAX5.0"
};
public readonly Dictionary<string, bool> Extensions = new Dictionary<string, bool>();
public readonly string DeviceName;
public readonly float SpeedOfSound;
public readonly string ExtensionString;
public readonly string Renderer;
public readonly string Vendor;
public readonly string Version;
public readonly ALDistanceModel DistanceModel;
const uint MaxSourcesLimit = 128;
public readonly uint MaxSources;
#endregion Fields
public ALDiagnostic(AudioContext ac)
{
Trace.WriteLine("--- AL related errors ---");
DeviceName = ac.CurrentDevice;
ExtensionString = AL.Get(ALGetString.Extensions);
Renderer = AL.Get(ALGetString.Renderer);
Vendor = AL.Get(ALGetString.Vendor);
Version = AL.Get(ALGetString.Version);
SpeedOfSound = AL.Get(ALGetFloat.SpeedOfSound);
DistanceModel = AL.GetDistanceModel();
foreach (string s in AL_Extension_Names)
Extensions.Add(s, AL.IsExtensionPresent(s));
AL.GetError(); // clear it, need this for the source counting to work properly
uint[] dummy_sources = new uint[MaxSourcesLimit];
for (MaxSources = 0; MaxSources < MaxSourcesLimit; MaxSources++)
{
AL.GenSource(out dummy_sources[MaxSources]);
if (AL.GetError() != ALError.NoError)
break;
}
for (int i = 0; i < MaxSources; i++)
AL.DeleteSource(ref dummy_sources[i]);
}
public void Print()
{
Trace.WriteLine("--- AL related analysis ---");
Trace.Indent();
{
Trace.WriteLine("Used Device: "+DeviceName);
Trace.WriteLine("AL Renderer: " + Renderer);
Trace.WriteLine("AL Vendor: " + Vendor);
Trace.WriteLine("AL Version: " + Version);
Trace.WriteLine("AL Speed of sound: " + SpeedOfSound);
Trace.WriteLine("AL Distance Model: " + DistanceModel.ToString());
Trace.WriteLine("AL Maximum simultanous Sources: " + MaxSources);
Trace.WriteLine("AL Extension string: " + ExtensionString);
Trace.WriteLine("Confirmed AL Extensions:");
Trace.Indent();
{
foreach (KeyValuePair<string, bool> pair in Extensions)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
}
Trace.Unindent();
}
}
class EfxDiagnostic
{
#region Fields
private EfxEffectType[] EffectNames = new EfxEffectType[]
{
EfxEffectType.Autowah,
EfxEffectType.Chorus,
EfxEffectType.Compressor,
EfxEffectType.Distortion,
EfxEffectType.EaxReverb,
EfxEffectType.Echo,
EfxEffectType.Equalizer,
EfxEffectType.Flanger,
EfxEffectType.FrequencyShifter,
EfxEffectType.PitchShifter,
EfxEffectType.Reverb,
EfxEffectType.RingModulator,
EfxEffectType.VocalMorpher,
};
private EfxFilterType[] FilterNames = new EfxFilterType[]
{
EfxFilterType.Bandpass,
EfxFilterType.Highpass,
EfxFilterType.Lowpass,
};
public readonly Dictionary<string, bool> Effects = new Dictionary<string, bool>();
public readonly Dictionary<string, bool> Filters = new Dictionary<string, bool>();
const uint MaxAuxiliaryEffectSlotsLimit = 4;
public readonly uint MaxAuxiliaryEffectSlots;
#endregion Fields
public EfxDiagnostic()
{
Trace.WriteLine("--- Efx related errors ---");
EffectsExtension Efx = new EffectsExtension();
Trace.Assert(Efx.IsInitialized);
#region Test for available Effects
uint effect;
Efx.GenEffect(out effect);
AL.GetError();
foreach (EfxEffectType e in EffectNames)
{
Efx.BindEffect(effect, e);
Effects.Add(e.ToString(), AL.GetError() == ALError.NoError);
}
Efx.DeleteEffect(ref effect);
#endregion Test for available Effects
#region Test for available Filters
uint filter;
Efx.GenFilter(out filter);
AL.GetError();
foreach (EfxFilterType f in FilterNames)
{
Efx.Filter(filter, EfxFilteri.FilterType, (int)f);
Filters.Add(f.ToString(), AL.GetError() == ALError.NoError);
}
Efx.DeleteFilter(ref filter);
#endregion Test for available Filters
AL.GetError();
uint[] dummy_slots = new uint[MaxAuxiliaryEffectSlotsLimit];
for (MaxAuxiliaryEffectSlots = 0; MaxAuxiliaryEffectSlots < MaxAuxiliaryEffectSlotsLimit; MaxAuxiliaryEffectSlots++)
{
Efx.GenAuxiliaryEffectSlot(out dummy_slots[MaxAuxiliaryEffectSlots]);
if (AL.GetError() != ALError.NoError)
break;
}
for (uint i = 0; i < MaxAuxiliaryEffectSlots; i++)
Efx.DeleteAuxiliaryEffectSlot(ref dummy_slots[i]);
}
public void Print()
{
Trace.WriteLine("--- Efx related analysis ---");
Trace.Indent();
{
Trace.WriteLine("Efx Effects supported:");
Trace.Indent();
{
foreach (KeyValuePair<string, bool> pair in Effects)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
Trace.WriteLine("Efx Filters supported:");
Trace.Indent();
{
foreach (KeyValuePair<string, bool> pair in Filters)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
Trace.WriteLine("Efx max. Auxiliary Effect Slots: " + MaxAuxiliaryEffectSlots);
}
Trace.Unindent();
}
}
class XRamDiagnostic
{
#region Fields
private XRamExtension.XRamStorage[] storagemodes = new XRamExtension.XRamStorage[]
{
XRamExtension.XRamStorage.Hardware,
XRamExtension.XRamStorage.Accessible,
XRamExtension.XRamStorage.Automatic,
};
public readonly bool XRamFound;
public readonly int RamTotal;
public readonly int RamFree;
public readonly Dictionary<string, bool> BufferModes = new Dictionary<string, bool>();
#endregion Fields
public XRamDiagnostic()
{
Trace.WriteLine("--- X-RAM related errors ---");
XRamExtension XRam = new XRamExtension();
if (XRam.IsInitialized)
{
XRamFound = true;
RamTotal = XRam.GetRamSize;
RamFree = XRam.GetRamFree;
uint buffer;
AL.GenBuffer(out buffer);
foreach (XRamExtension.XRamStorage m in storagemodes)
{
XRam.SetBufferMode(1, ref buffer, m);
BufferModes.Add(m.ToString(), m == XRam.GetBufferMode(ref buffer));
}
AL.DeleteBuffer(ref buffer);
}
else
XRamFound = false;
}
public void Print()
{
Trace.WriteLine("--- X-RAM related analysis ---");
if (XRamFound)
{
Trace.Indent(); // *
Trace.WriteLine("X-RAM extension found.");
}
else
{
Trace.Indent();
{
Trace.WriteLine("X-RAM extension is not available, skipping test.");
}
Trace.Unindent();
return;
}
Trace.WriteLine("Ram status (free/total) in bytes: " + RamFree + "/" + RamTotal);
Trace.WriteLine("Available buffer modes:");
Trace.Indent();
{
foreach (KeyValuePair<string, bool> pair in BufferModes)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
Trace.Unindent(); // *
}
}
class RecorderDiagnostic
{
#region Fields
bool IsDeviceAvailable;
bool BufferContentsAllZero;
short MaxSample = short.MinValue;
short MinSample = short.MaxValue;
private AudioCapture r;
Dictionary<string, AlcError> Errorlist = new Dictionary<string, AlcError>();
string DeviceName;
#endregion Fields
private void CheckRecorderError(string location)
{
AlcError err = r.CurrentError;
if (err != AlcError.NoError)
Errorlist.Add(location, err);
}
public RecorderDiagnostic()
{
Trace.WriteLine("--- AudioCapture related errors ---");
IsDeviceAvailable = false;
try
{
r = new AudioCapture(AudioCapture.DefaultDevice, 16000, ALFormat.Mono16, 4096);
}
catch (AudioDeviceException ade)
{
Trace.WriteLine("AudioCapture Exception caught: " + ade.Message);
return;
}
IsDeviceAvailable = true;
DeviceName = r.CurrentDevice;
CheckRecorderError("Alc.CaptureOpenDevice");
r.Start();
CheckRecorderError("Alc.CaptureStart");
Thread.Sleep(100);
r.Stop();
CheckRecorderError("Alc.CaptureStop");
byte[] Buffer = new byte[8192];
Thread.Sleep(10); // Wait for a few samples to become available.
int SamplesBefore = r.AvailableSamples;
CheckRecorderError("Alc.GetInteger(...CaptureSamples...)");
r.ReadSamples(Buffer, (SamplesBefore > 4096 ? 4096 : SamplesBefore));
CheckRecorderError("Alc.CaptureSamples");
int SamplesCaptured = SamplesBefore - r.AvailableSamples;
uint ZeroCounter = 0;
for (int i = 0; i < SamplesCaptured * 2; i++)
{
if (Buffer[i] == 0)
ZeroCounter++;
}
for (int i = 0; i < SamplesCaptured; i++)
{
short sample = BitConverter.ToInt16(Buffer, i * 2);
if (sample > MaxSample)
MaxSample = sample;
if (sample < MinSample)
MinSample = sample;
}
if (ZeroCounter < SamplesCaptured * 2 && SamplesCaptured > 0)
BufferContentsAllZero = false;
else
BufferContentsAllZero = true;
r.Dispose();
CheckRecorderError("Alc.CaptureCloseDevice");
// no playback test needed due to Parrot test app.
/*
uint buf;
AL.GenBuffer(out buf);
AL.BufferData(buf, ALFormat.Mono16, BufferPtr, SamplesCaptured * 2, 16000);
uint src;
AL.GenSource(out src);
AL.BindBufferToSource(src, buf);
AL.Listener(ALListenerf.Gain, 16.0f);
AL.SourcePlay(src);
while (AL.GetSourceState(src) == ALSourceState.Playing)
{
Thread.Sleep(0);
}
AL.SourceStop(src);
AL.DeleteSource(ref src);
AL.DeleteBuffer(ref buf);
*/
}
public void Print()
{
Trace.WriteLine("--- AudioCapture related analysis ---");
if (!IsDeviceAvailable)
{
Trace.WriteLine("Capture Device could not be initlialized (no microphone plugged into the jack?). Skipping test.");
return;
}
Trace.Indent();
{
Trace.WriteLine("Using capture device: " + DeviceName);
if (Errorlist.Count > 0)
{
Trace.WriteLine("Found Alc Errors:");
Trace.Indent();
{
foreach (KeyValuePair<string, AlcError> pair in Errorlist)
Trace.WriteLine(pair.Key + ": " + pair.Value);
}
Trace.Unindent();
}
Trace.WriteLine("Buffer contents after capture was all 0's: " + BufferContentsAllZero);
Trace.WriteLine("Sample min/max in recorded data: " + MinSample + " / " + MaxSample);
}
Trace.Unindent();
}
}
}

View file

@ -1,203 +0,0 @@
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing 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("AudioContext Test", ExampleCategory.OpenTK, "Test", 0, false)]
class TestApp
{
public static void PrintOpenALErrors( IntPtr device )
{
ALError AlErr = AL.GetError();
Trace.WriteLine("OpenAL error: {0}"+ AlErr);
}
public static void Main()
{
AlcUnitTestFunc();
}
public static void AlcUnitTestFunc()
{
AudioContext context = new AudioContext();
Trace.WriteLine("Testing AudioContext functions.");
Trace.Indent();
// Trace.WriteLine("Suspend()...");
// context.Suspend();
// Trace.Assert(!context.IsProcessing);
//
// Trace.WriteLine("Process()...");
// context.Process();
// Trace.Assert(context.IsProcessing);
//Trace.WriteLine("MakeCurrent()...");
//context.MakeCurrent();
//Trace.Assert(context.IsCurrent);
//Trace.WriteLine("IsCurrent = false...");
//context.IsCurrent = false;
//Trace.Assert(!context.IsCurrent);
//Trace.WriteLine("IsCurrent = true...");
//context.IsCurrent = true;
//Trace.Assert(context.IsCurrent);
Trace.WriteLine("AudioContext.CurrentContext...");
Trace.Assert(AudioContext.CurrentContext == context);
#region Get Attribs
//int AttribCount;
//Alc.GetInteger(context.Device, AlcGetInteger.AttributesSize, sizeof(int), out AttribCount);
//Trace.WriteLine("AttributeSize: " + AttribCount);
//if (AttribCount > 0)
//{
// int[] Attribs = new int[AttribCount];
// Alc.GetInteger(context.Device, AlcGetInteger.AllAttributes, AttribCount, out Attribs[0]);
// for (int i = 0; i < Attribs.Length; i++)
// {
// Trace.Write(Attribs[i]);
// Trace.Write(" ");
// }
// Trace.WriteLine();
//}
#endregion Get Attribs
#if false
AlDevice MyDevice;
AlContext MyContext;
// Initialize Open AL
MyDevice = Alc.OpenDevice( null );// open default device
if ( MyDevice != Al.Null )
{
Trace.WriteLine( "Device allocation succeeded." );
MyContext = Alc.CreateContext( MyDevice, Al.Null ); // create context
if ( MyContext != Al.Null )
{
Trace.WriteLine( "Context allocation succeeded." );
GetOpenALErrors( MyDevice );
Alc.SuspendContext( MyContext ); // disable context
Alc.ProcessContext( MyContext ); // enable context. The default state of a context created by alcCreateContext is that it is processing.
Al.Bool result = Alc.MakeContextCurrent( MyContext ); // set active context
Trace.WriteLine( "MakeContextCurrent succeeded? " + result );
GetOpenALErrors( MyDevice );
Trace.WriteLine( "Default: " + Alc.GetString( MyDevice, Enums.AlcGetString.DefaultDeviceSpecifier ) );
Trace.WriteLine( "Device: " + Alc.GetString( MyDevice, Enums.AlcGetString.DeviceSpecifier ) );
Trace.WriteLine( "Extensions: " + Alc.GetString( MyDevice, Enums.AlcGetString.Extensions ) );
GetOpenALErrors( MyDevice );
#region Get Attribs
int AttribCount;
Alc.GetInteger( MyDevice, Enums.AlcGetInteger.AttributesSize, sizeof( int ), out AttribCount );
Trace.WriteLine( "AttributeSize: " + AttribCount );
if ( AttribCount > 0 )
{
int[] Attribs = new int[AttribCount];
Alc.GetInteger( MyDevice, Enums.AlcGetInteger.AttributesSize, AttribCount, out Attribs[0] );
for ( int i = 0; i < Attribs.Length; i++ )
Trace.Write( ", " + Attribs[i] );
Trace.WriteLine( );
}
#endregion Get Attribs
GetOpenALErrors( MyDevice );
AlDevice currdev = Alc.GetContextsDevice( MyContext );
AlContext currcon = Alc.GetCurrentContext( );
if ( MyDevice == currdev )
Trace.WriteLine( "Devices match." );
else
Trace.WriteLine( "Error: Devices do not match." );
if ( MyContext == currcon )
Trace.WriteLine( "Context match." );
else
Trace.WriteLine( "Error: Contexts do not match." );
// exit
Alc.MakeContextCurrent( Al.Null ); // results in no context being current
Alc.DestroyContext( MyContext );
result = Alc.CloseDevice( MyDevice );
Trace.WriteLine( "Result: " + result );
Trace.ReadLine( );
}
else
{
Trace.WriteLine( "Context creation failed." );
}
}
else
{
Trace.WriteLine( "Failed to find suitable Device." );
}
#endif
/*
include <stdlib.h>
include <AL/alut.h>
int
main (int argc, char **argv)
{
ALuint helloBuffer, helloSource;
alutInit (&argc, argv);
helloBuffer = alutCreateBufferHelloWorld (); alGenSources (1, &helloSource);
alSourcei (helloSource, AL_Buffer, helloBuffer);
alSourcePlay (helloSource);
alutSleep (1);
alutExit ();
return EXIT_SUCCESS;
}*/
/*
* Processing Loop Example:
// PlaceCamera - places OpenGL camera & updates OpenAL listener buffer
void AVEnvironment::PlaceCamera()
{
// update OpenGL camera position
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.1333, 0.1333, -0.1, 0.1, 0.2, 50.0);
gluLookAt(listenerPos[0], listenerPos[1], listenerPos[2],
(listenerPos[0] + sin(listenerAngle)), listenerPos[1],
(listenerPos[2] - cos(listenerAngle)),
0.0, 1.0, 0.0);
// update OpenAL
// place listener at camera
alListener3f(AL_POSITION, listenerPos[0], listenerPos[1], listenerPos[2]);
float directionvect[6];
directionvect[0] = (float) sin(listenerAngle);
directionvect[1] = 0;
directionvect[2] = (float) cos(listenerAngle);
directionvect[3] = 0;
directionvect[4] = 1;
directionvect[5] = 0;
alListenerfv(AL_ORIENTATION, directionvect);
}
*/
}
}
}

View file

@ -1,145 +0,0 @@
#if EXPERIMENTAL
using System;
using System.Collections.Generic;
using System.Text;
using OpenTK.Compute.CL10;
namespace Examples
{
using cl_context = IntPtr;
using cl_device_id = IntPtr;
using cl_command_queue = IntPtr;
using cl_program = IntPtr;
using cl_kernel = IntPtr;
using cl_mem = IntPtr;
[Example("Vector Addition", ExampleCategory.OpenCL, "1.0")]
class VectorAdd
{
public static void Main()
{
const int cnBlockSize = 4;
const int cnBlocks = 3;
IntPtr cnDimension = new IntPtr(cnBlocks * cnBlockSize);
string sProgramSource = @"
__kernel void
vectorAdd(__global const float * a,
__global const float * b,
__global float * c)
{
// Vector element index
int nIndex = get_global_id(0);
c[nIndex] = a[nIndex] + b[nIndex];
}
";
ErrorCode error;
// create OpenCL device & context
cl_context hContext;
unsafe { hContext = CL.CreateContextFromType((ContextProperties*)null, DeviceTypeFlags.DeviceTypeDefault, IntPtr.Zero, IntPtr.Zero, &error); }
// query all devices available to the context
IntPtr nContextDescriptorSize;
CL.GetContextInfo(hContext, ContextInfo.ContextDevices, IntPtr.Zero, IntPtr.Zero, out nContextDescriptorSize);
cl_device_id[] aDevices = new cl_device_id[nContextDescriptorSize.ToInt32()];
unsafe
{
fixed (cl_device_id* ptr = aDevices)
{
IntPtr ret;
CL.GetContextInfo(hContext, ContextInfo.ContextDevices, nContextDescriptorSize, new IntPtr(ptr), out ret);
}
}
// create a command queue for first device the context reported
cl_command_queue hCmdQueue = CL.CreateCommandQueue(hContext, aDevices[0], (CommandQueueFlags)0, out error);
// create & compile program
cl_program hProgram;
unsafe { hProgram = CL.CreateProgramWithSource(hContext, 1, new string[] { sProgramSource }, null, &error); }
CL.BuildProgram(hProgram, 0, (IntPtr[])null, null, IntPtr.Zero, IntPtr.Zero);
// create kernel
cl_kernel hKernel = CL.CreateKernel(hProgram, "vectorAdd", out error);
// allocate host vectors
float[] A = new float[cnDimension.ToInt32()];
float[] B = new float[cnDimension.ToInt32()];
float[] C = new float[cnDimension.ToInt32()];
// initialize host memory
Random rand = new Random();
for (int i = 0; i < A.Length; i++)
{
A[i] = rand.Next() % 256;
B[i] = rand.Next() % 256;
}
// allocate device memory
unsafe
{
fixed (float* pA = A)
fixed (float* pB = B)
fixed (float* pC = C)
{
cl_mem hDeviceMemA, hDeviceMemB, hDeviceMemC;
hDeviceMemA = CL.CreateBuffer(hContext,
MemFlags.MemReadOnly | MemFlags.MemCopyHostPtr,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
new IntPtr(pA),
out error);
hDeviceMemB = CL.CreateBuffer(hContext,
MemFlags.MemReadOnly | MemFlags.MemCopyHostPtr,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
new IntPtr(pA),
out error);
hDeviceMemC = CL.CreateBuffer(hContext,
MemFlags.MemWriteOnly,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
IntPtr.Zero,
out error);
// setup parameter values
CL.SetKernelArg(hKernel, 0, new IntPtr(sizeof(cl_mem)), new IntPtr(&hDeviceMemA));
CL.SetKernelArg(hKernel, 1, new IntPtr(sizeof(cl_mem)), new IntPtr(&hDeviceMemB));
CL.SetKernelArg(hKernel, 2, new IntPtr(sizeof(cl_mem)), new IntPtr(&hDeviceMemC));
// write data from host to device
CL.EnqueueWriteBuffer(hCmdQueue, hDeviceMemA, true, IntPtr.Zero,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
new IntPtr(pA), 0, null, (IntPtr[])null);
CL.EnqueueWriteBuffer(hCmdQueue, hDeviceMemB, true, IntPtr.Zero,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
new IntPtr(pB), 0, null, (IntPtr[])null);
// execute kernel
error = (ErrorCode)CL.EnqueueNDRangeKernel(hCmdQueue, hKernel, 1, null, &cnDimension, null, 0, null, null);
if (error != ErrorCode.Success)
throw new Exception(error.ToString());
// copy results from device back to host
IntPtr event_handle = IntPtr.Zero;
error = (ErrorCode)CL.EnqueueReadBuffer(hCmdQueue, hDeviceMemC, true, IntPtr.Zero,
new IntPtr(cnDimension.ToInt32() * sizeof(float)),
new IntPtr(pC), 0, null, (IntPtr[])null);
if (error != ErrorCode.Success)
throw new Exception(error.ToString());
CL.Finish(hCmdQueue);
CL.ReleaseMemObject(hDeviceMemA);
CL.ReleaseMemObject(hDeviceMemB);
CL.ReleaseMemObject(hDeviceMemC);
}
}
for (int i = 0; i < A.Length; i++)
{
System.Diagnostics.Trace.WriteLine(String.Format("{0} + {1} = {2}", A[i], B[i], C[i]));
}
}
}
}
#endif

View file

@ -1,209 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Diagnostics;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
[Example( "Anaglyph Stereo", ExampleCategory.OpenGL, "1.x", Documentation = "Anaglyph" )]
class Anaglyph : GameWindow
{
Examples.Shapes.DrawableShape Object;
/// <summary>Creates a 800x600 window with the specified title.</summary>
public Anaglyph()
: base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.Default)
{
VSync = VSyncMode.On;
}
/// <summary>Load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(System.Drawing.Color.Black);
GL.Enable(EnableCap.DepthTest);
GL.Enable( EnableCap.Lighting );
GL.Enable( EnableCap.Light0 );
Object = new Examples.Shapes.MengerSponge(1.0, Shapes.MengerSponge.eSubdivisions.Two, true );
// Object = new Examples.Shapes.TorusKnot( 256, 32, 0.1, 3, 4, 1, true );
}
protected override void OnUnload( EventArgs e )
{
base.OnUnload( e );
Object.Dispose();
}
/// <summary>
/// Called when your window is resized. Set your viewport here. It is also
/// a good place to set up your projection matrix (which probably changes
/// along when the aspect ratio of your window).
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(ClientRectangle);
}
/// <summary>
/// Called when it is time to setup the next frame. Add you game logic here.
/// </summary>
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}
struct Camera
{
public Vector3 Position, Direction, Up;
public double NearPlane, FarPlane;
public double EyeSeparation;
public double Aperture; // FOV in degrees
public double FocalLength;
}
enum Eye
{
left,
right,
}
void SetupCamera( Eye eye )
{
Camera camera;
camera.Position = Vector3.UnitZ;
camera.Up = Vector3.UnitY;
camera.Direction = -Vector3.UnitZ;
camera.NearPlane = 1.0;
camera.FarPlane = 5.0;
camera.FocalLength = 2.0;
camera.EyeSeparation = camera.FocalLength / 30.0;
camera.Aperture = 75.0;
double left, right,
bottom, top;
double widthdiv2 = camera.NearPlane * Math.Tan( MathHelper.DegreesToRadians( (float)( camera.Aperture / 2.0 ) ) ); // aperture in radians
double precalc1 = ClientRectangle.Width / (double)ClientRectangle.Height * widthdiv2;
double precalc2 = 0.5 * camera.EyeSeparation * camera.NearPlane / camera.FocalLength;
Vector3 Right = Vector3.Cross( camera.Direction, camera.Up ); // Each unit vectors
Right.Normalize();
Right.X *= (float)( camera.EyeSeparation / 2.0 );
Right.Y *= (float)( camera.EyeSeparation / 2.0 );
Right.Z *= (float)( camera.EyeSeparation / 2.0 );
// Projection Matrix
top = widthdiv2;
bottom = -widthdiv2;
if ( eye == Eye.right )
{
left = -precalc1 - precalc2;
right = precalc1 - precalc2;
}
else
{
left = -precalc1 + precalc2;
right = precalc1 + precalc2;
}
GL.MatrixMode( MatrixMode.Projection );
GL.LoadIdentity();
GL.Frustum( left, right, bottom, top, camera.NearPlane, camera.FarPlane );
// Modelview Matrix
Matrix4 modelview;
if ( eye == Eye.right )
{
modelview = Matrix4.LookAt(
new Vector3( camera.Position.X + Right.X, camera.Position.Y + Right.Y, camera.Position.Z + Right.Z ),
new Vector3( camera.Position.X + Right.X + camera.Direction.X, camera.Position.Y + Right.Y + camera.Direction.Y, camera.Position.Z + Right.Z + camera.Direction.Z ),
camera.Up );
}
else
{
modelview = Matrix4.LookAt(
new Vector3( camera.Position.X - Right.X, camera.Position.Y - Right.Y, camera.Position.Z - Right.Z ),
new Vector3( camera.Position.X - Right.X + camera.Direction.X, camera.Position.Y - Right.Y + camera.Direction.Y, camera.Position.Z - Right.Z + camera.Direction.Z ),
camera.Up );
}
GL.MatrixMode( MatrixMode.Modelview );
GL.LoadIdentity();
GL.MultMatrix( ref modelview );
}
float Angle;
void Draw()
{
GL.Translate( 0f, 0f, -2f );
GL.Rotate( Angle, Vector3.UnitY );
Object.Draw();
}
/// <summary>
/// Called when it is time to render the next frame. Add your rendering code here.
/// </summary>
/// <param name="e">Contains timing information.</param>
protected override void OnRenderFrame( FrameEventArgs e )
{
Angle += (float)(e.Time *20.0);
GL.Clear( ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit );
SetupCamera( Eye.right );
GL.ColorMask( true, false, false, true );
Draw();
GL.Clear( ClearBufferMask.DepthBufferBit ); //
SetupCamera( Eye.left );
GL.ColorMask( false, true, true, true );
Draw();
GL.ColorMask( true, true, true, true );
SwapBuffers();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// The 'using' idiom guarantees proper resource cleanup.
// We request 30 UpdateFrame events per second, and unlimited
// RenderFrame events (as fast as the computer can handle).
using (Anaglyph game = new Anaglyph())
{
game.Run(10.0);
}
}
}
}

View file

@ -1,157 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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.Threading;
using OpenTK;
using OpenTK.Graphics.OpenGL;
#endregion --- Using Directives ---
namespace Examples.Tutorial
{
[Example("Display Lists", ExampleCategory.OpenGL, "1.x", 2, Documentation = "DisplayLists")]
public class T07_Display_Lists_Flower : GameWindow
{
#region --- Fields ---
const int num_lists = 13;
int[] lists = new int[num_lists];
#endregion
#region --- Constructor ---
public T07_Display_Lists_Flower()
: base(800, 600)
{
}
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
// Build some display lists.
int first_list = GL.GenLists(num_lists);
float c = 0;
for (int i = 0; i < num_lists; i++)
{
lists[i] = first_list + i;
GL.NewList(first_list + i, ListMode.Compile);
GL.Color3(0.3 + 0.7 * c * c, 0.3 + 1.4 * c * c, 0.7 - 0.7 * c * c);
c += 1 / (float)num_lists;
GL.PushMatrix();
GL.Rotate(c * 360.0f, 0.0, 0.0, 1.0);
GL.Translate(5.0, 0.0, 0.0);
GL.Begin(PrimitiveType.Quads);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.End();
GL.PopMatrix();
GL.EndList();
}
}
#endregion
#region OnUnload
protected override void OnUnload(EventArgs e)
{
GL.DeleteLists(lists[0], num_lists);
}
#endregion
#region OnResize
protected override void OnResize(EventArgs e)
{
GL.Viewport(ClientRectangle);
float aspect = this.ClientSize.Width / (float)this.ClientSize.Height;
Matrix4 projection_matrix;
Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspect, 1, 64, out projection_matrix);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection_matrix);
}
#endregion
#region OnUpdateFrame
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
}
#endregion
#region OnRenderFrame
protected override void OnRenderFrame(FrameEventArgs e)
{
Matrix4 lookat = Matrix4.LookAt(0, 0, 16, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.CallLists(num_lists, ListNameType.Int, lists);
SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (T07_Display_Lists_Flower example = new T07_Display_Lists_Flower())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,286 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Drawing;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial
{
[Example("Framebuffer Objects", ExampleCategory.OpenGL, "1.x", Documentation = "FramebufferObject")]
public class SimpleFBO : GameWindow
{
public SimpleFBO()
: base(800, 400)
{
}
uint ColorTexture;
uint DepthTexture;
uint FBOHandle;
const int TextureSize = 512;
Examples.Shapes.DrawableShape Object;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!GL.GetString(StringName.Extensions).Contains("GL_EXT_framebuffer_object"))
{
throw new NotSupportedException(
"GL_EXT_framebuffer_object extension is required. Please update your drivers.");
}
Object = new Shapes.TorusKnot(256, 16, 0.2, 7,8, 1, true);
GL.Enable(EnableCap.DepthTest);
GL.ClearDepth(1.0);
GL.DepthFunc(DepthFunction.Lequal);
GL.Enable(EnableCap.CullFace);
// Create Color Tex
GL.GenTextures(1, out ColorTexture);
GL.BindTexture(TextureTarget.Texture2D, ColorTexture);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, TextureSize, TextureSize, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
// GL.Ext.GenerateMipmap( GenerateMipmapTarget.Texture2D );
// Create Depth Tex
GL.GenTextures(1, out DepthTexture);
GL.BindTexture(TextureTarget.Texture2D, DepthTexture);
GL.TexImage2D(TextureTarget.Texture2D, 0, (PixelInternalFormat)All.DepthComponent32, TextureSize, TextureSize, 0, PixelFormat.DepthComponent, PixelType.UnsignedInt, IntPtr.Zero);
// things go horribly wrong if DepthComponent's Bitcount does not match the main Framebuffer's Depth
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
// GL.Ext.GenerateMipmap( GenerateMipmapTarget.Texture2D );
// Create a FBO and attach the textures
GL.Ext.GenFramebuffers(1, out FBOHandle);
GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, FBOHandle);
GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, ColorTexture, 0);
GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.DepthAttachmentExt, TextureTarget.Texture2D, DepthTexture, 0);
#region Test for Error
switch (GL.Ext.CheckFramebufferStatus(FramebufferTarget.FramebufferExt))
{
case FramebufferErrorCode.FramebufferCompleteExt:
{
Console.WriteLine("FBO: The framebuffer is complete and valid for rendering.");
break;
}
case FramebufferErrorCode.FramebufferIncompleteAttachmentExt:
{
Console.WriteLine("FBO: One or more attachment points are not framebuffer attachment complete. This could mean theres no texture attached or the format isnt renderable. For color textures this means the base format must be RGB or RGBA and for depth textures it must be a DEPTH_COMPONENT format. Other causes of this error are that the width or height is zero or the z-offset is out of range in case of render to volume.");
break;
}
case FramebufferErrorCode.FramebufferIncompleteMissingAttachmentExt:
{
Console.WriteLine("FBO: There are no attachments.");
break;
}
/* case FramebufferErrorCode.GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
{
Console.WriteLine("FBO: An object has been attached to more than one attachment point.");
break;
}*/
case FramebufferErrorCode.FramebufferIncompleteDimensionsExt:
{
Console.WriteLine("FBO: Attachments are of different size. All attachments must have the same width and height.");
break;
}
case FramebufferErrorCode.FramebufferIncompleteFormatsExt:
{
Console.WriteLine("FBO: The color attachments have different format. All color attachments must have the same format.");
break;
}
case FramebufferErrorCode.FramebufferIncompleteDrawBufferExt:
{
Console.WriteLine("FBO: An attachment point referenced by GL.DrawBuffers() doesnt have an attachment.");
break;
}
case FramebufferErrorCode.FramebufferIncompleteReadBufferExt:
{
Console.WriteLine("FBO: The attachment point referenced by GL.ReadBuffers() doesnt have an attachment.");
break;
}
case FramebufferErrorCode.FramebufferUnsupportedExt:
{
Console.WriteLine("FBO: This particular FBO configuration is not supported by the implementation.");
break;
}
default:
{
Console.WriteLine("FBO: Status unknown. (yes, this is really bad.)");
break;
}
}
// using FBO might have changed states, e.g. the FBO might not support stereoscopic views or double buffering
int[] queryinfo = new int[6];
GL.GetInteger(GetPName.MaxColorAttachmentsExt, out queryinfo[0]);
GL.GetInteger(GetPName.AuxBuffers, out queryinfo[1]);
GL.GetInteger(GetPName.MaxDrawBuffers, out queryinfo[2]);
GL.GetInteger(GetPName.Stereo, out queryinfo[3]);
GL.GetInteger(GetPName.Samples, out queryinfo[4]);
GL.GetInteger(GetPName.Doublebuffer, out queryinfo[5]);
Console.WriteLine("max. ColorBuffers: " + queryinfo[0] + " max. AuxBuffers: " + queryinfo[1] + " max. DrawBuffers: " + queryinfo[2] +
"\nStereo: " + queryinfo[3] + " Samples: " + queryinfo[4] + " DoubleBuffer: " + queryinfo[5]);
Console.WriteLine("Last GL Error: " + GL.GetError());
#endregion Test for Error
GL.PushAttrib(AttribMask.ViewportBit);
{
GL.Viewport(0, 0, TextureSize, TextureSize);
// clear the screen in red, to make it very obvious what the clear affected. only the FBO, not the real framebuffer
GL.ClearColor(1f, 0f, 0f, 0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView( MathHelper.PiOver4, TextureSize / (float)TextureSize, 2.5f, 6f );
GL.MatrixMode( MatrixMode.Projection );
GL.LoadMatrix( ref perspective );
Matrix4 lookat = Matrix4.LookAt( 0f, 0f, 4.5f, 0f, 0f, 0f, 0f, 1f, 0f );
GL.MatrixMode( MatrixMode.Modelview );
GL.LoadMatrix( ref lookat );
// draw some complex object into the FBO's textures
GL.Enable( EnableCap.Lighting );
GL.Enable( EnableCap.Light0 );
GL.Enable( EnableCap.ColorMaterial );
GL.Color3( 0f, 1f, 0f );
Object.Draw();
GL.Disable( EnableCap.ColorMaterial );
GL.Disable( EnableCap.Light0 );
GL.Disable( EnableCap.Lighting );
}
GL.PopAttrib();
GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // disable rendering into the FBO
GL.ClearColor(.1f, .2f, .3f, 0f);
GL.Color3(1f, 1f, 1f);
GL.Enable(EnableCap.Texture2D); // enable Texture Mapping
GL.BindTexture(TextureTarget.Texture2D, 0); // bind default texture
}
protected override void OnUnload(EventArgs e)
{
Object.Dispose();
// Clean up what we allocated before exiting
if (ColorTexture != 0)
GL.DeleteTextures(1, ref ColorTexture);
if (DepthTexture != 0)
GL.DeleteTextures(1, ref DepthTexture);
if (FBOHandle != 0)
GL.Ext.DeleteFramebuffers(1, ref FBOHandle);
}
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
Matrix4 lookat = Matrix4.LookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
base.OnResize(e);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
this.Exit();
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.PushMatrix();
{
// Draw the Color Texture
GL.Translate(-1.1f, 0f, 0f);
GL.BindTexture(TextureTarget.Texture2D, ColorTexture);
GL.Begin(PrimitiveType.Quads);
{
GL.TexCoord2(0f, 1f);
GL.Vertex2(-1.0f, 1.0f);
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex2(-1.0f, -1.0f);
GL.TexCoord2(1.0f, 0.0f);
GL.Vertex2(1.0f, -1.0f);
GL.TexCoord2(1.0f, 1.0f);
GL.Vertex2(1.0f, 1.0f);
}
GL.End();
// Draw the Depth Texture
GL.Translate(+2.2f, 0f, 0f);
GL.BindTexture(TextureTarget.Texture2D, DepthTexture);
GL.Begin(PrimitiveType.Quads);
{
GL.TexCoord2(0f, 1f);
GL.Vertex2(-1.0f, 1.0f);
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex2(-1.0f, -1.0f);
GL.TexCoord2(1.0f, 0.0f);
GL.Vertex2(1.0f, -1.0f);
GL.TexCoord2(1.0f, 1.0f);
GL.Vertex2(1.0f, 1.0f);
}
GL.End();
}
GL.PopMatrix();
this.SwapBuffers();
}
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (SimpleFBO example = new SimpleFBO())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,192 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates immediate mode rendering.
/// </summary>
[Example("Immediate mode", ExampleCategory.OpenGL, "1.x", 1, Documentation = "ImmediateMode")]
public class T03_Immediate_Mode_Cube : GameWindow
{
#region --- Fields ---
const float rotation_speed = 180.0f;
float angle;
#endregion
#region --- Constructor ---
public T03_Immediate_Mode_Cube()
: base(800, 600)
{ }
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
}
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
angle += rotation_speed * (float)e.Time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
DrawCube();
this.SwapBuffers();
Thread.Sleep(1);
}
#endregion
#region private void DrawCube()
private void DrawCube()
{
GL.Begin(PrimitiveType.Quads);
GL.Color3(Color.Silver);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Color3(Color.Honeydew);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Color3(Color.Moccasin);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Color3(Color.IndianRed);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Color3(Color.PaleVioletRed);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Color3(Color.ForestGreen);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.End();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (T03_Immediate_Mode_Cube example = new T03_Immediate_Mode_Cube())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,443 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Diagnostics;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
[Example( "OpenGL Diagnostics", ExampleCategory.OpenGL, "1.x", Documentation = "OpenGLDiagnostics" )]
class GLDiagnostics : GameWindow
{
/// <summary>Creates a 800x600 window with the specified title.</summary>
public GLDiagnostics()
: base(80, 60, GraphicsMode.Default, "OpenTK Quick Start Sample", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.Default)
{
VSync = VSyncMode.On;
this.Context.ErrorChecking = false;
}
struct TexFormat
{
public PixelInternalFormat pif;
public PixelFormat pf;
public PixelType pt;
public TexFormat(PixelInternalFormat _pif, PixelFormat _pf, PixelType _pt)
{
pif = _pif;
pf = _pf;
pt = _pt;
}
}
TexFormat[] TextureFormats = new TexFormat[]
{
new TexFormat( PixelInternalFormat.Alpha, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Alpha4, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Alpha8, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Alpha12, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Alpha16, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.Alpha16fArb, PixelFormat.Alpha, PixelType.HalfFloat),
new TexFormat( (PixelInternalFormat)All.Alpha32fArb, PixelFormat.Alpha, PixelType.Float),
new TexFormat( PixelInternalFormat.DepthComponent, PixelFormat.DepthComponent, PixelType.Int),
new TexFormat( PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.Float),
new TexFormat( PixelInternalFormat.DepthComponent24, PixelFormat.DepthComponent, PixelType.Float),
new TexFormat( PixelInternalFormat.DepthComponent32, PixelFormat.DepthComponent, PixelType.Float),
new TexFormat( PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float),
new TexFormat( PixelInternalFormat.DepthStencil, PixelFormat.DepthStencil, PixelType.UnsignedInt248),
new TexFormat( PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248),
new TexFormat( PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev),
new TexFormat( PixelInternalFormat.One, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Two, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgba, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Srgb, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.SrgbAlpha, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Srgb8, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.R16f, PixelFormat.Red, PixelType.HalfFloat),
new TexFormat( PixelInternalFormat.Rg16f, PixelFormat.Rg, PixelType.HalfFloat),
new TexFormat( PixelInternalFormat.Rgb16f, PixelFormat.Rgb, PixelType.HalfFloat),
new TexFormat( PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat),
new TexFormat( PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float),
new TexFormat( PixelInternalFormat.Rg32f, PixelFormat.Rg, PixelType.Float),
new TexFormat( PixelInternalFormat.Rgb32f, PixelFormat.Rgb, PixelType.Float),
new TexFormat( PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float),
new TexFormat( PixelInternalFormat.R8, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb8, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.R8ui, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rg8ui, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb8ui, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgba8ui, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.R16ui, PixelFormat.Red, PixelType.UnsignedShort),
new TexFormat( PixelInternalFormat.Rg16ui, PixelFormat.Rg, PixelType.UnsignedShort),
new TexFormat( PixelInternalFormat.Rgb16ui, PixelFormat.Rgb, PixelType.UnsignedShort),
new TexFormat( PixelInternalFormat.Rgba16ui, PixelFormat.Rgba, PixelType.UnsignedShort),
new TexFormat( PixelInternalFormat.R32ui, PixelFormat.Red, PixelType.UnsignedInt),
new TexFormat( PixelInternalFormat.Rg32ui, PixelFormat.Rg, PixelType.UnsignedInt),
new TexFormat( PixelInternalFormat.Rgb32ui, PixelFormat.Rgb, PixelType.UnsignedInt),
new TexFormat( PixelInternalFormat.Rgba32ui, PixelFormat.Rgba, PixelType.UnsignedInt),
new TexFormat( PixelInternalFormat.R8i, PixelFormat.Red, PixelType.Byte),
new TexFormat( PixelInternalFormat.Rg8i, PixelFormat.Rg, PixelType.Byte),
new TexFormat( PixelInternalFormat.Rgb8i, PixelFormat.Rgb, PixelType.Byte),
new TexFormat( PixelInternalFormat.Rgba8i, PixelFormat.Rgba, PixelType.Byte),
new TexFormat( PixelInternalFormat.R16i, PixelFormat.Red, PixelType.Short),
new TexFormat( PixelInternalFormat.Rg16i, PixelFormat.Rg, PixelType.Short),
new TexFormat( PixelInternalFormat.Rgb16i, PixelFormat.Rgb, PixelType.Short),
new TexFormat( PixelInternalFormat.Rgba16i, PixelFormat.Rgba, PixelType.Short),
new TexFormat( PixelInternalFormat.R32i, PixelFormat.Red, PixelType.Int),
new TexFormat( PixelInternalFormat.Rg32i, PixelFormat.Rg, PixelType.Int),
new TexFormat( PixelInternalFormat.Rgb32i, PixelFormat.Rgb, PixelType.Int),
new TexFormat( PixelInternalFormat.Rgba32i, PixelFormat.Rgba, PixelType.Int),
new TexFormat( PixelInternalFormat.R3G3B2, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb10A2, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb5A1, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.Rgb9E5, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedAlpha, PixelFormat.Alpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedIntensity, PixelFormat.Luminance, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedLuminance, PixelFormat.Luminance, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedLuminanceAlpha, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedLuminanceLatc1Ext, PixelFormat.Luminance, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedLuminanceAlphaLatc2Ext, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRed, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRedRgtc1, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRedGreenRgtc2Ext, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRg, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRgRgtc2, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRgb, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbFxt13Dfx, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedRgba, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbaFxt13Dfx, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedSignedLuminanceAlphaLatc2Ext, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedSignedLuminanceLatc1Ext, PixelFormat.Luminance, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSignedRedRgtc1, PixelFormat.Red, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSignedRgRgtc2, PixelFormat.Rg, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSluminance, PixelFormat.Luminance, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSluminanceAlpha, PixelFormat.LuminanceAlpha, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgb, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgbAlpha, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgbS3tcDxt1Ext, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbS3tcDxt1Ext, PixelFormat.Rgb, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt1Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt3Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
new TexFormat( (PixelInternalFormat)All.CompressedRgbaS3tcDxt5Ext, PixelFormat.Rgba, PixelType.UnsignedByte),
};
#region GL.Get* Helper
public enum eType
{
Boolean,
Int,
IntEnum,
IntArray2,
IntArray4,
Float,
FloatArray2,
FloatArray4,
}
public void Analyze(GetPName pname, eType type)
{
bool result1b;
int result1i;
int[] result2i = new int[2];
int[] result4i = new int[4];
float result1f;
Vector2 result2f;
Vector4 result4f;
string output;
switch (type)
{
case eType.Boolean:
GL.GetBoolean(pname, out result1b);
output = pname + ": " + result1b;
break;
case eType.Int:
GL.GetInteger(pname, out result1i);
output = pname + ": " + result1i;
break;
case eType.IntEnum:
GL.GetInteger(pname, out result1i);
output = pname + ": " + (All)result1i;
break;
case eType.IntArray2:
GL.GetInteger(pname, result2i);
output = pname + ": ( " + result2i[0] + ", " + result2i[1] + " )";
break;
case eType.IntArray4:
GL.GetInteger(pname, result4i);
output = pname + ": ( " + result4i[0] + ", " + result4i[1] + " ) ( " + result4i[2] + ", " + result4i[3] + " )";
break;
case eType.Float:
GL.GetFloat(pname, out result1f);
output = pname + ": " + result1f;
break;
case eType.FloatArray2:
GL.GetFloat(pname, out result2f);
output = pname + ": ( " + result2f.X + ", " + result2f.Y + " )";
break;
case eType.FloatArray4:
GL.GetFloat(pname, out result4f);
output = pname + ": ( " + result4f.X + ", " + result4f.Y + ", " + result4f.Z + ", " + result4f.W + " )";
break;
default: throw new NotImplementedException();
}
ErrorCode err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("Unsupported Token: " + pname);
else
Trace.WriteLine(output);
}
#endregion GL.Get* Helper
/// <summary>Load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(System.Drawing.Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
// returns 0 formats, driver broken?
/*
int CompressedTextureFormatCount;
GL.GetInteger(GetPName.NumCompressedTextureFormats, out CompressedTextureFormatCount);
if (CompressedTextureFormatCount > 0)
{
int[] CompressedTextureFormats = new int[CompressedTextureFormatCount];
GL.GetInteger(GetPName.CompressedTextureFormats, CompressedTextureFormats);
Trace.WriteLine("Supported compressed Texture formats:");
for (int i = 0; i < CompressedTextureFormats.Length; i++)
Trace.Write((All)CompressedTextureFormats[i] + ", ");
}
*/
string Renderer = GL.GetString(StringName.Renderer);
string GLSLang = GL.GetString(StringName.ShadingLanguageVersion);
string Vendor = GL.GetString(StringName.Vendor);
string Version = GL.GetString(StringName.Version);
string ExtensionsRaw = GL.GetString(StringName.Extensions);
string[] splitter = new string[] { " " };
string[] Extensions = ExtensionsRaw.Split(splitter, StringSplitOptions.None);
Trace.WriteLine("Vendor: " + Vendor);
Trace.WriteLine("Renderer: " + Renderer);
Trace.WriteLine("GL Version: " + Version);
Analyze(GetPName.MajorVersion, eType.Int);
Analyze(GetPName.MinorVersion, eType.Int);
Trace.WriteLine("GLSL Version: " + GLSLang);
Trace.WriteLine("Extensions: ");
for (int i = 0; i < Extensions.Length; i++)
Trace.WriteLine(Extensions[i]);
Trace.WriteLine("--- Framebuffer ---");
Analyze(GetPName.Doublebuffer, eType.Boolean);
Analyze(GetPName.MaxColorAttachments, eType.Int);
Analyze(GetPName.MaxDrawBuffers, eType.Int);
Analyze(GetPName.AuxBuffers, eType.Int);
Analyze(GetPName.DrawBuffer, eType.IntEnum);
Analyze(GetPName.MaxSamples, eType.Int);
Analyze(GetPName.MaxViewportDims, eType.IntArray2);
Analyze(GetPName.Viewport, eType.IntArray4);
Trace.WriteLine("--- Framebuffer channels ---");
Analyze(GetPName.RedBits, eType.Int);
Analyze(GetPName.GreenBits, eType.Int);
Analyze(GetPName.BlueBits, eType.Int);
Analyze(GetPName.AlphaBits, eType.Int);
Analyze(GetPName.DepthBits, eType.Int);
Analyze(GetPName.StencilBits, eType.Int);
Analyze(GetPName.AccumRedBits, eType.Int);
Analyze(GetPName.AccumGreenBits, eType.Int);
Analyze(GetPName.AccumBlueBits, eType.Int);
Analyze(GetPName.AccumAlphaBits, eType.Int);
Trace.WriteLine("--- Textures ---");
Analyze(GetPName.MaxCombinedTextureImageUnits, eType.Int);
Analyze(GetPName.MaxVertexTextureImageUnits, eType.Int);
Analyze(GetPName.MaxTextureImageUnits, eType.Int);
Analyze(GetPName.MaxTextureUnits, eType.Int);
Analyze(GetPName.MaxTextureSize, eType.Int);
Analyze(GetPName.Max3DTextureSize, eType.Int);
Analyze(GetPName.MaxCubeMapTextureSize, eType.Int);
Analyze(GetPName.MaxRenderbufferSize, eType.Int);
Analyze(GetPName.MaxTextureLodBias, eType.Int);
Queue<TexFormat> Supported = new Queue<TexFormat>();
Queue<TexFormat> Unsupported = new Queue<TexFormat>();
uint DummyTexture;
foreach (TexFormat t in TextureFormats)
{
GL.GenTextures(1, out DummyTexture);
GL.BindTexture(TextureTarget.Texture2D, DummyTexture);
GL.TexImage2D(TextureTarget.Texture2D, 0, t.pif, 4, 4, 0, t.pf, t.pt, IntPtr.Zero);
if (GL.GetError() == ErrorCode.NoError)
Supported.Enqueue(t);
else
Unsupported.Enqueue(t);
GL.DeleteTextures(1, ref DummyTexture);
}
GL.BindTexture(TextureTarget.Texture2D, 0);
Trace.WriteLine("--- UN-supported Texture formats ---");
while (Unsupported.Count > 0)
{
TexFormat tex = Unsupported.Dequeue();
Trace.Write((All)tex.pif+", ");
}
Trace.WriteLine( " " );
Trace.WriteLine("--- SUPPORTED Texture formats ---");
while (Supported.Count > 0)
{
TexFormat tex = Supported.Dequeue();
Trace.WriteLine((All)tex.pif+" " +tex.pf + " "+tex.pt);
}
Trace.WriteLine(" ");
Trace.WriteLine("--- Point&Line volumes ---");
Analyze(GetPName.AliasedPointSizeRange, eType.FloatArray2);
Analyze(GetPName.PointSizeMin, eType.Float);
Analyze(GetPName.PointSizeMax, eType.Float);
Analyze(GetPName.PointSizeGranularity, eType.Float);
Analyze(GetPName.PointSizeRange, eType.FloatArray2);
Analyze(GetPName.AliasedLineWidthRange, eType.FloatArray2);
Analyze(GetPName.LineWidthGranularity, eType.Float);
Analyze(GetPName.LineWidthRange, eType.FloatArray2);
Trace.WriteLine("--- VBO ---");
Analyze(GetPName.MaxElementsIndices, eType.Int);
Analyze(GetPName.MaxElementsVertices, eType.Int);
Analyze(GetPName.MaxVertexAttribs, eType.Int);
Trace.WriteLine("--- GLSL ---");
Analyze(GetPName.MaxCombinedFragmentUniformComponents, eType.Int);
Analyze(GetPName.MaxCombinedGeometryUniformComponents, eType.Int);
Analyze(GetPName.MaxCombinedVertexUniformComponents, eType.Int);
Analyze(GetPName.MaxFragmentUniformComponents, eType.Int);
Analyze(GetPName.MaxVertexUniformComponents, eType.Int);
Analyze(GetPName.MaxCombinedUniformBlocks, eType.Int);
Analyze(GetPName.MaxFragmentUniformBlocks, eType.Int);
Analyze(GetPName.MaxGeometryUniformBlocks, eType.Int);
Analyze(GetPName.MaxVertexUniformBlocks, eType.Int);
Analyze(GetPName.MaxUniformBlockSize, eType.Int);
Analyze(GetPName.MaxUniformBufferBindings, eType.Int);
Analyze(GetPName.MaxVaryingFloats, eType.Int);
Trace.WriteLine("--- Transform Feedback ---");
Analyze(GetPName.MaxTransformFeedbackInterleavedComponents, eType.Int);
Analyze(GetPName.MaxTransformFeedbackSeparateAttribs, eType.Int);
Analyze(GetPName.MaxTransformFeedbackSeparateComponents, eType.Int);
Trace.WriteLine("--- Fixed-Func Stacks, GL.Push* and GL.Pop* ---");
Analyze(GetPName.MaxClientAttribStackDepth, eType.Int);
Analyze(GetPName.MaxAttribStackDepth, eType.Int);
Analyze(GetPName.MaxProjectionStackDepth, eType.Int);
Analyze(GetPName.MaxModelviewStackDepth, eType.Int);
Analyze(GetPName.MaxTextureStackDepth, eType.Int);
Analyze(GetPName.MaxNameStackDepth, eType.Int);
Trace.WriteLine("--- Fixed-Func misc. stuff ---");
Analyze(GetPName.MaxEvalOrder, eType.Int);
Analyze(GetPName.MaxClipPlanes, eType.Int);
Analyze(GetPName.MaxArrayTextureLayers, eType.Int);
Analyze(GetPName.MaxListNesting, eType.Int);
Analyze(GetPName.MaxLights, eType.Int);
Analyze(GetPName.MaxTextureCoords, eType.Int);
this.Exit();
}
/// <summary>
/// Called when your window is resized. Set your viewport here. It is also
/// a good place to set up your projection matrix (which probably changes
/// along when the aspect ratio of your window).
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(ClientRectangle);
}
/// <summary>
/// Called when it is time to setup the next frame. Add you game logic here.
/// </summary>
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}
/// <summary>
/// Called when it is time to render the next frame. Add your rendering code here.
/// </summary>
/// <param name="e">Contains timing information.</param>
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// The 'using' idiom guarantees proper resource cleanup.
// We request 30 UpdateFrame events per second, and unlimited
// RenderFrame events (as fast as the computer can handle).
using (GLDiagnostics game = new GLDiagnostics())
{
game.Run(10.0);
}
}
}
}

View file

@ -1,323 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.IO;
using System.Drawing;
using System.Diagnostics;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using Examples.Shapes;
namespace Examples.Tutorial
{
/// <summary>
/// This demo shows over which triangle the cursor is, it does so by assigning all 3 vertices of a triangle the same Ids.
/// 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.
/// </summary>
[Example("Picking", ExampleCategory.OpenGL, "1.x", Documentation = "Picking")]
class Picking : GameWindow
{
int mouse_x, mouse_y;
/// <summary>Creates a 800x600 window with the specified title.</summary>
public Picking()
: base(800, 600, GraphicsMode.Default, "Picking", GameWindowFlags.Default, DisplayDevice.Default, 1, 1, GraphicsContextFlags.Default)
{
VSync = VSyncMode.On;
MouseMove += (sender, e) =>
{
mouse_x = e.X;
mouse_y = e.Y;
};
}
struct Byte4
{
public byte R, G, B, A;
public Byte4(byte[] input)
{
R = input[0];
G = input[1];
B = input[2];
A = input[3];
}
public uint ToUInt32()
{
byte[] temp = new byte[] { this.R, this.G, this.B, this.A };
return BitConverter.ToUInt32(temp, 0);
}
public override string ToString()
{
return this.R + ", " + this.G + ", " + this.B + ", " + this.A;
}
}
struct Vertex
{
public Byte4 Color; // 4 bytes
public Vector3 Position; // 12 bytes
public const byte SizeInBytes = 16;
}
const TextureTarget Target = TextureTarget.TextureRectangleArb;
float angle;
PrimitiveType VBO_PrimMode;
Vertex[] VBO_Array;
uint VBO_Handle;
uint SelectedTriangle;
// int VertexShaderObject, FragmentShaderObject, ProgramObject;
/// <summary>Load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.CullFace);
#region prepare data for VBO from procedural object
DrawableShape temp_obj = new SierpinskiTetrahedron(3f, SierpinskiTetrahedron.eSubdivisions.Five, false);
VertexT2fN3fV3f[] temp_VBO;
uint[] temp_IBO;
temp_obj.GetArraysforVBO(out VBO_PrimMode, out temp_VBO, out temp_IBO);
temp_obj.Dispose();
if (temp_IBO != null)
throw new Exception("Expected data for GL.DrawArrays, but Element Array is not null.");
// Convert from temp mesh to final object, copy position and add triangle Ids for the color attribute.
VBO_Array = new Vertex[temp_VBO.Length];
int TriangleCounter = -1;
for (int i = 0; i < temp_VBO.Length; i++)
{
// Position
VBO_Array[i].Position = temp_VBO[i].Position;
// Index
if (i % 3 == 0)
TriangleCounter++;
VBO_Array[i].Color = new Byte4(BitConverter.GetBytes(TriangleCounter));
}
#endregion prepare data for VBO from procedural object
#region Setup VBO for drawing
GL.GenBuffers(1, out VBO_Handle);
GL.BindBuffer(BufferTarget.ArrayBuffer, VBO_Handle);
GL.BufferData<Vertex>(BufferTarget.ArrayBuffer, (IntPtr)(VBO_Array.Length * Vertex.SizeInBytes), VBO_Array, BufferUsageHint.StaticDraw);
GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, IntPtr.Zero);
ErrorCode err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("VBO Setup failed (Error: " + err + "). Attempting to continue.");
#endregion Setup VBO for drawing
#region Shader
/*
// Load&Compile Vertex Shader
using (StreamReader sr = new StreamReader("Data/Shaders/Picking_VS.glsl"))
{
VertexShaderObject = GL.CreateShader(ShaderType.VertexShader);
GL.ShaderSource(VertexShaderObject, sr.ReadToEnd());
GL.CompileShader(VertexShaderObject);
}
err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("Vertex Shader: " + err);
string LogInfo;
GL.GetShaderInfoLog(VertexShaderObject, out LogInfo);
if (LogInfo.Length > 0 && !LogInfo.Contains("hardware"))
Trace.WriteLine("Vertex Shader failed!\nLog:\n" + LogInfo);
else
Trace.WriteLine("Vertex Shader compiled without complaint.");
// Load&Compile Fragment Shader
using (StreamReader sr = new StreamReader("Data/Shaders/Picking_FS.glsl"))
{
FragmentShaderObject = GL.CreateShader(ShaderType.FragmentShader);
GL.ShaderSource(FragmentShaderObject, sr.ReadToEnd());
GL.CompileShader(FragmentShaderObject);
}
GL.GetShaderInfoLog(FragmentShaderObject, out LogInfo);
err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("Fragment Shader: " + err);
if (LogInfo.Length > 0 && !LogInfo.Contains("hardware"))
Trace.WriteLine("Fragment Shader failed!\nLog:\n" + LogInfo);
else
Trace.WriteLine("Fragment Shader compiled without complaint.");
// Link the Shaders to a usable Program
ProgramObject = GL.CreateProgram();
GL.AttachShader(ProgramObject, VertexShaderObject);
GL.AttachShader(ProgramObject, FragmentShaderObject);
// link it all together
GL.LinkProgram(ProgramObject);
err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("LinkProgram: " + err);
GL.UseProgram(ProgramObject);
err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("UseProgram: " + err);
// flag ShaderObjects for delete when not used anymore
GL.DeleteShader(VertexShaderObject);
GL.DeleteShader(FragmentShaderObject);
int temp;
GL.GetProgram(ProgramObject, ProgramParameter.LinkStatus, out temp);
Trace.WriteLine("Linking Program (" + ProgramObject + ") " + ((temp == 1) ? "succeeded." : "FAILED!"));
if (temp != 1)
{
GL.GetProgramInfoLog(ProgramObject, out LogInfo);
Trace.WriteLine("Program Log:\n" + LogInfo);
}
Trace.WriteLine("End of Shader build. GL Error: " + GL.GetError());
GL.UseProgram(0);
*/
#endregion Shader
}
protected override void OnUnload(EventArgs e)
{
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.DeleteBuffers(1, ref VBO_Handle);
base.OnUnload(e);
}
/// <summary>
/// Called when your window is resized. Set your viewport here. It is also
/// a good place to set up your projection matrix (which probably changes
/// along when the aspect ratio of your window).
/// </summary>
/// <param name="e">Contains information on the new Width and Size of the GameWindow.</param>
protected override void OnResize(EventArgs e)
{
GL.Viewport(ClientRectangle);
Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, this.Width / (float)this.Height, 0.1f, 10.0f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection);
}
/// <summary>
/// Called when it is time to setup the next frame. Add you game logic here.
/// </summary>
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}
/// <summary>
/// Called when it is time to render the next frame. Add your rendering code here.
/// </summary>
/// <param name="e">Contains timing information.</param>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Color3(Color.White);
GL.EnableClientState(ArrayCap.ColorArray);
#region Pass 1: Draw Object and pick Triangle
GL.ClearColor(1f, 1f, 1f, 1f); // clears to uint.MaxValue
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 modelview = Matrix4.LookAt(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref modelview);
GL.Translate(0f, 0f, -3f);
GL.Rotate(angle, Vector3.UnitX);
GL.Rotate(angle, Vector3.UnitY);
angle += (float)e.Time * 3.0f;
// You may re-enable the shader, but it works perfectly without and will run on intel HW too
// GL.UseProgram(ProgramObject);
GL.DrawArrays(VBO_PrimMode, 0, VBO_Array.Length);
// GL.UseProgram(0);
// Read Pixel under mouse cursor
Byte4 Pixel = new Byte4();
GL.ReadPixels(mouse_x, this.Height - mouse_y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, ref Pixel);
SelectedTriangle = Pixel.ToUInt32();
#endregion Pass 1: Draw Object and pick Triangle
GL.Color3(Color.White);
GL.DisableClientState(ArrayCap.ColorArray);
#region Pass 2: Draw Shape
if (SelectedTriangle == uint.MaxValue)
GL.ClearColor(.2f, .1f, .3f, 1f); // purple
else
GL.ClearColor(0f, .2f, .3f, 1f); // cyan
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Color3(1f, 1f, 1f);
GL.DrawArrays(VBO_PrimMode, 0, VBO_Array.Length);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.Color3(Color.Red);
GL.DrawArrays(VBO_PrimMode, 0, VBO_Array.Length);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
if (SelectedTriangle != uint.MaxValue)
{
GL.Disable(EnableCap.DepthTest);
GL.Color3(Color.Green);
GL.DrawArrays(VBO_PrimMode, (int)SelectedTriangle * 3, 3);
GL.Enable(EnableCap.DepthTest);
}
#endregion Pass 2: Draw Shape
this.SwapBuffers();
ErrorCode err = GL.GetError();
if (err != ErrorCode.NoError)
Trace.WriteLine("Error at Swapbuffers: " + err);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// The 'using' idiom guarantees proper resource cleanup.
// We request 30 UpdateFrame events per second, and unlimited
// RenderFrame events (as fast as the computer can handle).
using (Picking example = new Picking())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2} (use the mouse to pick)", info.Category, info.Difficulty, info.Title);
example.Run(30.0);
}
}
}
}

View file

@ -1,311 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Examples.Shapes;
namespace Examples.Tutorial
{
[Example("Stencil CSG", ExampleCategory.OpenGL, "1.x", Documentation = "StencilCSG")]
partial class StencilCSG : GameWindow
{
#region Model Related
DrawableShape OperandB;
DrawableShape OperandA;
float MySphereZOffset = 0f;
float MySphereXOffset = 0f;
int Texture;
#endregion Model Related
string WindowTitle;
bool ShowDebugWireFrame = true;
float CameraZoom;
float CameraRotX;
float CameraRotY;
Vector3 EyePosition = new Vector3(0f, 0f, 15f);
#region Window
public StencilCSG()
: base(800, 600, new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8)) // request 8-bit stencil buffer
{
base.VSync = VSyncMode.Off;
KeyDown += delegate(object sender, KeyboardKeyEventArgs e)
{
switch (e.Key)
{
case Key.Escape: this.Exit(); break;
case Key.Space: ShowDebugWireFrame = !ShowDebugWireFrame; break;
}
};
}
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
GL.MatrixMode(MatrixMode.Projection);
Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 64.0f);
GL.LoadMatrix(ref p);
}
#endregion Window
protected override void OnLoad(EventArgs e)
{
#region Abort on platforms which will not be able to execute the ops properly
/*
if (!GL.SupportsExtension("VERSION_1_2"))
{
Trace.WriteLine("Aborting. OpenGL 1.2 or later required.");
this.Exit();
}
int[] t = new int[2];
GL.GetInteger(GetPName.MajorVersion, out t[0]);
GL.GetInteger(GetPName.MinorVersion, out t[1]);
Trace.WriteLine("OpenGL Context Version: " + t[0] + "." + t[1]);
GL.GetInteger(GetPName.DepthBits, out t[0]);
Trace.WriteLine("Depth Bits: " + t[0]);
GL.GetInteger(GetPName.StencilBits, out t[1]);
Trace.WriteLine("Stencil Bits: " + t[1]);
if (t[0] < 16)
{
Trace.WriteLine("Aborting. Need at least 16 depth bits, only " + t[0] + " available.");
this.Exit();
}
if (t[1] < 1)
{
Trace.WriteLine("Aborting. Need at least 1 stencil bit, only " + t[1] + " available.");
this.Exit();
}
*/
#endregion Abort on platforms which will not be able to execute the ops properly
WindowTitle = "Cube-Sphere Stencil CSG " + GL.GetString(StringName.Renderer) + " (GL " + GL.GetString(StringName.Version) + ")";
#region GL States
GL.ClearColor(.08f, .12f, .16f, 1f);
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Less);
GL.ClearDepth(1.0);
GL.Enable(EnableCap.StencilTest);
GL.ClearStencil(0);
GL.StencilMask(0xFFFFFFFF); // read&write
GL.Enable(EnableCap.CullFace);
GL.FrontFace(FrontFaceDirection.Ccw);
GL.CullFace(CullFaceMode.Back);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.Color4(1f, 1f, 1f, 1f);
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.Light0);
GL.ShadeModel(ShadingModel.Smooth);
#endregion GL States
#region Load Texture
Bitmap bitmap = new Bitmap("Data/Textures/logo-dark.jpg");
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
GL.GenTextures(1, out Texture);
GL.BindTexture(TextureTarget.Texture2D, Texture);
BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.Finish();
bitmap.UnlockBits(data);
#endregion Load Texture
OperandA = new ChamferCube(1.5, 2.0, 2.5, ChamferCube.SubDivs.Four, 0.42, true);
OperandB = new SlicedSphere(2.0f, Vector3d.Zero,
SlicedSphere.eSubdivisions.Three,
new SlicedSphere.eDir[] { SlicedSphere.eDir.All },
true);
#region Invert Operand B's Normals
// only the inside of the operand is ever drawn to color buffers and lighting requires this.
PrimitiveType tempPrimMode;
VertexT2dN3dV3d[] tempVertices;
uint[] tempIndices;
OperandB.GetArraysforVBO(out tempPrimMode, out tempVertices, out tempIndices);
OperandB.Dispose();
for (int i = 0; i < tempVertices.Length; i++)
{
tempVertices[i].Normal *= -1.0;
tempVertices[i].Normal.Normalize();
}
OperandB = new VboShape(ref tempPrimMode, ref tempVertices, ref tempIndices, true);
#endregion Invert Operand B's Normals
}
protected override void OnUnload(EventArgs e)
{
GL.DeleteTextures(1, ref Texture);
OperandA.Dispose();
OperandB.Dispose();
base.OnUnload(e);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
var mouse = OpenTK.Input.Mouse.GetState();
CameraRotX = -mouse.X * .5f;
CameraRotY = mouse.Y * .5f;
CameraZoom = mouse.Wheel * .2f;
}
public void DrawOperandB()
{
GL.PushMatrix();
GL.Translate(Math.Cos(MySphereXOffset), -1f, Math.Cos(MySphereZOffset));
OperandB.Draw();
GL.PopMatrix();
}
public void DrawOperandA()
{
GL.Enable(EnableCap.Texture2D);
OperandA.Draw();
GL.Disable(EnableCap.Texture2D);
}
public void RenderCsg()
{
// first pass
GL.Disable(EnableCap.StencilTest);
GL.ColorMask(false, false, false, false);
GL.CullFace(CullFaceMode.Front);
DrawOperandB();// draw front-faces into depth buffer
// use stencil plane to find parts of b in a
GL.DepthMask(false);
GL.Enable(EnableCap.StencilTest);
GL.StencilFunc(StencilFunction.Always, 0, 0);
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Incr);
GL.CullFace(CullFaceMode.Back);
DrawOperandA(); // increment the stencil where the front face of a is drawn
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Decr);
GL.CullFace(CullFaceMode.Front);
DrawOperandA(); // decrement the stencil buffer where the back face of a is drawn
GL.DepthMask(true);
GL.Disable(EnableCap.DepthTest);
GL.ColorMask(true, true, true, true);
GL.StencilFunc(StencilFunction.Notequal, 0, 1);
DrawOperandB(); // draw the part of b that's in a
// fix depth
GL.ColorMask(false, false, false, false);
GL.Enable(EnableCap.DepthTest);
GL.Disable(EnableCap.StencilTest);
GL.DepthFunc(DepthFunction.Always);
DrawOperandA();
GL.DepthFunc(DepthFunction.Less);
// second pass
GL.CullFace(CullFaceMode.Back);
DrawOperandA();
GL.DepthMask(false);
GL.Enable(EnableCap.StencilTest);
GL.StencilFunc(StencilFunction.Always, 0, 0);
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Incr);
DrawOperandB(); // increment the stencil where the front face of b is drawn
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Decr);
GL.CullFace(CullFaceMode.Front);
DrawOperandB(); // decrement the stencil buffer where the back face of b is drawn
GL.DepthMask(true);
GL.Disable(EnableCap.DepthTest);
GL.ColorMask(true, true, true, true);
GL.StencilFunc(StencilFunction.Equal, 0, 1);
GL.CullFace(CullFaceMode.Back);
DrawOperandA(); // draw the part of a that's in b
GL.Enable(EnableCap.DepthTest);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
this.Title = WindowTitle + " FPS: " + (1f / e.Time).ToString("0.");
MySphereZOffset += (float)(e.Time * 3.1);
MySphereXOffset += (float)(e.Time * 4.2);
#region Transform setup
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
// Camera
GL.MatrixMode(MatrixMode.Modelview);
Matrix4 mv = Matrix4.LookAt(EyePosition, Vector3.Zero, Vector3.UnitY);
GL.LoadMatrix(ref mv);
GL.Translate(0f, 0f, CameraZoom);
GL.Rotate(CameraRotX, Vector3.UnitY);
GL.Rotate(CameraRotY, Vector3.UnitX);
#endregion Transform setup
RenderCsg();
// ---------------------------------
if (ShowDebugWireFrame)
{
GL.Color3(System.Drawing.Color.LightGray);
GL.Disable(EnableCap.StencilTest);
GL.Disable(EnableCap.Lighting);
//GL.Disable( EnableCap.DepthTest );
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
DrawOperandB();
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.StencilTest);
}
this.SwapBuffers();
}
[STAThread]
static void Main()
{
using (StencilCSG example = new StencilCSG())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
}
}

View file

@ -1,265 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial
{
[Example("Text Rendering (2D)", ExampleCategory.OpenGL, "1.x", Documentation = "TextRendering")]
class TextRendering : GameWindow
{
TextRenderer renderer;
Font serif = new Font(FontFamily.GenericSerif, 24);
Font sans = new Font(FontFamily.GenericSansSerif, 24);
Font mono = new Font(FontFamily.GenericMonospace, 24);
/// <summary>
/// Uses System.Drawing for 2d text rendering.
/// </summary>
public class TextRenderer : IDisposable
{
Bitmap bmp;
Graphics gfx;
int texture;
Rectangle dirty_region;
bool disposed;
#region Constructors
/// <summary>
/// Constructs a new instance.
/// </summary>
/// <param name="width">The width of the backing store in pixels.</param>
/// <param name="height">The height of the backing store in pixels.</param>
public TextRenderer(int width, int height)
{
if (width <= 0)
throw new ArgumentOutOfRangeException("width");
if (height <= 0)
throw new ArgumentOutOfRangeException("height ");
if (GraphicsContext.CurrentContext == null)
throw new InvalidOperationException("No GraphicsContext is current on the calling thread.");
bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
gfx = Graphics.FromImage(bmp);
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
texture = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, texture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0,
PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
}
#endregion
#region Public Members
/// <summary>
/// Clears the backing store to the specified color.
/// </summary>
/// <param name="color">A <see cref="System.Drawing.Color"/>.</param>
public void Clear(Color color)
{
gfx.Clear(color);
dirty_region = new Rectangle(0, 0, bmp.Width, bmp.Height);
}
/// <summary>
/// Draws the specified string to the backing store.
/// </summary>
/// <param name="text">The <see cref="System.String"/> to draw.</param>
/// <param name="font">The <see cref="System.Drawing.Font"/> that will be used.</param>
/// <param name="brush">The <see cref="System.Drawing.Brush"/> that will be used.</param>
/// <param name="point">The location of the text on the backing store, in 2d pixel coordinates.
/// The origin (0, 0) lies at the top-left corner of the backing store.</param>
public void DrawString(string text, Font font, Brush brush, PointF point)
{
gfx.DrawString(text, font, brush, point);
SizeF size = gfx.MeasureString(text, font);
dirty_region = Rectangle.Round(RectangleF.Union(dirty_region, new RectangleF(point, size)));
dirty_region = Rectangle.Intersect(dirty_region, new Rectangle(0, 0, bmp.Width, bmp.Height));
}
/// <summary>
/// Gets a <see cref="System.Int32"/> that represents an OpenGL 2d texture handle.
/// The texture contains a copy of the backing store. Bind this texture to TextureTarget.Texture2d
/// in order to render the drawn text on screen.
/// </summary>
public int Texture
{
get
{
UploadBitmap();
return texture;
}
}
#endregion
#region Private Members
// Uploads the dirty regions of the backing store to the OpenGL texture.
void UploadBitmap()
{
if (dirty_region != RectangleF.Empty)
{
System.Drawing.Imaging.BitmapData data = bmp.LockBits(dirty_region,
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.BindTexture(TextureTarget.Texture2D, texture);
GL.TexSubImage2D(TextureTarget.Texture2D, 0,
dirty_region.X, dirty_region.Y, dirty_region.Width, dirty_region.Height,
PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
dirty_region = Rectangle.Empty;
}
}
#endregion
#region IDisposable Members
void Dispose(bool manual)
{
if (!disposed)
{
if (manual)
{
bmp.Dispose();
gfx.Dispose();
if (GraphicsContext.CurrentContext != null)
GL.DeleteTexture(texture);
}
disposed = true;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~TextRenderer()
{
Console.WriteLine("[Warning] Resource leaked: {0}.", typeof(TextRenderer));
}
#endregion
}
#region Constructor
public TextRendering()
: base(800, 600)
{
}
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
renderer = new TextRenderer(Width, Height);
PointF position = PointF.Empty;
renderer.Clear(Color.MidnightBlue);
renderer.DrawString("The quick brown fox jumps over the lazy dog", serif, Brushes.White, position);
position.Y += serif.Height;
renderer.DrawString("The quick brown fox jumps over the lazy dog", sans, Brushes.White, position);
position.Y += sans.Height;
renderer.DrawString("The quick brown fox jumps over the lazy dog", mono, Brushes.White, position);
position.Y += mono.Height;
}
#endregion
#region OnUnload
protected override void OnUnload(EventArgs e)
{
renderer.Dispose();
}
#endregion
#region OnResize
protected override void OnResize(EventArgs e)
{
GL.Viewport(ClientRectangle);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
}
#endregion
#region OnUpdateFrame
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
}
#endregion
#region OnRenderFrame
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, renderer.Texture);
GL.Begin(PrimitiveType.Quads);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1f, -1f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1f, -1f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1f, 1f);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1f, 1f);
GL.End();
SwapBuffers();
}
#endregion
#region Main
public static void Main()
{
using (TextRendering example = new TextRendering())
{
Utilities.SetWindowTitle(example);
example.Run(30.0);
}
}
#endregion
}
}

View file

@ -1,175 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
[Example("Texture Matrix Wormhole", ExampleCategory.OpenGL, "1.x", Documentation = "TextureMatrix")]
class TextureMatrix : GameWindow
{
Vector2 orientation;
public TextureMatrix()
: base(800, 600, new GraphicsMode(32, 16, 0, 4))
{
VSync = VSyncMode.On;
}
int Texture;
int list;
protected override void OnLoad(EventArgs e)
{
GL.ClearColor(0f, 0f, 0f, 0f);
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.CullFace);
Texture = LoadTexture("Data/Textures/logo-dark.jpg");
GL.Enable(EnableCap.Texture2D);
list = GL.GenLists(1);
GL.NewList(list, ListMode.Compile);
{
const int slices = 32;
const float distance = 0.25f;
GL.Begin(PrimitiveType.Quads);
for (float scale = 0.26f; scale < 5f; scale += distance)
for (int i = 0; i < slices; i++)
{
Vector3 MiddleCenter = new Vector3((float)(Math.Sin((double)i / slices * 2 * Math.PI) * scale),
(float)(Math.Cos((double)i / slices * 2 * Math.PI) * scale),
(float)(1f / scale));
Vector3 MiddleRight = new Vector3((float)(Math.Sin((double)(i + 1) / slices * 2 * Math.PI) * scale),
(float)(Math.Cos((double)(i + 1) / slices * 2 * Math.PI) * scale),
(float)(1f / scale));
Vector3 BottomRight = new Vector3((float)(Math.Sin((double)(i + 1) / slices * 2 * Math.PI) * (scale - distance)),
(float)(Math.Cos((double)(i + 1) / slices * 2 * Math.PI) * (scale - distance)),
(float)(1f / (scale - distance)));
Vector3 BottomCenter = new Vector3((float)(Math.Sin((double)i / slices * 2 * Math.PI) * (scale - distance)),
(float)(Math.Cos((double)i / slices * 2 * Math.PI) * (scale - distance)),
(float)(1f / (scale - distance)));
GL.TexCoord2(1f, 0f);
GL.Vertex3(MiddleCenter);
GL.TexCoord2(0f, 0f);
GL.Vertex3(MiddleRight);
GL.TexCoord2(0f, 1f);
GL.Vertex3(BottomRight);
GL.TexCoord2(1f, 1f);
GL.Vertex3(BottomCenter);
}
GL.End();
}
GL.EndList();
}
protected override void OnResize(EventArgs e)
{
GL.Viewport(this.ClientRectangle);
Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 1.0f, 50.0f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
var mouse = OpenTK.Input.Mouse.GetState();
orientation = new Vector2(mouse.X, mouse.Y);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit |
ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Texture);
GL.Translate(e.Time / 2, -e.Time, 0f);
Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref modelview);
GL.Translate(0f, 0f, 1.5f);
GL.Rotate(orientation.X, Vector3.UnitY);
GL.Rotate(orientation.Y, Vector3.UnitX);
GL.BindTexture(TextureTarget.Texture2D, Texture);
GL.CallList(list);
SwapBuffers();
}
public static int LoadTexture(string filename)
{
TextureTarget Target = TextureTarget.Texture2D;
int texture;
GL.GenTextures(1, out texture);
GL.BindTexture(Target, texture);
Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
Version target = new Version(1, 4);
if (version >= target)
{
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);
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.Finish();
bitmap.UnlockBits(data);
if (GL.GetError() != ErrorCode.NoError)
throw new Exception("Error loading texture " + filename);
return texture;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using (TextureMatrix example = new TextureMatrix())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.Run(30.0, 0.0);
}
}
}
}

View file

@ -1,151 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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
{
/// <summary>
/// Demonstrates simple OpenGL Texturing.
/// </summary>
[Example("Texture mapping", ExampleCategory.OpenGL, "1.x", 5, Documentation = "Textures")]
public class Textures : GameWindow
{
Bitmap bitmap = new Bitmap("Data/Textures/logo.jpg");
int texture;
public Textures() : base(800, 600) { }
#region OnLoad
/// <summary>
/// Setup OpenGL and load resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.Texture2D);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
GL.GenTextures(1, out texture);
GL.BindTexture(TextureTarget.Texture2D, texture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bitmap.UnlockBits(data);
}
#endregion
#region OnUnload
protected override void OnUnload(EventArgs e)
{
GL.DeleteTextures(1, ref texture);
}
#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)
{
GL.Viewport(0, 0, Width, Height);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
}
#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)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
}
#endregion
#region OnRenderFrame
/// <summary>
/// Add your game rendering code here.
/// </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)
{
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.BindTexture(TextureTarget.Texture2D, texture);
GL.Begin(PrimitiveType.Quads);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-0.6f, -0.4f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(0.6f, -0.4f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(0.6f, 0.4f);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-0.6f, 0.4f);
GL.End();
SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (Textures example = new Textures())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)typeof(Textures).GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,212 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples.Tutorial
{
[Example("VBO Dynamic", ExampleCategory.OpenGL, "1.x", 4, Documentation = "VBODynamic")]
class T09_VBO_Dynamic : GameWindow
{
/// <summary>Creates a 800x600 window with the specified title.</summary>
public T09_VBO_Dynamic()
: base(800, 600)
{
this.VSync = VSyncMode.Off;
}
#region Particles
static int MaxParticleCount = 2000;
int VisibleParticleCount;
VertexC4ubV3f[] VBO = new VertexC4ubV3f[MaxParticleCount];
ParticleAttribut[] ParticleAttributes = new ParticleAttribut[MaxParticleCount];
// this struct is used for drawing
struct VertexC4ubV3f
{
public byte R, G, B, A;
public Vector3 Position;
public static int SizeInBytes = 16;
}
// this struct is used for updates
struct ParticleAttribut
{
public Vector3 Direction;
public uint Age;
// more stuff could be here: Rotation, Radius, whatever
}
uint VBOHandle;
#endregion Particles
/// <summary>Load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
Version target = new Version(1, 5);
if (version < target)
{
throw new NotSupportedException(String.Format(
"OpenGL {0} is required (you only have {1}).", target, version));
}
GL.ClearColor(.1f, 0f, .1f, 0f);
GL.Enable(EnableCap.DepthTest);
// Setup parameters for Points
GL.PointSize(5f);
GL.Enable(EnableCap.PointSmooth);
GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
// Setup VBO state
GL.EnableClientState(ArrayCap.ColorArray);
GL.EnableClientState(ArrayCap.VertexArray);
GL.GenBuffers(1, out VBOHandle);
// Since there's only 1 VBO in the app, might aswell setup here.
GL.BindBuffer(BufferTarget.ArrayBuffer, VBOHandle);
GL.ColorPointer(4, ColorPointerType.UnsignedByte, VertexC4ubV3f.SizeInBytes, (IntPtr)0);
GL.VertexPointer(3, VertexPointerType.Float, VertexC4ubV3f.SizeInBytes, (IntPtr)(4 * sizeof(byte)));
Random rnd = new Random();
Vector3 temp = Vector3.Zero;
// generate some random stuff for the particle system
for (uint i = 0; i < MaxParticleCount; i++)
{
VBO[i].R = (byte)rnd.Next(0, 256);
VBO[i].G = (byte)rnd.Next(0, 256);
VBO[i].B = (byte)rnd.Next(0, 256);
VBO[i].A = (byte)rnd.Next(0, 256); // isn't actually used
VBO[i].Position = Vector3.Zero; // all particles are born at the origin
// generate direction vector in the range [-0.25f...+0.25f]
// that's slow enough so you can see particles 'disappear' when they are respawned
temp.X = (float)((rnd.NextDouble() - 0.5) * 0.5f);
temp.Y = (float)((rnd.NextDouble() - 0.5) * 0.5f);
temp.Z = (float)((rnd.NextDouble() - 0.5) * 0.5f);
ParticleAttributes[i].Direction = temp; // copy
ParticleAttributes[i].Age = 0;
}
VisibleParticleCount = 0;
}
protected override void OnUnload(EventArgs e)
{
GL.DeleteBuffers(1, ref VBOHandle);
}
/// <summary>
/// Called when your window is resized. Set your viewport here. It is also
/// a good place to set up your projection matrix (which probably changes
/// along when the aspect ratio of your window).
/// </summary>
/// <param name="e">Contains information on the new Width and Size of the GameWindow.</param>
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
GL.MatrixMode(MatrixMode.Projection);
Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 50.0f);
GL.LoadMatrix(ref p);
GL.MatrixMode(MatrixMode.Modelview);
Matrix4 mv = Matrix4.LookAt(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY);
GL.LoadMatrix(ref mv);
}
/// <summary>
/// Called when it is time to setup the next frame. Add you game logic here.
/// </summary>
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
{
Exit();
}
// will update particles here. When using a Physics SDK, it's update rate is much higher than
// the framerate and it would be a waste of cycles copying to the VBO more often than drawing it.
if (VisibleParticleCount < MaxParticleCount)
VisibleParticleCount++;
Vector3 temp;
for (int i = MaxParticleCount - VisibleParticleCount; i < MaxParticleCount; i++)
{
if (ParticleAttributes[i].Age >= MaxParticleCount)
{
// reset particle
ParticleAttributes[i].Age = 0;
VBO[i].Position = Vector3.Zero;
}
else
{
ParticleAttributes[i].Age += (uint)Math.Max(ParticleAttributes[i].Direction.LengthFast * 10, 1);
Vector3.Multiply(ref ParticleAttributes[i].Direction, (float)e.Time, out temp);
Vector3.Add(ref VBO[i].Position, ref temp, out VBO[i].Position);
}
}
}
/// <summary>
/// Called when it is time to render the next frame. Add your rendering code here.
/// </summary>
/// <param name="e">Contains timing information.</param>
protected override void OnRenderFrame(FrameEventArgs e)
{
this.Title = VisibleParticleCount + " Points. FPS: " + string.Format("{0:F}", 1.0 / e.Time);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.PushMatrix();
GL.Translate(0f, 0f, -5f);
// Tell OpenGL to discard old VBO when done drawing it and reserve memory _now_ for a new buffer.
// without this, GL would wait until draw operations on old VBO are complete before writing to it
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(VertexC4ubV3f.SizeInBytes * MaxParticleCount), IntPtr.Zero, BufferUsageHint.StreamDraw);
// Fill newly allocated buffer
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(VertexC4ubV3f.SizeInBytes * MaxParticleCount), VBO, BufferUsageHint.StreamDraw);
// Only draw particles that are alive
GL.DrawArrays(PrimitiveType.Points, MaxParticleCount - VisibleParticleCount, VisibleParticleCount);
GL.PopMatrix();
SwapBuffers();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// The 'using' idiom guarantees proper resource cleanup.
// We request 30 UpdateFrame events per second, and unlimited
// RenderFrame events (as fast as the computer can handle).
using (T09_VBO_Dynamic example = new T09_VBO_Dynamic())
{
Utilities.SetWindowTitle(example);
example.Run(60.0, 0.0);
}
}
}
}

View file

@ -1,178 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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;
using System.Drawing;
#endregion
namespace Examples.Tutorial
{
[Example("VBO Static", ExampleCategory.OpenGL, "1.x", 3, Documentation = "VBOStatic")]
public class T08_VBO : GameWindow
{
const float rotation_speed = 180.0f;
float angle;
struct Vbo { public int VboID, EboID, NumElements; }
Vbo[] vbo = new Vbo[2];
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 T08_VBO() : base(800, 600) { }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
Version target = new Version(1, 5);
if (version < target)
{
throw new NotSupportedException(String.Format(
"OpenGL {0} is required (you only have {1}).", target, version));
}
GL.ClearColor(System.Drawing.Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
vbo[0] = LoadVBO(CubeVertices, CubeElements);
vbo[1] = LoadVBO(CubeVertices, CubeElements);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
angle += rotation_speed * (float)e.Time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
Draw(vbo[0]);
SwapBuffers();
}
Vbo LoadVBO<TVertex>(TVertex[] vertices, short[] elements) where TVertex : struct
{
Vbo handle = new Vbo();
int size;
// To create a VBO:
// 1) Generate the buffer handles for the vertex and element buffers.
// 2) Bind the vertex buffer handle and upload your vertex data. Check that the buffer was uploaded correctly.
// 3) Bind the element buffer handle and upload your element data. Check that the buffer was uploaded correctly.
GL.GenBuffers(1, out handle.VboID);
GL.BindBuffer(BufferTarget.ArrayBuffer, handle.VboID);
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * BlittableValueType.StrideOf(vertices)), vertices,
BufferUsageHint.StaticDraw);
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
if (vertices.Length * BlittableValueType.StrideOf(vertices) != size)
throw new ApplicationException("Vertex data not uploaded correctly");
GL.GenBuffers(1, out handle.EboID);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle.EboID);
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(elements.Length * sizeof(short)), elements,
BufferUsageHint.StaticDraw);
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
if (elements.Length * sizeof(short) != size)
throw new ApplicationException("Element data not uploaded correctly");
handle.NumElements = elements.Length;
return handle;
}
void Draw(Vbo handle)
{
// To draw a VBO:
// 1) Ensure that the VertexArray client state is enabled.
// 2) Bind the vertex and element buffer handles.
// 3) Set up the data pointers (vertex, normal, color) according to your vertex format.
// 4) Call DrawElements. (Note: the last parameter is an offset into the element buffer
// and will usually be IntPtr.Zero).
GL.EnableClientState(ArrayCap.ColorArray);
GL.EnableClientState(ArrayCap.VertexArray);
GL.BindBuffer(BufferTarget.ArrayBuffer, handle.VboID);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle.EboID);
GL.VertexPointer(3, VertexPointerType.Float, BlittableValueType.StrideOf(CubeVertices), new IntPtr(0));
GL.ColorPointer(4, ColorPointerType.UnsignedByte, BlittableValueType.StrideOf(CubeVertices), new IntPtr(12));
GL.DrawElements(PrimitiveType.Triangles, handle.NumElements, DrawElementsType.UnsignedShort, IntPtr.Zero);
}
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (T08_VBO example = new T08_VBO())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
}
}

View file

@ -1,205 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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
{
/// <summary>
/// Demonstrates Vertex Arrays (in system memory). Example is incomplete (documentation).
/// Broken since release 0.3.12.
/// </summary>
[Example("Vertex Arrays", ExampleCategory.OpenGL, "1.x", 5, false)]
class T02_Vertex_Arrays : GameWindow
{
float rotation_speed = 3.0f;
float angle = 0.0f;
Shapes.Shape shape = new Examples.Shapes.Plane(16, 16, 2.0f, 2.0f);
//TextureFont sans = new TextureFont(new Font(FontFamily.GenericSansSerif, 32, FontStyle.Regular,
// GraphicsUnit.Pixel));
#region Constructor
public T02_Vertex_Arrays()
: base(800, 600)
{
//this.VSync = VSyncMode.On;
KeyUp += Keyboard_KeyUp;
}
void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
{
// F4 cycles between available VSync modes.
if (e.Key == Key.F4)
{
if (this.VSync == VSyncMode.Off)
this.VSync = VSyncMode.On;
else if (this.VSync == VSyncMode.On)
this.VSync = VSyncMode.Adaptive;
else
this.VSync = VSyncMode.Off;
}
}
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
GL.Enable(EnableCap.Texture2D);
GL.ClearColor(Color.CadetBlue);
GL.Enable(EnableCap.DepthTest);
GL.EnableClientState(ArrayCap.VertexArray);
//GL.EnableClientState(GL.Enums.EnableCap.COLOR_ARRAY);
GL.VertexPointer(3, VertexPointerType.Float, 0, shape.Vertices);
//GL.ColorPointer(4, GL.Enums.ColorPointerType.UNSIGNED_BYTE, 0, shape.Colors);
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
{
this.Exit();
return;
}
if (keyboard[Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;
// Plus/Minus change the target render frequency.
// PageUp/PageDown change the target update frequency.
if (keyboard[Key.Plus] || keyboard[Key.KeypadAdd]) TargetRenderFrequency++;
if (keyboard[Key.Minus] || keyboard[Key.KeypadSubtract]) TargetRenderFrequency--;
if (keyboard[Key.PageUp]) TargetUpdateFrequency++;
if (keyboard[Key.PageDown]) TargetUpdateFrequency--;
// Right/Left control the rotation speed and direction.
if (keyboard[Key.Right]) rotation_speed += 0.5f;
if (keyboard[Key.Left]) rotation_speed -= 0.5f;
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
angle += rotation_speed * (float)e.Time;
if (angle >= 360.0f)
angle -= 360.0f;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
GL.DrawElements(PrimitiveType.Triangles, shape.Indices.Length,
DrawElementsType.UnsignedInt, shape.Indices);
//GL.Begin(GL.Enums.BeginMode.TRIANGLES);
//GL.Vertex3(-1.0, -1.0, 5.0);
//GL.Vertex3(1.0, -1.0, 5.0);
//GL.Vertex3(1.0, 1.0, 5.0);
//GL.End();
GL.PushMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
//GL.Translate(0.7f, 1.0f, 0.0f);
//sans.Print(String.format("{0:f1}", RenderFrequency));
GL.PopMatrix();
SwapBuffers();
}
#endregion
#region public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
public void Launch()
{
// Lock UpdateFrame rate at 30Hz and RenderFrame rate 85Hz.
//Run(60.0, 85.0);
Run(30.0, 85.0);
}
#endregion
public static readonly int order = 2;
}
}

View file

@ -1,181 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using Examples.Shapes;
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation).
/// </summary>
[Example("Vertex Lighting", ExampleCategory.OpenGL, "1.x", false)]
public class T04_Vertex_Lighting : GameWindow
{
float x_angle, zoom;
Shape shape = new Plane(16, 16, 4.0f, 4.0f);
#region Constructor
public T04_Vertex_Lighting() : base(800, 600)
{
}
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
//GL.Enable(GL.Enums.EnableCap.CULL_FACE);
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.NormalArray);
GL.VertexPointer(3, VertexPointerType.Float, 0, shape.Vertices);
GL.NormalPointer(NormalPointerType.Float, 0, shape.Normals);
// Enable Light 0 and set its parameters.
GL.Light(LightName.Light0, LightParameter.Position, new float[] { 1.0f, 1.0f, -0.5f });
GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0.3f, 0.3f, 0.3f, 1.0f });
GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Light(LightName.Light0, LightParameter.SpotExponent, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.LightModel(LightModelParameter.LightModelAmbient, new float[] { 0.2f, 0.2f, 0.2f, 1.0f });
GL.LightModel(LightModelParameter.LightModelTwoSide, 1);
GL.LightModel(LightModelParameter.LightModelLocalViewer, 1);
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.Light0);
// Use GL.Material to set your object's material parameters.
GL.Material(MaterialFace.Front, MaterialParameter.Ambient, new float[] { 0.3f, 0.3f, 0.3f, 1.0f });
GL.Material(MaterialFace.Front, MaterialParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Material(MaterialFace.Front, MaterialParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Material(MaterialFace.Front, MaterialParameter.Emission, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
var mouse = OpenTK.Input.Mouse.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
}
if (keyboard[OpenTK.Input.Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;
if (mouse[OpenTK.Input.MouseButton.Left])
x_angle = mouse.X;
else
x_angle += 0.5f;
zoom = mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows.
// Do not leave x_angle drift too far away, as this will cause inaccuracies.
if (x_angle > 360.0f)
x_angle -= 360.0f;
else if (x_angle < -360.0f)
x_angle += 360.0f;
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 lookat = Matrix4.LookAt(0, 0, -7.5f + zoom, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
GL.Rotate(x_angle, 0.0f, 1.0f, 0.0f);
GL.Begin(PrimitiveType.Triangles);
foreach (int index in shape.Indices)
{
GL.Normal3(shape.Normals[index]);
GL.Vertex3(shape.Vertices[index]);
}
GL.End();
SwapBuffers();
}
#endregion
#region public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
public static void Main()
{
using (T04_Vertex_Lighting example = new T04_Vertex_Lighting())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,273 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using System.IO;
using System.Text;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Examples.Shapes;
using Examples.TextureLoaders;
namespace Examples.Tutorial
{
[Example("DDS Cube Map", ExampleCategory.OpenGL, "2.x", Documentation = "DDSCubeMap")]
public class T13_GLSL_Earth: GameWindow
{
public T13_GLSL_Earth( )
: base( 800, 800 )
{
}
#region internal Fields
// Shader
int VertexShaderObject, FragmentShaderObject, ProgramObject;
const string VertexShaderFilename = "Data/Shaders/CubeMap_VS.glsl";
const string FragmentShaderFilename = "Data/Shaders/CubeMap_FS.glsl";
// Textures
const TextureUnit TMU0_Unit = TextureUnit.Texture0;
const int TMU0_UnitInteger = 0;
const string TMU0_Filename = "Data/Textures/earth-cubemap.dds";
uint TMU0_Handle;
TextureTarget TMU0_Target;
// DL
DrawableShape sphere;
// Camera
Vector3 EyePos = new Vector3( 0.0f, 0.0f, 6.0f );
Vector3 Trackball = Vector3.Zero;
#endregion internal Fields
/// <summary>Setup OpenGL and load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
this.VSync = VSyncMode.Off;
// Check for necessary capabilities:
string extensions = GL.GetString(StringName.Extensions);
if (!GL.GetString(StringName.Extensions).Contains("GL_ARB_shading_language"))
{
throw new NotSupportedException(String.Format("This example requires OpenGL 2.0. Found {0}. Aborting.",
GL.GetString(StringName.Version).Substring(0, 3)));
}
if (!extensions.Contains("GL_ARB_texture_compression") ||
!extensions.Contains("GL_EXT_texture_compression_s3tc"))
{
throw new NotSupportedException("This example requires support for texture compression. Aborting.");
}
#region GL State
GL.ClearColor( 0f, 0f, 0f, 0f );
GL.Disable( EnableCap.Dither );
GL.Enable( EnableCap.CullFace );
GL.FrontFace( FrontFaceDirection.Ccw );
GL.PolygonMode( MaterialFace.Front, PolygonMode.Fill );
// GL.PolygonMode( MaterialFace.Back, PolygonMode.Line );
#endregion GL State
#region Shaders
string LogInfo;
// Load&Compile Vertex Shader
using ( StreamReader sr = new StreamReader( VertexShaderFilename ) )
{
VertexShaderObject = GL.CreateShader( ShaderType.VertexShader );
GL.ShaderSource( VertexShaderObject, sr.ReadToEnd( ) );
GL.CompileShader( VertexShaderObject );
}
GL.GetShaderInfoLog( VertexShaderObject, out LogInfo );
if ( LogInfo.Length > 0 && !LogInfo.Contains( "hardware" ) )
Trace.WriteLine( "Vertex Shader failed!\nLog:\n" + LogInfo );
else
Trace.WriteLine( "Vertex Shader compiled without complaint." );
// Load&Compile Fragment Shader
using ( StreamReader sr = new StreamReader( FragmentShaderFilename ) )
{
FragmentShaderObject = GL.CreateShader( ShaderType.FragmentShader );
GL.ShaderSource( FragmentShaderObject, sr.ReadToEnd( ) );
GL.CompileShader( FragmentShaderObject );
}
GL.GetShaderInfoLog( FragmentShaderObject, out LogInfo );
if ( LogInfo.Length > 0 && !LogInfo.Contains( "hardware" ) )
Trace.WriteLine( "Fragment Shader failed!\nLog:\n" + LogInfo );
else
Trace.WriteLine( "Fragment Shader compiled without complaint." );
// Link the Shaders to a usable Program
ProgramObject = GL.CreateProgram( );
GL.AttachShader( ProgramObject, VertexShaderObject );
GL.AttachShader( ProgramObject, FragmentShaderObject );
// link it all together
GL.LinkProgram( ProgramObject );
// flag ShaderObjects for delete when not used anymore
GL.DeleteShader( VertexShaderObject );
GL.DeleteShader( FragmentShaderObject );
int[] temp = new int[1];
GL.GetProgram(ProgramObject, GetProgramParameterName.LinkStatus, out temp[0]);
Trace.WriteLine( "Linking Program (" + ProgramObject + ") " + ( ( temp[0] == 1 ) ? "succeeded." : "FAILED!" ) );
if ( temp[0] != 1 )
{
GL.GetProgramInfoLog( ProgramObject, out LogInfo );
Trace.WriteLine( "Program Log:\n" + LogInfo );
}
GL.GetProgram(ProgramObject, GetProgramParameterName.ActiveAttributes, out temp[0]);
Trace.WriteLine( "Program registered " + temp[0] + " Attributes. (Should be 4: Pos, UV, Normal, Tangent)" );
Trace.WriteLine( "Tangent attribute bind location: " + GL.GetAttribLocation( ProgramObject, "AttributeTangent" ) );
Trace.WriteLine( "End of Shader build. GL Error: " + GL.GetError( ) );
#endregion Shaders
#region Textures
TextureLoaderParameters.FlipImages = false;
TextureLoaderParameters.MagnificationFilter = TextureMagFilter.Linear;
TextureLoaderParameters.MinificationFilter = TextureMinFilter.Linear;
TextureLoaderParameters.WrapModeS = TextureWrapMode.ClampToEdge;
TextureLoaderParameters.WrapModeT = TextureWrapMode.ClampToEdge;
TextureLoaderParameters.EnvMode = TextureEnvMode.Modulate;
ImageDDS.LoadFromDisk( TMU0_Filename, out TMU0_Handle, out TMU0_Target );
Trace.WriteLine( "Loaded " + TMU0_Filename + " with handle " + TMU0_Handle + " as " + TMU0_Target );
#endregion Textures
Trace.WriteLine( "End of Texture Loading. GL Error: " + GL.GetError( ) );
Trace.WriteLine( "");
sphere = new SlicedSphere(1.5f, Vector3d.Zero, SlicedSphere.eSubdivisions.Four, new SlicedSphere.eDir[] { SlicedSphere.eDir.All }, true);
}
protected override void OnUnload(EventArgs e)
{
sphere.Dispose();
GL.DeleteProgram( ProgramObject );
GL.DeleteTextures( 1, ref TMU0_Handle );
base.OnUnload( e );
}
/// <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 )
{
GL.Viewport( 0, 0, Width, Height );
GL.MatrixMode( MatrixMode.Projection );
Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 10.0f);
GL.LoadMatrix(ref p);
GL.MatrixMode( MatrixMode.Modelview );
GL.LoadIdentity( );
base.OnResize( e );
}
/// <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)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
var mouse = OpenTK.Input.Mouse.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
if (keyboard[OpenTK.Input.Key.Space])
Trace.WriteLine("GL: " + GL.GetError());
Trackball.X = mouse.X;
Trackball.Y = mouse.Y;
Trackball.Z = mouse.Scroll.Y * 0.5f;
}
/// <summary>Add your game rendering code here.</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)
{
this.Title = "FPS: " + (1 / e.Time).ToString("0.");
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.UseProgram(ProgramObject);
#region Textures
GL.ActiveTexture(TMU0_Unit);
GL.BindTexture(TMU0_Target, TMU0_Handle);
#endregion Textures
#region Uniforms
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "Earth"), TMU0_UnitInteger);
#endregion Uniforms
GL.PushMatrix();
Matrix4 temp = Matrix4.LookAt(EyePos, Vector3.Zero, Vector3.UnitY);
GL.MultMatrix(ref temp);
GL.Rotate(Trackball.X, Vector3.UnitY);
GL.Rotate(Trackball.Y, Vector3.UnitX);
#region Draw
GL.Color3(1f, 1f, 1f);
sphere.Draw();
#endregion Draw
GL.PopMatrix();
this.SwapBuffers();
}
/// <summary>Entry point</summary>
[STAThread]
public static void Main( )
{
using ( T13_GLSL_Earth example = new T13_GLSL_Earth( ) )
{
Utilities.SetWindowTitle(example);
example.Run( 30.0, 0.0 );
}
}
}
}

View file

@ -1,246 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Drawing;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial
{
[Example("Basic Geometry Shader", ExampleCategory.OpenGL, "2.x", Documentation = "Simple usage of EXT_geometry_shader4")]
public class SimpleGeometryShader : GameWindow
{
public SimpleGeometryShader()
: base(800, 600)
{
}
int shaderProgram = 0;
protected override void OnLoad(EventArgs e)
{
if (!GL.GetString(StringName.Extensions).Contains("EXT_geometry_shader4"))
{
System.Windows.Forms.MessageBox.Show(
"Your video card does not support EXT_geometry_shader4. Please update your drivers.",
"EXT_geometry_shader4 not supported",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
Exit();
throw new NotSupportedException();
}
// create a shader object.
shaderProgram = GL.CreateProgram();
// create shader objects for all three types.
int vert = GL.CreateShader(ShaderType.VertexShader);
int frag = GL.CreateShader(ShaderType.FragmentShader);
int geom = GL.CreateShader(ShaderType.GeometryShaderExt);
// GLSL for fragment shader.
String fragSource = @"
void main( void )
{
gl_FragColor = vec4(0, 1, 0, 0);
}
";
// GLSL for vertex shader.
String vertSource = @"
void main( void )
{
gl_Position = ftransform();
}
";
// GLSL for geometry shader.
// Note this is a version 1.20 shader
// Also note GL_EXT_geometry_shader4 must be enabled explicitly, correct
// OpenGL implementations should only have the new tokens, like
// EmitVertex and EndPrimitive, when this extension is enabled.
String geomSource = @"
#version 120
#extension GL_EXT_geometry_shader4 : enable
void main(void)
{
// variable to use in for loops
int i;
// Emit the original vertices without changing, making
// this part exactly the same as if no geometry shader
// was used.
for(i=0; i< gl_VerticesIn; i++)
{
gl_Position = gl_PositionIn[i];
EmitVertex();
}
// End the one primitive with the original vertices
EndPrimitive();
// Now we generate some more! This translates 0.2 over
// the positive x axis.
for(i=0; i< gl_VerticesIn; i++)
{
gl_Position = gl_PositionIn[i];
gl_Position.x += 0.2;
EmitVertex();
}
EndPrimitive();
}
";
// compile shaders.
compileShader(frag, fragSource);
compileShader(vert, vertSource);
compileShader(geom, geomSource);
// attach shaders and link the program.
GL.AttachShader(shaderProgram, frag);
GL.AttachShader(shaderProgram, vert);
GL.AttachShader(shaderProgram, geom);
// Set the input type of the primitives we are going to feed the geometry shader, this should be the same as
// the primitive type given to GL.Begin. If the types do not match a GL error will occur (todo: verify GL_INVALID_ENUM, on glBegin)
GL.Ext.ProgramParameter(shaderProgram, AssemblyProgramParameterArb.GeometryInputType, (int)BeginMode.Lines);
// Set the output type of the geometry shader. Becasue we input Lines we will output LineStrip(s).
GL.Ext.ProgramParameter(shaderProgram, AssemblyProgramParameterArb.GeometryOutputType, (int)BeginMode.LineStrip);
// We must tell the shader program how much vertices the geometry shader will output (at most).
// One simple way is to query the maximum and use that.
// NOTE: Make sure that the number of vertices * sum(components of active varyings) does not
// exceed MaxGeometryTotalOutputComponents.
GL.Ext.ProgramParameter(shaderProgram, AssemblyProgramParameterArb.GeometryVerticesOut, 50);
// NOTE: calls to ProgramParameter do not take effect until you call LinkProgram.
GL.LinkProgram(shaderProgram);
// output link info log.
string info;
GL.GetProgramInfoLog(shaderProgram, out info);
Debug.WriteLine(info);
// Set clearcolor and bind the shader program.
GL.ClearColor(0.1f, 0.1f, 0.1f, 0.1f);
GL.UseProgram(shaderProgram);
// Set color to red. If the shader fails the fixed pipeline will be used and
// the lines will be red, if all is ok the fragment shader is used and they will be green.
GL.Color3(1.0f, 0, 0);
// Clean up resources. Note the program object is not deleted.
if (frag != 0)
GL.DeleteShader(frag);
if (vert != 0)
GL.DeleteShader(vert);
if (geom != 0)
GL.DeleteShader(geom);
}
/// <summary>
/// Helper method to avoid code duplication.
/// Compiles a shader and prints results using Debug.WriteLine.
/// </summary>
/// <param name="shader">A shader object, gotten from GL.CreateShader.</param>
/// <param name="source">The GLSL source to compile.</param>
void compileShader(int shader, string source)
{
GL.ShaderSource(shader, source);
GL.CompileShader(shader);
string info;
GL.GetShaderInfoLog(shader, out info);
Debug.WriteLine(info);
int compileResult;
GL.GetShader(shader, ShaderParameter.CompileStatus, out compileResult);
if (compileResult != 1)
{
Debug.WriteLine("Compile Error!");
Debug.WriteLine(source);
}
}
protected override void OnUnload(EventArgs e)
{
if (shaderProgram != 0)
GL.DeleteProgram(shaderProgram);
base.OnUnload(e);
}
/// <summary>
/// Sets the viewport and projection matrix for orthographic projection.
/// </summary>
/// <param name="e">resize event args</param>
protected override void OnResize(EventArgs e)
{
GL.Viewport(ClientRectangle);
// Set projection matrix
GL.MatrixMode(MatrixMode.Projection);
OpenTK.Matrix4 ortho = OpenTK.Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, 1, -1);
GL.LoadMatrix(ref ortho);
// Set selector state back to matrix mode
GL.MatrixMode(MatrixMode.Modelview);
base.OnResize(e);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Space])
{
ErrorCode err = GL.GetError();
//Console.WriteLine(err + " " + Glu.ErrorString((GluErrorCode)err));
Console.WriteLine("GL error code: {0}", err);
}
if (keyboard[Key.Escape])
this.Exit();
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
// draw two vertical lines
GL.Begin(PrimitiveType.Lines);
{
// line one
GL.Vertex2(-0.5f, -0.5f);
GL.Vertex2(-0.5f, 0.5f);
// line two
GL.Vertex2(0.5f, 0.5f);
GL.Vertex2(0.5f, -0.5f);
}
GL.End();
this.SwapBuffers();
}
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (SimpleGeometryShader example = new SimpleGeometryShader())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,307 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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;
using OpenTK.Input;
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates how to render an animated Julia Set in real-time. Quality is sacrificed for speed.
/// Info about the fractal: http://en.wikipedia.org/wiki/Julia_set
/// 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.
/// </summary>
[Example("Julia Set Fractal", ExampleCategory.OpenGL, "2.x", Documentation = "JuliaSetFractal")]
public class JuliaSetFractal : GameWindow
{
public JuliaSetFractal()
: base(512, 512)
{
}
#region Private Fields
// GLSL Objects
int VertexShaderObject, FragmentShaderObject, ProgramObject;
int TextureObject;
// Julia Variables for animation
float AnimOffsetX = 0.213f; // using non-zero as starting point to make it more interesting
float AnimOffsetY = 0.63f;
const double AnimSpeedX = 0.65; // anim speed scaling is solely used to make the anim more interesting
const double AnimSpeedY = 1.05;
const double AnimCosinusPercent = 0.85f; // scales the cosinus down to 85% to avoid the (boring) borders
float UniformScaleFactorX; // fractal horizontal scaling is only affected by window resize
float UniformScaleFactorY; // fractal vertical scaling is only affected by window resize
float UniformOffsetX = 1.8f; // fractal horizontal offset
float UniformOffsetY = 1.8f; // fractal vertical offset
#endregion private Fields
#region OnLoad
/// <summary>
/// Setup OpenGL and load resources here.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Check for necessary capabilities:
Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
Version target = new Version(2, 0);
if (version < target)
{
throw new NotSupportedException(String.Format(
"OpenGL {0} is required (you only have {1}).", target, version));
}
this.VSync = VSyncMode.On;
GL.Disable(EnableCap.Dither);
GL.ClearColor(0.2f, 0f, 0.4f, 0f);
// declare some variables for tracking which shader did compile, and which texture to use
string[] ShaderFilenames = new string[2];
ShaderFilenames[0] = "Data/Shaders/JuliaSet_SM3_FS.glsl";
ShaderFilenames[1] = "Data/Shaders/JuliaSet_SM2_FS.glsl";
string LogInfo;
int status = 0;
#region Shaders
// Load&Compile Vertex Shader
using (StreamReader sr = new StreamReader("Data/Shaders/JuliaSet_VS.glsl"))
{
VertexShaderObject = GL.CreateShader(ShaderType.VertexShader);
GL.ShaderSource(VertexShaderObject, sr.ReadToEnd());
GL.CompileShader(VertexShaderObject);
}
GL.GetShaderInfoLog(VertexShaderObject, out LogInfo);
if (LogInfo.Length > 0 && !LogInfo.Contains("hardware"))
Trace.WriteLine("Vertex Shader Log:\n" + LogInfo);
else
Trace.WriteLine("Vertex Shader compiled without complaint.");
// Load&Compile Fragment Shader
FragmentShaderObject = GL.CreateShader(ShaderType.FragmentShader);
foreach (var shader in ShaderFilenames)
{
using (StreamReader sr = new StreamReader(shader))
{
GL.ShaderSource(FragmentShaderObject, sr.ReadToEnd());
GL.CompileShader(FragmentShaderObject);
}
GL.GetShader(FragmentShaderObject, ShaderParameter.CompileStatus, out status);
if (status != 1)
{
GL.GetShaderInfoLog(FragmentShaderObject, out LogInfo);
Trace.WriteLine("Compiling " + shader + " failed!\nLog:\n" + LogInfo);
}
else
{
Trace.WriteLine("Fragment Shader compiled without complaint.");
break;
}
}
if (status != 1)
{
MessageBox.Show("Shader compilation failed");
Exit();
}
// Link the Shaders to a usable Program
ProgramObject = GL.CreateProgram();
GL.AttachShader(ProgramObject, VertexShaderObject);
GL.AttachShader(ProgramObject, FragmentShaderObject);
GL.LinkProgram(ProgramObject);
// make current
GL.UseProgram(ProgramObject);
// Flag ShaderObjects for delete when app exits
GL.DeleteShader(VertexShaderObject);
GL.DeleteShader(FragmentShaderObject);
#endregion Shaders
#region Textures
// Load&Bind the 1D texture for color lookups
GL.ActiveTexture(TextureUnit.Texture0); // select TMU0
GL.GenTextures(1, out TextureObject);
GL.TexParameter(TextureTarget.Texture1D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture1D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture1D, TextureParameterName.TextureWrapS, (int)(TextureWrapMode)All.ClampToEdge);
using (Bitmap bitmap = new Bitmap("Data/Textures/JuliaColorTable.bmp"))
{
BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.TexImage1D(TextureTarget.Texture1D, 0, PixelInternalFormat.Rgb8, data.Width, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgr,
PixelType.UnsignedByte, data.Scan0);
bitmap.UnlockBits(data);
}
#endregion Textures
KeyUp += Keyboard_KeyUp;
}
int i = 0;
void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
{
if (e.Key == Key.F12)
{
Bitmap bmp = new Bitmap(this.Width, this.Height);
System.Drawing.Imaging.BitmapData data =
bmp.LockBits(new System.Drawing.Rectangle(0, 0, this.Width, this.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.ReadPixels(0, 0, this.Width, this.Height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgr,
OpenTK.Graphics.OpenGL.PixelType.UnsignedByte,
data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
bmp.Save("Screenshot" + (i++).ToString() + ".png", ImageFormat.Png);
}
}
#endregion
#region OnUnload
protected override void OnUnload(EventArgs e)
{
if (TextureObject != 0)
GL.DeleteTextures(1, ref TextureObject);
if (ProgramObject != 0)
GL.DeleteProgram(ProgramObject); // implies deleting the previously flagged ShaderObjects
}
#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)
{
// Magic numbers so the fractal almost fits inside the window.
// If changing this, also change the -1.6f offset in the fragment shader accordingly.
UniformScaleFactorX = Width / (UniformOffsetX * 2f);
UniformScaleFactorY = Height / (UniformOffsetY * 2f);
GL.Viewport(0, 0, Width, Height);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0); // 2D setup
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
}
#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)
{
base.OnUpdateFrame(e);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
}
#endregion
#region OnRenderFrame
/// <summary>
/// Add your game rendering code here.
/// </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)
{
//this.Title = "FPS: " + 1 / e.Time;
GL.Clear(ClearBufferMask.ColorBufferBit);
// First, render the next frame of the Julia fractal.
GL.UseProgram(ProgramObject);
// advance the animation by elapsed time, scaling is solely used to make the anim more interesting
AnimOffsetX += (float)(e.Time * AnimSpeedX);
AnimOffsetY += (float)(e.Time * AnimSpeedY);
// pass uniforms into the fragment shader
// first the texture
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "COLORTABLE"), TextureObject);
// the rest are floats
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "CETX"), (float)(Math.Cos(AnimOffsetX) * AnimCosinusPercent));
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "CETY"), (float)(Math.Cos(AnimOffsetY) * AnimCosinusPercent));
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "SCALINGX"), UniformScaleFactorX);
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "SCALINGY"), UniformScaleFactorY);
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "OFFSETX"), UniformOffsetX);
GL.Uniform1(GL.GetUniformLocation(ProgramObject, "OFFSETY"), UniformOffsetY);
// Fullscreen quad. Using immediate mode, since this app is fragment shader limited anyways.
GL.Begin(PrimitiveType.Quads);
{
GL.Vertex2(-1.0f, -1.0f);
GL.Vertex2(1.0f, -1.0f);
GL.Vertex2(1.0f, 1.0f);
GL.Vertex2(-1.0f, 1.0f);
}
GL.End();
SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (JuliaSetFractal example = new JuliaSetFractal())
{
Utilities.SetWindowTitle(example);
example.Run(30.0);
}
}
#endregion
}
}

View file

@ -1,293 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
#endregion --- Using Directives ---
namespace Examples.Tutorial
{
/// <summary>
/// Demonstrates how to load and use a simple OpenGL shader program. Example is incomplete (documentation).
/// </summary>
[Example("First shader", ExampleCategory.OpenGL, "2.x", Documentation = "SimpleGLSL")]
public class T10_GLSL_Cube : GameWindow
{
#region --- Fields ---
static float angle = 0.0f, rotation_speed = 3.0f;
int vertex_shader_object, fragment_shader_object, shader_program;
int vertex_buffer_object, color_buffer_object, element_buffer_object;
Shapes.Shape shape = new Examples.Shapes.Cube();
#endregion
#region --- Constructors ---
public T10_GLSL_Cube()
: base(800, 600, GraphicsMode.Default)
{ }
#endregion
#region OnLoad
/// <summary>
/// This is the place to load resources that change little
/// during the lifetime of the GameWindow. In this case, we
/// check for GLSL support, and load the shaders.
/// </summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Check for necessary capabilities:
Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
Version target = new Version(2, 0);
if (version < target)
{
throw new NotSupportedException(String.Format(
"OpenGL {0} is required (you only have {1}).", target, version));
}
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
CreateVBO();
using (StreamReader vs = new StreamReader("Data/Shaders/Simple_VS.glsl"))
using (StreamReader fs = new StreamReader("Data/Shaders/Simple_FS.glsl"))
CreateShaders(vs.ReadToEnd(), fs.ReadToEnd(),
out vertex_shader_object, out fragment_shader_object,
out shader_program);
}
#endregion
#region CreateShaders
void CreateShaders(string vs, string fs,
out int vertexObject, out int fragmentObject,
out int program)
{
int status_code;
string info;
vertexObject = GL.CreateShader(ShaderType.VertexShader);
fragmentObject = GL.CreateShader(ShaderType.FragmentShader);
// Compile vertex shader
GL.ShaderSource(vertexObject, vs);
GL.CompileShader(vertexObject);
GL.GetShaderInfoLog(vertexObject, out info);
GL.GetShader(vertexObject, ShaderParameter.CompileStatus, out status_code);
if (status_code != 1)
throw new ApplicationException(info);
// Compile vertex shader
GL.ShaderSource(fragmentObject, fs);
GL.CompileShader(fragmentObject);
GL.GetShaderInfoLog(fragmentObject, out info);
GL.GetShader(fragmentObject, ShaderParameter.CompileStatus, out status_code);
if (status_code != 1)
throw new ApplicationException(info);
program = GL.CreateProgram();
GL.AttachShader(program, fragmentObject);
GL.AttachShader(program, vertexObject);
GL.LinkProgram(program);
GL.UseProgram(program);
}
#endregion
#region private void CreateVBO()
void CreateVBO()
{
int size;
GL.GenBuffers(1, out vertex_buffer_object);
GL.GenBuffers(1, out color_buffer_object);
GL.GenBuffers(1, out element_buffer_object);
// Upload the vertex buffer.
GL.BindBuffer(BufferTarget.ArrayBuffer, vertex_buffer_object);
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Vertices.Length * 3 * sizeof(float)), shape.Vertices,
BufferUsageHint.StaticDraw);
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
if (size != shape.Vertices.Length * 3 * sizeof(Single))
throw new ApplicationException(String.Format(
"Problem uploading vertex buffer to VBO (vertices). Tried to upload {0} bytes, uploaded {1}.",
shape.Vertices.Length * 3 * sizeof(Single), size));
// Upload the color buffer.
GL.BindBuffer(BufferTarget.ArrayBuffer, color_buffer_object);
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Colors.Length * sizeof(int)), shape.Colors,
BufferUsageHint.StaticDraw);
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
if (size != shape.Colors.Length * sizeof(int))
throw new ApplicationException(String.Format(
"Problem uploading vertex buffer to VBO (colors). Tried to upload {0} bytes, uploaded {1}.",
shape.Colors.Length * sizeof(int), size));
// Upload the index buffer (elements inside the vertex buffer, not color indices as per the IndexPointer function!)
GL.BindBuffer(BufferTarget.ElementArrayBuffer, element_buffer_object);
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(shape.Indices.Length * sizeof(Int32)), shape.Indices,
BufferUsageHint.StaticDraw);
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
if (size != shape.Indices.Length * sizeof(int))
throw new ApplicationException(String.Format(
"Problem uploading vertex buffer to VBO (offsets). Tried to upload {0} bytes, uploaded {1}.",
shape.Indices.Length * sizeof(int), size));
}
#endregion
#region OnUnload
protected override void OnUnload(EventArgs e)
{
if (shader_program != 0)
GL.DeleteProgram(shader_program);
if (fragment_shader_object != 0)
GL.DeleteShader(fragment_shader_object);
if (vertex_shader_object != 0)
GL.DeleteShader(vertex_shader_object);
if (vertex_buffer_object != 0)
GL.DeleteBuffers(1, ref vertex_buffer_object);
if (element_buffer_object != 0)
GL.DeleteBuffers(1, ref element_buffer_object);
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
if (keyboard[OpenTK.Input.Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit |
ClearBufferMask.DepthBufferBit);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
angle += rotation_speed * (float)e.Time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.ColorArray);
GL.BindBuffer(BufferTarget.ArrayBuffer, vertex_buffer_object);
GL.VertexPointer(3, VertexPointerType.Float, 0, IntPtr.Zero);
GL.BindBuffer(BufferTarget.ArrayBuffer, color_buffer_object);
GL.ColorPointer(4, ColorPointerType.UnsignedByte, 0, IntPtr.Zero);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, element_buffer_object);
GL.DrawElements(PrimitiveType.Triangles, shape.Indices.Length,
DrawElementsType.UnsignedInt, IntPtr.Zero);
//GL.DrawArrays(GL.Enums.BeginMode.POINTS, 0, shape.Vertices.Length);
GL.DisableClientState(ArrayCap.VertexArray);
GL.DisableClientState(ArrayCap.ColorArray);
//int error = GL.GetError();
//if (error != 0)
// Debug.Print(Glu.ErrorString(Glu.Enums.ErrorCode.INVALID_OPERATION));
SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (T10_GLSL_Cube example = new T10_GLSL_Cube())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

View file

@ -1,380 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Examples.TextureLoaders;
namespace Examples.Tutorial
{
/// <summary>Demonstrates Swizzled DXT5 Parallax Mapping
/// The idea is described in more detail right here: http://www.opentk.com/node/394
/// </summary>
[Example("Swizzled Parallax Mapping", ExampleCategory.OpenGL, "2.x", Documentation = "SwizzledParallax")]
public class T12_GLSL_Parallax: GameWindow
{
public T12_GLSL_Parallax( )
: base( 800, 600 )
{
}
#region internal Fields
// Shader
int VertexShaderObject, FragmentShaderObject, ProgramObject;
const string VertexShaderFilename = "Data/Shaders/Parallax_VS.glsl";
const string FragmentShaderFilename = "Data/Shaders/Parallax_FS.glsl";
const int AttribTangent = 5; // slot where to pass tangents to VS, not sure which are reserved besides 0
Vector3 Tangent = new Vector3( 1f, 0f, 0f );
Vector3 Normal = new Vector3( 0f, 0f, 1f );
// Material parameter
//Vector3 MaterialScaleAndBiasAndShininess = new Vector3( 0.07f, 0.0f, 38.0f ); // for Metal tex
Vector3 MaterialScaleAndBiasAndShininess = new Vector3( 0.04f, 0.0f, 92.0f ); // for Rock tex
// Textures
const TextureUnit TMU0_Unit = TextureUnit.Texture0;
const int TMU0_UnitInteger = 0;
const string TMU0_Filename = "Data/Textures/swizzled-rock-diffuse-height.dds";
uint TMU0_Handle;
TextureTarget TMU0_Target;
const TextureUnit TMU1_Unit = TextureUnit.Texture1;
const int TMU1_UnitInteger = 1;
const string TMU1_Filename = "Data/Textures/swizzled-rock-normal-gloss.dds";
uint TMU1_Handle;
TextureTarget TMU1_Target;
// Camera
Vector3 EyePos = new Vector3( 0.0f, 0.0f, 3.0f );
// Light
Vector3 LightPosition = new Vector3( 0.0f, 1.0f, 1.0f );
Vector3 LightDiffuse = new Vector3( 0.5f, 0.5f, 0.5f );
Vector3 LightSpecular = new Vector3( 1f, 1f, 1f );
#endregion internal Fields
/// <summary>Setup OpenGL and load resources here.</summary>
/// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e)
{
this.VSync = VSyncMode.Off;
// Check for necessary capabilities:
string extensions = GL.GetString(StringName.Extensions);
if ( !GL.GetString(StringName.Extensions).Contains("GL_ARB_shading_language"))
{
throw new NotSupportedException(String.Format("This example requires OpenGL 2.0. Found {0}. Aborting.",
GL.GetString(StringName.Version).Substring(0, 3)));
}
if (!extensions.Contains("GL_ARB_texture_compression") ||
!extensions.Contains("GL_EXT_texture_compression_s3tc"))
{
throw new NotSupportedException("This example requires support for texture compression. Aborting.");
}
int[] temp = new int[1];
GL.GetInteger( GetPName.MaxTextureImageUnits, out temp[0] );
Trace.WriteLine( temp[0] + " TMU's for Fragment Shaders found. (2 required)" );
GL.GetInteger( GetPName.MaxVaryingFloats, out temp[0] );
Trace.WriteLine( temp[0] + " varying floats between VS and FS allowed. (6 required)" );
GL.GetInteger( GetPName.MaxVertexUniformComponents, out temp[0] );
Trace.WriteLine( temp[0] + " uniform components allowed in Vertex Shader. (6 required)" );
GL.GetInteger( GetPName.MaxFragmentUniformComponents, out temp[0] );
Trace.WriteLine( temp[0] + " uniform components allowed in Fragment Shader. (11 required)" );
Trace.WriteLine("" );
#region GL State
GL.ClearColor( 0.2f, 0f, 0.4f, 0f );
GL.PointSize( 10f );
GL.Disable( EnableCap.Dither );
GL.FrontFace( FrontFaceDirection.Ccw );
GL.PolygonMode( MaterialFace.Front, PolygonMode.Fill );
GL.PolygonMode( MaterialFace.Back, PolygonMode.Line );
#endregion GL State
#region Shaders
string LogInfo;
// Load&Compile Vertex Shader
using ( StreamReader sr = new StreamReader( VertexShaderFilename ) )
{
VertexShaderObject = GL.CreateShader( ShaderType.VertexShader );
GL.ShaderSource( VertexShaderObject, sr.ReadToEnd( ) );
GL.CompileShader( VertexShaderObject );
}
GL.GetShaderInfoLog( VertexShaderObject, out LogInfo );
if ( LogInfo.Length > 0 && !LogInfo.Contains( "hardware" ) )
Trace.WriteLine( "Vertex Shader failed!\nLog:\n" + LogInfo );
else
Trace.WriteLine( "Vertex Shader compiled without complaint." );
// Load&Compile Fragment Shader
using ( StreamReader sr = new StreamReader( FragmentShaderFilename ) )
{
FragmentShaderObject = GL.CreateShader( ShaderType.FragmentShader );
GL.ShaderSource( FragmentShaderObject, sr.ReadToEnd( ) );
GL.CompileShader( FragmentShaderObject );
}
GL.GetShaderInfoLog( FragmentShaderObject, out LogInfo );
if ( LogInfo.Length > 0 && !LogInfo.Contains( "hardware" ) )
Trace.WriteLine( "Fragment Shader failed!\nLog:\n" + LogInfo );
else
Trace.WriteLine( "Fragment Shader compiled without complaint." );
// Link the Shaders to a usable Program
ProgramObject = GL.CreateProgram( );
GL.AttachShader( ProgramObject, VertexShaderObject );
GL.AttachShader( ProgramObject, FragmentShaderObject );
// must bind the attribute before linking
GL.BindAttribLocation( ProgramObject, AttribTangent, "AttributeTangent" );
// link it all together
GL.LinkProgram( ProgramObject );
// flag ShaderObjects for delete when not used anymore
GL.DeleteShader( VertexShaderObject );
GL.DeleteShader( FragmentShaderObject );
GL.GetProgram(ProgramObject, GetProgramParameterName.LinkStatus, out temp[0]);
Trace.WriteLine( "Linking Program (" + ProgramObject + ") " + ( ( temp[0] == 1 ) ? "succeeded." : "FAILED!" ) );
if ( temp[0] != 1 )
{
GL.GetProgramInfoLog( ProgramObject, out LogInfo );
Trace.WriteLine( "Program Log:\n" + LogInfo );
}
GL.GetProgram(ProgramObject, GetProgramParameterName.ActiveAttributes, out temp[0]);
Trace.WriteLine( "Program registered " + temp[0] + " Attributes. (Should be 4: Pos, UV, Normal, Tangent)" );
Trace.WriteLine( "Tangent attribute bind location: " + GL.GetAttribLocation( ProgramObject, "AttributeTangent" ) );
Trace.WriteLine( "End of Shader build. GL Error: " + GL.GetError( ) );
#endregion Shaders
#region Textures
TextureLoaderParameters.MagnificationFilter = TextureMagFilter.Linear;
TextureLoaderParameters.MinificationFilter = TextureMinFilter.LinearMipmapLinear;
TextureLoaderParameters.WrapModeS = TextureWrapMode.ClampToBorder;
TextureLoaderParameters.WrapModeT = TextureWrapMode.ClampToBorder;
TextureLoaderParameters.EnvMode = TextureEnvMode.Modulate;
ImageDDS.LoadFromDisk( TMU0_Filename, out TMU0_Handle, out TMU0_Target );
Trace.WriteLine( "Loaded " + TMU0_Filename + " with handle " + TMU0_Handle + " as " + TMU0_Target );
ImageDDS.LoadFromDisk( TMU1_Filename, out TMU1_Handle, out TMU1_Target );
Trace.WriteLine( "Loaded " + TMU1_Filename + " with handle " + TMU1_Handle + " as " + TMU1_Target );
#endregion Textures
Trace.WriteLine( "End of Texture Loading. GL Error: " + GL.GetError( ) );
Trace.WriteLine( "");
}
protected override void OnUnload(EventArgs e)
{
GL.DeleteProgram( ProgramObject );
GL.DeleteTextures( 1, ref TMU0_Handle );
GL.DeleteTextures( 1, ref TMU1_Handle );
base.OnUnload( e );
}
/// <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 )
{
GL.Viewport( 0, 0, Width, Height );
GL.MatrixMode( MatrixMode.Projection );
Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 100.0f);
GL.LoadMatrix(ref p);
GL.MatrixMode( MatrixMode.Modelview );
GL.LoadIdentity( );
base.OnResize( e );
}
protected override void OnKeyDown(OpenTK.Input.KeyboardKeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Keyboard[OpenTK.Input.Key.Escape])
this.Exit();
if (e.Keyboard[OpenTK.Input.Key.Space])
Trace.WriteLine("GL: " + GL.GetError());
if (e.Keyboard[OpenTK.Input.Key.Q])
{
MaterialScaleAndBiasAndShininess.X += 0.01f;
Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y);
}
if (e.Keyboard[OpenTK.Input.Key.A])
{
MaterialScaleAndBiasAndShininess.X -= 0.01f;
Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y);
}
if (e.Keyboard[OpenTK.Input.Key.W])
{
MaterialScaleAndBiasAndShininess.Y += 0.01f;
Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y);
}
if (e.Keyboard[OpenTK.Input.Key.S])
{
MaterialScaleAndBiasAndShininess.Y -= 0.01f;
Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y);
}
if (e.Keyboard[OpenTK.Input.Key.E])
{
MaterialScaleAndBiasAndShininess.Z += 1f;
Trace.WriteLine("Shininess: " + MaterialScaleAndBiasAndShininess.Z);
}
if (e.Keyboard[OpenTK.Input.Key.D])
{
MaterialScaleAndBiasAndShininess.Z -= 1f;
Trace.WriteLine("Shininess: " + MaterialScaleAndBiasAndShininess.Z);
}
}
protected override void OnMouseMove(OpenTK.Input.MouseMoveEventArgs e)
{
base.OnMouseMove(e);
LightPosition.X = (-(this.Width / 2) + e.Mouse.X) / 100f;
LightPosition.Y = ((this.Height / 2) - e.Mouse.Y) / 100f;
EyePos.Y = e.Mouse.Wheel * 0.5f;
}
/// <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 )
{
base.OnUpdateFrame( e );
}
/// <summary>Add your game rendering code here.</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 )
{
this.Title = "FPS: " + (1 / e.Time).ToString("0.");
GL.Clear( ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit );
GL.UseProgram( ProgramObject );
#region Textures
GL.ActiveTexture( TMU0_Unit );
GL.BindTexture( TMU0_Target, TMU0_Handle );
GL.ActiveTexture( TMU1_Unit );
GL.BindTexture( TMU1_Target, TMU1_Handle );
#endregion Textures
#region Uniforms
// first Material's uniforms
GL.Uniform1( GL.GetUniformLocation( ProgramObject, "Material_DiffuseAndHeight" ), TMU0_UnitInteger );
GL.Uniform1( GL.GetUniformLocation( ProgramObject, "Material_NormalAndGloss" ), TMU1_UnitInteger );
GL.Uniform3( GL.GetUniformLocation( ProgramObject, "Material_ScaleBiasShininess" ), MaterialScaleAndBiasAndShininess.X, MaterialScaleAndBiasAndShininess.Y, MaterialScaleAndBiasAndShininess.Z );
// the rest are vectors
GL.Uniform3( GL.GetUniformLocation( ProgramObject, "Camera_Position" ), EyePos.X, EyePos.Y, EyePos.Z );
GL.Uniform3( GL.GetUniformLocation( ProgramObject, "Light_Position" ), LightPosition.X, LightPosition.Y, LightPosition.Z );
GL.Uniform3( GL.GetUniformLocation( ProgramObject, "Light_DiffuseColor" ), LightDiffuse.X, LightDiffuse.Y, LightDiffuse.Z );
GL.Uniform3( GL.GetUniformLocation( ProgramObject, "Light_SpecularColor" ), LightSpecular.X, LightSpecular.Y, LightSpecular.Z );
#endregion Uniforms
GL.PushMatrix( );
Matrix4 t = Matrix4.LookAt( EyePos, Vector3.Zero, Vector3.UnitY );
GL.MultMatrix(ref t);
#region Draw Quad
GL.Color3( 1f, 1f, 1f );
GL.Begin(PrimitiveType.Quads);
{
GL.Normal3( Normal );
GL.VertexAttrib3( AttribTangent, ref Tangent );
GL.MultiTexCoord2( TextureUnit.Texture0, 0f, 1f );
GL.Vertex3( -1.0f, 1.0f, 0.0f );
GL.Normal3( Normal );
GL.VertexAttrib3( AttribTangent, ref Tangent );
GL.MultiTexCoord2( TextureUnit.Texture0, 0f, 0f );
GL.Vertex3( -1.0f, -1.0f, 0.0f );
GL.Normal3( Normal );
GL.VertexAttrib3( AttribTangent, ref Tangent );
GL.MultiTexCoord2( TextureUnit.Texture0, 1f, 0f );
GL.Vertex3( 1.0f, -1.0f, 0.0f );
GL.Normal3( Normal );
GL.VertexAttrib3( AttribTangent, ref Tangent );
GL.MultiTexCoord2( TextureUnit.Texture0, 1f, 1f );
GL.Vertex3( 1.0f, 1.0f, 0.0f );
}
GL.End( );
#endregion Draw Quad
GL.UseProgram( 0 );
// visualize the light position 'somehow'
GL.Begin(PrimitiveType.Points);
{
GL.Color3( LightSpecular );
GL.Vertex3( LightPosition );
}
GL.End( );
GL.PopMatrix( );
this.SwapBuffers( );
}
/// <summary>Entry point</summary>
[STAThread]
public static void Main( )
{
using ( T12_GLSL_Parallax example = new T12_GLSL_Parallax( ) )
{
Utilities.SetWindowTitle( example );
example.Run( 30.0, 0.0 );
}
}
}
}

View file

@ -1,233 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.IO;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.Tutorial
{
[Example("OpenGL 3.0", ExampleCategory.OpenGL, "3.x", Documentation="HelloGL3")]
public class HelloGL3 : GameWindow
{
string vertexShaderSource = @"
#version 140
precision highp float;
uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
in vec3 in_position;
in vec3 in_normal;
out vec3 normal;
void main(void)
{
//works only for orthogonal modelview
normal = (modelview_matrix * vec4(in_normal, 0)).xyz;
gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);
}";
string fragmentShaderSource = @"
#version 140
precision highp float;
const vec3 ambient = vec3(0.1, 0.1, 0.1);
const vec3 lightVecNormalized = normalize(vec3(0.5, 0.5, 2.0));
const vec3 lightColor = vec3(0.9, 0.9, 0.7);
in vec3 normal;
out vec4 out_frag_color;
void main(void)
{
float diffuse = clamp(dot(lightVecNormalized, normalize(normal)), 0.0, 1.0);
out_frag_color = vec4(ambient + diffuse * lightColor, 1.0);
}";
int vertexShaderHandle,
fragmentShaderHandle,
shaderProgramHandle,
modelviewMatrixLocation,
projectionMatrixLocation,
vaoHandle,
positionVboHandle,
normalVboHandle,
eboHandle;
Vector3[] positionVboData = new Vector3[]{
new Vector3(-1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, -1.0f, 1.0f),
new Vector3( 1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, 1.0f, 1.0f),
new Vector3(-1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, -1.0f, -1.0f),
new Vector3( 1.0f, 1.0f, -1.0f),
new Vector3(-1.0f, 1.0f, -1.0f) };
int[] indicesVboData = new int[]{
// front face
0, 1, 2, 2, 3, 0,
// top face
3, 2, 6, 6, 7, 3,
// back face
7, 6, 5, 5, 4, 7,
// left face
4, 0, 3, 3, 7, 4,
// bottom face
0, 1, 5, 5, 4, 0,
// right face
1, 5, 6, 6, 2, 1, };
Matrix4 projectionMatrix, modelviewMatrix;
public HelloGL3()
: base(640, 480,
new GraphicsMode(), "OpenGL 3 Example", 0,
DisplayDevice.Default, 3, 2,
GraphicsContextFlags.ForwardCompatible | GraphicsContextFlags.Debug)
{ }
protected override void OnLoad (System.EventArgs e)
{
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);
fragmentShaderHandle = GL.CreateShader(ShaderType.FragmentShader);
GL.ShaderSource(vertexShaderHandle, vertexShaderSource);
GL.ShaderSource(fragmentShaderHandle, fragmentShaderSource);
GL.CompileShader(vertexShaderHandle);
GL.CompileShader(fragmentShaderHandle);
Debug.WriteLine(GL.GetShaderInfoLog(vertexShaderHandle));
Debug.WriteLine(GL.GetShaderInfoLog(fragmentShaderHandle));
// Create program
shaderProgramHandle = GL.CreateProgram();
GL.AttachShader(shaderProgramHandle, vertexShaderHandle);
GL.AttachShader(shaderProgramHandle, fragmentShaderHandle);
GL.BindAttribLocation(shaderProgramHandle, 0, "in_position");
GL.BindAttribLocation(shaderProgramHandle, 1, "in_normal");
GL.LinkProgram(shaderProgramHandle);
Debug.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle));
GL.UseProgram(shaderProgramHandle);
// Set uniforms
projectionMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "projection_matrix");
modelviewMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "modelview_matrix");
float aspectRatio = ClientSize.Width / (float)(ClientSize.Height);
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));
GL.UniformMatrix4(projectionMatrixLocation, false, ref projectionMatrix);
GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
}
void CreateVBOs()
{
positionVboHandle = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
positionVboData, BufferUsageHint.StaticDraw);
normalVboHandle = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
positionVboData, BufferUsageHint.StaticDraw);
eboHandle = GL.GenBuffer();
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.
vaoHandle = GL.GenVertexArray();
GL.BindVertexArray(vaoHandle);
GL.EnableVertexAttribArray(0);
GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
GL.EnableVertexAttribArray(1);
GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
GL.BindVertexArray(0);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
Matrix4 rotation = Matrix4.CreateRotationY((float)e.Time);
Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix);
GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
Exit();
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Viewport(0, 0, Width, Height);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.BindVertexArray(vaoHandle);
GL.DrawElements(PrimitiveType.Triangles, indicesVboData.Length,
DrawElementsType.UnsignedInt, IntPtr.Zero);
SwapBuffers();
}
[STAThread]
public static void Main()
{
using (HelloGL3 example = new HelloGL3())
{
Utilities.SetWindowTitle(example);
example.Run(30);
}
}
}
}

View file

@ -1,186 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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.ES11;
#endregion
namespace Examples.Tutorial
{
#if EXPERIMENTAL
[Example("Immediate mode", ExampleCategory.OpenGLES, "1.1", Documentation = "SimpleES11Window")]
public class SimpleES11Window : GameWindow
{
#region --- Fields ---
float rotation_speed = 3.0f;
float angle;
#endregion
#region --- Constructor ---
public SimpleES11Window()
: base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded)
{ }
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Color4 color = Color4.MidnightBlue;
GL.ClearColor(color.R, color.G, color.B, color.A);
GL.Enable((All)EnableCap.DepthTest);
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode((All)MatrixMode.Projection);
GL.LoadMatrix(ref perspective.Row0.X);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
}
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear((uint)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode((All)MatrixMode.Modelview);
GL.LoadMatrix(ref lookat.Row0.X);
angle += rotation_speed * (float)e.Time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
DrawCube();
this.SwapBuffers();
}
#endregion
#region private void DrawCube()
private void DrawCube()
{
#if false
GL.Begin(BeginMode.Quads);
GL.Color3(Color.Silver);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Color3(Color.Honeydew);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Color3(Color.Moccasin);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Color3(Color.IndianRed);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Color3(Color.PaleVioletRed);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Color3(Color.ForestGreen);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.End();
#endif
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (SimpleES11Window example = new SimpleES11Window())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
#endif
}

View file

@ -1,134 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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.ES20;
#endregion
namespace Examples.Tutorial
{
[Example("Simple ES 2.0", ExampleCategory.OpenGLES, "2.0", Documentation = "SimpleES20Window")]
public class SimpleES20Window : GameWindow
{
#region Constructor
public SimpleES20Window(GraphicsContextFlags flags)
: base(800, 600, GraphicsMode.Default, "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, flags)
{ }
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Color4 color = Color4.MidnightBlue;
GL.ClearColor(color.R, color.G, color.B, color.A);
GL.Enable(EnableCap.DepthTest);
}
#endregion
#region OnResize
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
}
#endregion
#region OnUpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
}
}
#endregion
#region OnRenderFrame
/// <summary>
/// Place your rendering code here.
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
this.SwapBuffers();
}
#endregion
#region private void DrawCube()
private void DrawCube()
{
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
SimpleES20Window example;
try
{
example = new SimpleES20Window(GraphicsContextFlags.Embedded);
}
catch
{
example = new SimpleES20Window(GraphicsContextFlags.Default);
}
if (example != null)
{
using (example)
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
}
#endregion
}
}

View file

@ -1,688 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{868E37B3-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>Resources\App.ico</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>Examples</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenTK.Examples</RootNamespace>
<StartupObject>Examples.Program</StartupObject>
<StartArguments>
</StartArguments>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE;</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<DebugType>none</DebugType>
<WarningLevel>4</WarningLevel>
<Optimize>True</Optimize>
<DefineConstants>TRACE;</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;</DefineConstants>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>True</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\OpenTK.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.Xml</Name>
</Reference>
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenTK\OpenTK.csproj">
<Name>OpenTK</Name>
<Project>{A37A7E14-0000-0000-0000-000000000000}</Project>
</ProjectReference>
<ProjectReference Include="..\GLControl\OpenTK.GLControl.csproj">
<Project>{A625BE88-0000-0000-0000-000000000000}</Project>
<Name>OpenTK.GLControl</Name>
</ProjectReference>
<ProjectReference Include="..\GLWidget\OpenTK.GLWidget.csproj">
<Project>{A625BE87-0000-0000-0000-000000000000}</Project>
<Name>OpenTK.GLWidget</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DependencyLoader.cs" />
<Compile Include="ExampleInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\Anaglyph.cs" />
<Compile Include="OpenGL\1.x\OpenGLDiagnostics.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\TextRendering.cs" />
<Compile Include="OpenTK\GameWindow\MouseCursorSimple.cs" />
<Compile Include="OpenTK\Test\TestShaderUtf8Support.cs" />
<Compile Include="SamplesTreeViewSorter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Main.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExampleAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IExample.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExampleBrowser.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TextBoxTraceListener.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utilities.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenCL\VectorAdd.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\DisplayLists.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\StencilCSG.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\VertexArrays.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\VertexLighting.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\Textures.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\VBODynamic.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\FramebufferObject.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\ImmediateMode.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\VBOStatic.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\TextureMatrix.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\1.x\Picking.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\SimpleGLSL.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\GeometryShader.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\DDSCubeMap.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\SwizzledParallax.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\GeometryShaderAdvanced.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\2.x\JuliaSetFractal.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGL\3.x\HelloGL3.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGLES\SimpleWindow20.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGLES\2.0\SimpleWindow20.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenGLES\1.1\SimpleWindow.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utilities\LoaderGDI.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utilities\LoaderStatics.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utilities\LoaderDDS.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\EFX\EFXReverb.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\Test\TestAudioContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\Test\OpenALDiagnostics.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\1.1\Parrot.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenAL\1.1\Playback.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\1.1\PlayStatic.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenAL\1.1\StreamingPlayback.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\MengerSponge.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\TorusKnot.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\KochTetrahedron.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Capsule.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\ChamferCube.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\SlicedHose.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\VertexPositionColor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\SlicedSphere.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Base\VertexStructs.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Base\DrawableShape.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Old\IsoSphere.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Old\SierpinskiTetrahedron.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Old\Plane.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Old\Shape.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Old\Cube.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Helpers\VboShape.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Helpers\MengerCube.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Helpers\TetrahedronFace.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Shapes\Helpers\Chunk.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\GameWindow\GameWindowMsaa.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\GameWindow\GameWindowThreaded.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\GameWindow\GameWindowSimple.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Fonts\FontRenderingBasic.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenTK\Fonts\FontRenderingAdvanced.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\GLControl\GLControlSimple.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenTK\GLControl\DerivedGLControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="OpenTK\GLControl\MultipleGLControls.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenTK\GLControl\GLControlGameLoop.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenTK\Test\Multithreading.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\TestResolutionChanges.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\BlittableValueTypes.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\MathSpeed.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\GameWindowStates.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\MathSerialization.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\Extensions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OpenTK\Test\Color4Serialization.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\TestGraphicsModes.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="OpenGL\1.x\ImmediateMode.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\VBODynamic.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\Picking.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\StencilCSG.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\FramebufferObject.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\VBOStatic.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\DisplayLists.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\Textures.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenGL\1.x\TextureMatrix.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenAL\1.1\Parrot.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenAL\1.1\Playback.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\GameWindow\GameWindowThreaded.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\GameWindow\GameWindowSimple.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\GameWindow\GameWindowMsaa.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\Fonts\FontRenderingBasic.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\GLControl\GLControlSimple.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\Test\BlittableValueTypes.rtf">
</EmbeddedResource>
<EmbeddedResource Include="OpenTK\Test\GameWindowStates.rtf">
</EmbeddedResource>
<EmbeddedResource Include="ExampleBrowser.resx">
<DependentUpon>ExampleBrowser.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="ExampleBrowser.Designer.cs">
<DependentUpon>ExampleBrowser.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="OpenAL\1.1\Parrot.resx">
<DependentUpon>Parrot.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenAL\1.1\Parrot.Designer.cs">
<DependentUpon>Parrot.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\Fonts\FontRenderingBasic.resx">
<DependentUpon>FontRenderingBasic.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\Fonts\FontRenderingBasic.Designer.cs">
<DependentUpon>FontRenderingBasic.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\GLControl\MultipleGLControls.resx">
<DependentUpon>MultipleGLControls.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\GLControl\MultipleGLControls.Designer.cs">
<DependentUpon>MultipleGLControls.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\GLControl\GLControlGameLoop.resx">
<DependentUpon>GLControlGameLoop.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\GLControl\GLControlGameLoop.Designer.cs">
<DependentUpon>GLControlGameLoop.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\GLControl\GLControlSimple.resx">
<DependentUpon>GLControlSimple.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\GLControl\GLControlSimple.Designer.cs">
<DependentUpon>GLControlSimple.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\GLControl\DerivedGLControl.resx">
<DependentUpon>DerivedGLControl.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\GLControl\DerivedGLControl.Designer.cs">
<DependentUpon>DerivedGLControl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="OpenTK\Test\Extensions.resx">
<DependentUpon>Extensions.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="OpenTK\Test\Extensions.Designer.cs">
<DependentUpon>Extensions.cs</DependentUpon>
</Compile>
<None Include="..\..\OpenTK.snk">
<Link>OpenTK.snk</Link>
</None>
<None Include="app.manifest" />
<None Include="Data\Poem.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Picking_VS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Picking_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Parallax_VS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\JuliaSet_SM2_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\JuliaSet_SM3_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Simple_VS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\CubeMap_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Simple_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\Parallax_FS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\CubeMap_VS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Shaders\JuliaSet_VS.glsl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\swizzled-rock-normal-gloss.dds">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\Swizzled Textures License.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\logo.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\swizzled-rock-diffuse-height.dds">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\metal.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\earth-cubemap.dds">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\JuliaColorTable.bmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\logo-dark.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Audio\the_ring_that_fell.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Textures\cursor.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="OpenGL\1.x\OpenGLDiagnostics.rtf" />
<EmbeddedResource Include="OpenGL\1.x\Anaglyph.rtf" />
<EmbeddedResource Include="OpenGL\1.x\TextRendering.rtf" />
<EmbeddedResource Include="OpenTK\GameWindow\MouseCursorSimple.rtf" />
<None Include="Resources\App.ico">
</None>
<None Include="..\OpenTK\OpenTK.dll.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="OpenTK\Test\BasicMouseInput.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OpenTK\Test\MatrixTest.cs" />
<None Include="..\..\Dependencies\x86\libSDL2.dylib">
<Link>Dependencies\x86\libSDL2.dylib</Link>
</None>
<None Include="..\..\Dependencies\x64\libSDL2.dylib">
<Link>Dependencies\x64\libSDL2.dylib</Link>
</None>
<Compile Include="OpenTK\Test\ExternalContext.cs" />
<Compile Include="OpenTK\Test\PointToClient.cs" />
<Compile Include="OpenTK\GLWidget\GLWidgetSimple.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Resources\v4x.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenAL.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenCL.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenGL.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenGLES.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenTK.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\v1x.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\v2x.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\v3x.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Game.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\Dependencies\openal.COPYING.txt">
<Link>Dependencies\openal.COPYING.txt</Link>
</Content>
<Content Include="..\..\Dependencies\SDL2.COPYING.txt">
<Link>Dependencies\SDL2.COPYING.txt</Link>
</Content>
<Content Include="..\..\Dependencies\x64\openal32.dll">
<Link>Dependencies\x64\openal32.dll</Link>
<DependentUpon>SDL2.dll</DependentUpon>
</Content>
<Content Include="..\..\Dependencies\x64\SDL2.dll">
<Link>Dependencies\x64\SDL2.dll</Link>
</Content>
<Content Include="..\..\Dependencies\x86\openal32.dll">
<Link>Dependencies\x86\openal32.dll</Link>
</Content>
<Content Include="..\..\Dependencies\x86\SDL2.dll">
<Link>Dependencies\x86\SDL2.dll</Link>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMinimal|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;</DefineConstants>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<BaseAddress>285212672</BaseAddress>
<FileAlignment>4096</FileAlignment>
<RegisterForComInterop>False</RegisterForComInterop>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMinimal|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
<DefineConstants>TRACE;</DefineConstants>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<BaseAddress>285212672</BaseAddress>
<FileAlignment>4096</FileAlignment>
<RegisterForComInterop>False</RegisterForComInterop>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
</PropertyGroup>
<ItemGroup>
<Folder Include="OpenTK\GLWidget\" />
</ItemGroup>
</Project>

View file

@ -1,161 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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
/// <summary>
/// Shows how to render and scroll large amounts of text.
/// </summary>
[Example("Font rendering (advanced)", ExampleCategory.OpenTK, "Fonts", 2, Documentation="FontRenderingAdvanced")]
public class FontRenderingAdvanced : GameWindow
{
Font serif = new Font(FontFamily.GenericSerif, 16.0f);
Font sans = new Font(FontFamily.GenericSansSerif, 18.0f);
TextPrinter text = new TextPrinter();
string poem = new StreamReader("Data/Poem.txt").ReadToEnd();
int lines; // How many lines the poem contains.
float scroll_speed;
float initial_position;
float wraparound_position;
float current_position;
public FontRenderingAdvanced()
: base(800, 600)
{ }
#region OnLoad
protected override void OnLoad(EventArgs e)
{
GL.ClearColor(Color.MidnightBlue);
current_position = initial_position;
scroll_speed = -1.0f;
// Count the amount of lines in the text, to find out the correct
// warparound position. We want the text to scroll until the last
// line moves outside the screen, then warp it around from the
// other side of the screen.
foreach (char c in poem)
if (c == '\n')
lines++;
wraparound_position = -(lines + 1) * serif.Height;
}
#endregion
#region OnUnload
public override void OnUnload(EventArgs e)
{
if (serif != null)
serif.Dispose();
if (sans != null)
sans.Dispose();
}
#endregion
#region OnResize
protected override void OnResize(EventArgs e)
{
GL.Viewport(0, 0, Width, Height);
initial_position = Height + serif.Height; // Start one line below the screen.
wraparound_position = -(lines + 1) * serif.Height;
}
#endregion
#region OnUpdateFrame
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[Key.Space])
scroll_speed = 0;
if (Keyboard[Key.Down])
scroll_speed += 10;
if (Keyboard[Key.Up])
scroll_speed -= 10;
if (Keyboard[Key.Escape])
this.Exit();
}
#endregion
#region OnRenderFrame
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit);
// We'll start printing from the lower left corner of the screen. The text
// will slowly move updwards - the user can control the movement speed with
// the keyboard arrows and the space bar.
current_position += scroll_speed * (float)e.Time;
if (scroll_speed > 0.0f && current_position > initial_position)
current_position = wraparound_position;
else if (scroll_speed < 0.0f && current_position < wraparound_position)
current_position = initial_position;
// TextPrinter.Begin() sets up a 2d orthographic projection, with the x axis
// moving from 0 to viewport.Width (left to right) and the y axis from
// 0 to viewport.Height (top to bottom). This is the typical coordinate system
// used in 2d graphics, and is necessary for achieving pixel-perfect glyph rendering.
// TextPrinter.End() restores your previous projection/modelview matrices.
text.Begin();
// Print FPS counter. Since the counter changes per frame,
// it shouldn't be cached (TextPrinterOptions.NoCache).
text.Print((1.0 / e.Time).ToString("F2"), sans, Color.SpringGreen, new RectangleF(0, 0, Width, 0), TextPrinterOptions.NoCache, TextAlignment.Far);
// Print the actual text.
GL.Translate(0, current_position, 0);
text.Print(poem, serif, Color.White, new RectangleF(Width / 2, 0, Width / 2, 0), TextPrinterOptions.Default, TextAlignment.Far);
text.Print(poem, serif, Color.White, new RectangleF(0, 0, Width / 2, 0));
text.End();
SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (FontRenderingAdvanced example = new FontRenderingAdvanced())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.Run(30.0, 0.0);
}
}
#endregion
}
#endif
}

View file

@ -1,96 +0,0 @@
namespace Examples.WinForms
{
partial class FontRenderingBasic
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.glControl1 = new OpenTK.GLControl();
this.changeFont = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.fontDialog = new System.Windows.Forms.FontDialog();
this.SuspendLayout();
//
// glControl1
//
this.glControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.glControl1.BackColor = System.Drawing.Color.Black;
this.glControl1.Location = new System.Drawing.Point(0, 40);
this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(700, 521);
this.glControl1.TabIndex = 0;
this.glControl1.VSync = false;
this.glControl1.Load += new System.EventHandler(this.glControl1_Load);
this.glControl1.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl1_Paint);
this.glControl1.Resize += new System.EventHandler(this.glControl1_Resize);
//
// changeFont
//
this.changeFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.changeFont.Location = new System.Drawing.Point(568, 10);
this.changeFont.Name = "changeFont";
this.changeFont.Size = new System.Drawing.Size(120, 23);
this.changeFont.TabIndex = 1;
this.changeFont.Text = "Change Font";
this.changeFont.UseVisualStyleBackColor = true;
this.changeFont.Click += new System.EventHandler(this.changeFont_Click);
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(12, 11);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(550, 22);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "The quick brown fox jumped over the lazy dogs. 0123456789";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// FontRendering
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(700, 561);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.changeFont);
this.Controls.Add(this.glControl1);
this.Name = "FontRendering";
this.Text = "FontRendering";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private OpenTK.GLControl glControl1;
private System.Windows.Forms.Button changeFont;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.FontDialog fontDialog;
}
}

View file

@ -1,132 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.WinForms
{
[Example("Font rendering (basic)", ExampleCategory.OpenTK, "Fonts", Difficulty = 1, Documentation = "FontRenderingBasic", Visible=false)]
public partial class FontRenderingBasic : Form
{
#region Fields
float[] sizes = new float[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24 };
List<Font> fonts = new List<Font>();
//TextPrinter printer = new TextPrinter();
#endregion
#region Constructors
public FontRenderingBasic()
{
InitializeComponent();
ResizeRedraw = true;
glControl1.Width = ClientSize.Width;
glControl1.Height = ClientSize.Height;
UpdateFontList(fontDialog.Font);
glControl1_Resize(this, EventArgs.Empty);
}
#endregion
#region Private Members
void UpdateFontList(Font base_font)
{
//printer.Clear();
foreach (Font font in fonts)
font.Dispose();
fonts.Clear();
foreach (float size in sizes)
fonts.Add(new Font(base_font.Name, base_font.SizeInPoints + size, base_font.Style));
}
#endregion
#region Events
private void glControl1_Load(object sender, EventArgs e)
{
glControl1.MakeCurrent();
}
private void changeFont_Click(object sender, EventArgs e)
{
if (fontDialog.ShowDialog() == DialogResult.OK)
{
UpdateFontList(fontDialog.Font);
glControl1.Invalidate();
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
glControl1.Invalidate();
}
private void glControl1_Paint(object sender, PaintEventArgs e)
{
glControl1.MakeCurrent();
GL.ClearColor(Color.MidnightBlue);
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, glControl1.ClientSize.Width, glControl1.ClientSize.Height, 0, -1, 1);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
foreach (Font font in fonts)
{
//printer.Print(textBox1.Text, font, Color.White);
GL.Translate(0, font.Height + 5, 0);
}
glControl1.SwapBuffers();
}
private void glControl1_Resize(object sender, EventArgs e)
{
glControl1.MakeCurrent();
if (glControl1.ClientSize.Height == 0)
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (FontRenderingBasic example = new FontRenderingBasic())
{
Utilities.SetWindowTitle(example);
example.ShowDialog();
}
}
#endregion
}
}

View file

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="fontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -1,37 +0,0 @@
namespace Examples.WinForms
{
partial class DerivedGLControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View file

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.WinForms
{
public partial class DerivedGLControl : GLControl
{
Color clearColor;
public DerivedGLControl()
{
this.InitializeComponent();
}
public Color ClearColor
{
get { return clearColor; }
set
{
clearColor = value;
if (!this.DesignMode)
{
MakeCurrent();
GL.ClearColor(clearColor);
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!this.DesignMode)
{
MakeCurrent();
GL.Clear(ClearBufferMask.ColorBufferBit);
SwapBuffers();
}
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,60 +0,0 @@
namespace Examples.WinForms
{
partial class GameLoopForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.glControl = new OpenTK.GLControl();
this.SuspendLayout();
//
// glControl
//
this.glControl.BackColor = System.Drawing.Color.Black;
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Location = new System.Drawing.Point(0, 0);
this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(784, 564);
this.glControl.TabIndex = 0;
this.glControl.VSync = false;
//
// W02_Immediate_Mode_Cube
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 564);
this.Controls.Add(this.glControl);
this.Name = "W02_Immediate_Mode_Cube";
this.Text = "Cube";
this.ResumeLayout(false);
}
#endregion
private OpenTK.GLControl glControl;
}
}

View file

@ -1,243 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
#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;
using OpenTK;
#endregion
namespace Examples.WinForms
{
[Example("Simple GLControl Game Loop", ExampleCategory.OpenTK, "GLControl", 2, Documentation="GLControlGameLoop")]
public partial class GameLoopForm : Form
{
static float angle = 0.0f;
#region --- Constructor ---
public GameLoopForm()
{
InitializeComponent();
}
#endregion
#region OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
glControl.KeyDown += new KeyEventHandler(glControl_KeyDown);
glControl.KeyUp += new KeyEventHandler(glControl_KeyUp);
glControl.Resize += new EventHandler(glControl_Resize);
glControl.Paint += new PaintEventHandler(glControl_Paint);
Text =
GL.GetString(StringName.Vendor) + " " +
GL.GetString(StringName.Renderer) + " " +
GL.GetString(StringName.Version);
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
Application.Idle += Application_Idle;
// Ensure that the viewport and projection matrix are set correctly.
glControl_Resize(glControl, EventArgs.Empty);
}
void glControl_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F12)
{
GrabScreenshot().Save("screenshot.png");
}
}
#endregion
#region OnClosing
protected override void OnClosing(CancelEventArgs e)
{
Application.Idle -= Application_Idle;
base.OnClosing(e);
}
#endregion
#region Application_Idle event
void Application_Idle(object sender, EventArgs e)
{
while (glControl.IsIdle)
{
Render();
}
}
#endregion
#region GLControl.Resize event handler
void glControl_Resize(object sender, EventArgs e)
{
OpenTK.GLControl c = sender as OpenTK.GLControl;
if (c.ClientSize.Height == 0)
c.ClientSize = new System.Drawing.Size(c.ClientSize.Width, 1);
GL.Viewport(0, 0, c.ClientSize.Width, c.ClientSize.Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}
#endregion
#region GLControl.KeyDown event handler
void glControl_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.Escape:
this.Close();
break;
}
}
#endregion
#region GLControl.Paint event handler
void glControl_Paint(object sender, PaintEventArgs e)
{
Render();
}
#endregion
#region private void Render()
private void Render()
{
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
angle += 0.5f;
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
DrawCube();
glControl.SwapBuffers();
}
#endregion
#region private void DrawCube()
private void DrawCube()
{
GL.Begin(PrimitiveType.Quads);
GL.Color3(Color.Silver);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Color3(Color.Honeydew);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Color3(Color.Moccasin);
GL.Vertex3(-1.0f, -1.0f, -1.0f);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Color3(Color.IndianRed);
GL.Vertex3(-1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Color3(Color.PaleVioletRed);
GL.Vertex3(-1.0f, 1.0f, -1.0f);
GL.Vertex3(-1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Color3(Color.ForestGreen);
GL.Vertex3(1.0f, -1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, -1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.End();
}
#endregion
#region private void GrabScreenshot()
Bitmap GrabScreenshot()
{
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
System.Drawing.Imaging.BitmapData data =
bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (GameLoopForm example = new GameLoopForm())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Text = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.ShowDialog();
}
}
#endregion
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,110 +0,0 @@
namespace Examples.WinForms
{
partial class SimpleForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.redButton = new System.Windows.Forms.Button();
this.greenButton = new System.Windows.Forms.Button();
this.blueButton = new System.Windows.Forms.Button();
this.glControl1 = new OpenTK.GLControl();
this.SuspendLayout();
//
// redButton
//
this.redButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.redButton.Location = new System.Drawing.Point(1278, 25);
this.redButton.Margin = new System.Windows.Forms.Padding(6);
this.redButton.Name = "redButton";
this.redButton.Size = new System.Drawing.Size(266, 44);
this.redButton.TabIndex = 1;
this.redButton.Text = "Red";
this.redButton.UseVisualStyleBackColor = true;
this.redButton.Click += new System.EventHandler(this.redButton_Click);
//
// greenButton
//
this.greenButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.greenButton.Location = new System.Drawing.Point(1278, 83);
this.greenButton.Margin = new System.Windows.Forms.Padding(6);
this.greenButton.Name = "greenButton";
this.greenButton.Size = new System.Drawing.Size(266, 44);
this.greenButton.TabIndex = 2;
this.greenButton.Text = "Green";
this.greenButton.UseVisualStyleBackColor = true;
this.greenButton.Click += new System.EventHandler(this.greenButton_Click);
//
// blueButton
//
this.blueButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.blueButton.Location = new System.Drawing.Point(1278, 140);
this.blueButton.Margin = new System.Windows.Forms.Padding(6);
this.blueButton.Name = "blueButton";
this.blueButton.Size = new System.Drawing.Size(266, 44);
this.blueButton.TabIndex = 3;
this.blueButton.Text = "Blue";
this.blueButton.UseVisualStyleBackColor = true;
this.blueButton.Click += new System.EventHandler(this.blueButton_Click);
//
// glControl1
//
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDark;
this.glControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl1.Location = new System.Drawing.Point(0, 0);
this.glControl1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(1562, 1085);
this.glControl1.TabIndex = 4;
this.glControl1.VSync = false;
this.glControl1.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl1_Paint);
this.glControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.glControl1_KeyDown);
this.glControl1.Resize += new System.EventHandler(this.glControl1_Resize);
//
// SimpleForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1562, 1085);
this.Controls.Add(this.blueButton);
this.Controls.Add(this.greenButton);
this.Controls.Add(this.redButton);
this.Controls.Add(this.glControl1);
this.Margin = new System.Windows.Forms.Padding(6);
this.Name = "SimpleForm";
this.Text = "OpenTK Windows Forms Tutorial 01 - Your first window";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button redButton;
private System.Windows.Forms.Button greenButton;
private System.Windows.Forms.Button blueButton;
private OpenTK.GLControl glControl1;
}
}

View file

@ -1,94 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Windows.Forms;
using OpenTK.Graphics.OpenGL;
namespace Examples.WinForms
{
[Example("GLControl Simple", ExampleCategory.OpenTK, "GLControl", 1, Documentation="GLControlSimple")]
public partial class SimpleForm : Form
{
public SimpleForm()
{
InitializeComponent();
}
#region Events
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
glControl1_Resize(this, EventArgs.Empty); // Ensure the Viewport is set up correctly
GL.ClearColor(Color.Crimson);
}
private void redButton_Click(object sender, EventArgs e)
{
GL.ClearColor(Color.Crimson);
glControl1.Invalidate();
}
private void greenButton_Click(object sender, EventArgs e)
{
GL.ClearColor(Color.ForestGreen);
glControl1.Invalidate();
}
private void blueButton_Click(object sender, EventArgs e)
{
GL.ClearColor(Color.RoyalBlue);
glControl1.Invalidate();
}
private void glControl1_Paint(object sender, PaintEventArgs e)
{
glControl1.MakeCurrent();
GL.Clear(ClearBufferMask.ColorBufferBit);
glControl1.SwapBuffers();
}
private void glControl1_Resize(object sender, EventArgs e)
{
if (glControl1.ClientSize.Height == 0)
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
}
private void glControl1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.Escape:
this.Close();
break;
}
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (SimpleForm example = new SimpleForm())
{
Utilities.SetWindowTitle(example);
example.ShowDialog();
}
}
#endregion
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,74 +0,0 @@
namespace Examples.WinForms
{
partial class MultipleGLControlsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.derivedGLControl1 = new Examples.WinForms.DerivedGLControl();
this.derivedGLControl2 = new Examples.WinForms.DerivedGLControl();
this.SuspendLayout();
//
// derivedGLControl1
//
this.derivedGLControl1.BackColor = System.Drawing.Color.Black;
this.derivedGLControl1.ClearColor = System.Drawing.Color.Blue;
this.derivedGLControl1.Location = new System.Drawing.Point(12, 12);
this.derivedGLControl1.Name = "derivedGLControl1";
this.derivedGLControl1.Size = new System.Drawing.Size(300, 225);
this.derivedGLControl1.TabIndex = 0;
this.derivedGLControl1.VSync = false;
//
// derivedGLControl2
//
this.derivedGLControl2.BackColor = System.Drawing.Color.Black;
this.derivedGLControl2.ClearColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.derivedGLControl2.Location = new System.Drawing.Point(319, 13);
this.derivedGLControl2.Name = "derivedGLControl2";
this.derivedGLControl2.Size = new System.Drawing.Size(293, 224);
this.derivedGLControl2.TabIndex = 1;
this.derivedGLControl2.VSync = false;
//
// W04_Multiple_GLControls
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(624, 444);
this.Controls.Add(this.derivedGLControl2);
this.Controls.Add(this.derivedGLControl1);
this.Name = "W04_Multiple_GLControls";
this.Text = "W04_Multiple_GLControls";
this.ResumeLayout(false);
}
#endregion
private DerivedGLControl derivedGLControl1;
private DerivedGLControl derivedGLControl2;
}
}

View file

@ -1,35 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
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("Multiple GLControls", ExampleCategory.OpenTK, "GLControl", 3, Documentation="MultipleGLControls")]
public partial class MultipleGLControlsForm : Form
{
public MultipleGLControlsForm()
{
InitializeComponent();
}
public static void Main()
{
using (MultipleGLControlsForm example = new MultipleGLControlsForm())
{
Utilities.SetWindowTitle(example);
example.ShowDialog();
}
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,152 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using System.Threading;
using Gtk;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace Examples.GLWidget
{
[Example("GLWidget Simple", ExampleCategory.OpenTK, "GLWidget", 1, Documentation="GLWidgetSimple")]
public class SimpleWindow : Window
{
VBox vbox1;
HBox hbox1;
Button button_red, button_green, button_blue;
OpenTK.GLWidget glwidget1;
public SimpleWindow()
: base(WindowType.Toplevel)
{
Build();
}
private void Build()
{
this.Title = "Sample GLWidget Example";
this.DefaultWidth = 800;
this.DefaultHeight = 600;
vbox1 = new VBox();
glwidget1 = new OpenTK.GLWidget();
glwidget1.Initialized += Glwidget1_Initialized;
// do note that if you are placing the widget inside a container you have to do it after initalization
var t = new Thread(new ThreadStart(delegate {
Thread.Sleep(50);
Application.Invoke(delegate {
vbox1.PackStart(glwidget1, true, true, 1);
glwidget1.Show();
});
}));
t.Start();
hbox1 = new HBox();
button_blue = new Button("Clear Blue");
button_blue.Clicked += Button_blue_Clicked;
hbox1.PackStart(button_blue, true, true, 0);
button_green = new Button("Clear Green");
button_green.Clicked += Button_green_Clicked;
hbox1.PackStart(button_green, true, true, 1);
button_red = new Button("Clear Red");
button_red.Clicked += Button_red_Clicked;
hbox1.PackStart(button_red, true, true, 2);
vbox1.PackStart(hbox1, false, false, 0);
this.Add(vbox1);
this.ShowAll();
this.DeleteEvent += OnDeleteEvent;
}
#region Events
protected void Glwidget1_Initialized(object sender, EventArgs e)
{
GL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
glwidget1.SizeAllocated += Glwidget1_SizeAllocated;
glwidget1.RenderFrame += Glwidget1_RenderFrame;
}
protected void Glwidget1_SizeAllocated(object o, SizeAllocatedArgs args)
{
GL.Viewport(0, 0, args.Allocation.Width, args.Allocation.Height);
}
protected void Glwidget1_RenderFrame(object sender, EventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Begin(PrimitiveType.Triangles);
GL.Color3(Color.MidnightBlue);
GL.Vertex2(-1.0f, 1.0f);
GL.Color3(Color.SpringGreen);
GL.Vertex2(0.0f, -1.0f);
GL.Color3(Color.Ivory);
GL.Vertex2(1.0f, 1.0f);
GL.End();
GraphicsContext.CurrentContext.SwapBuffers();
}
protected void Button_blue_Clicked(object sender, EventArgs e)
{
GL.ClearColor(Color.RoyalBlue);
glwidget1.QueueDraw();
}
protected void Button_green_Clicked(object sender, EventArgs e)
{
GL.ClearColor(Color.ForestGreen);
glwidget1.QueueDraw();
}
protected void Button_red_Clicked(object sender, EventArgs e)
{
GL.ClearColor(Color.Crimson);
glwidget1.QueueDraw();
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
#endregion
#region public static void Main()
public static void Main(string[] args)
{
Application.Init();
SimpleWindow win = new SimpleWindow();
win.Show();
Application.Run();
}
#endregion
}
}

View file

@ -1,136 +0,0 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.
using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
namespace Examples
{
[Example("GameWindow MSAA", ExampleCategory.OpenTK, "GameWindow", 2, Documentation = "GameWindowMsaa")]
public class FullscreenAntialias : GameWindow
{
public FullscreenAntialias()
: base(800, 600, new GraphicsMode(32, 0, 0, 4))
{
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="key">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)
{
GL.ClearColor(Color.MidnightBlue);
}
#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)
{
GL.Viewport(0, 0, Width, Height);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
base.OnResize(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>
/// Add your game rendering code here.
/// </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)
{
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.Begin(PrimitiveType.Triangles);
GL.Color3(Color.MidnightBlue);
GL.Vertex2(-1.0f, 1.0f);
GL.Color3(Color.SpringGreen);
GL.Vertex2(0.0f, -1.0f);
GL.Color3(Color.Ivory);
GL.Vertex2(1.0f, 1.0f);
GL.End();
this.SwapBuffers();
}
#endregion
#region public static void Main()
/// <summary>
/// Entry point of this example.
/// </summary>
[STAThread]
public static void Main()
{
using (FullscreenAntialias example = new FullscreenAntialias())
{
// Get the title and category of this example using reflection.
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show more