Sycned with gl3 branch.

This commit is contained in:
the_fiddler 2007-08-01 09:32:49 +00:00
parent f4d6347832
commit 6bec9d994b
10 changed files with 322 additions and 37 deletions

View file

@ -8,7 +8,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using OpenTK.OpenGL; using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums; using Enums = OpenTK.OpenGL.GL.Enums;
using OpenTK; using OpenTK;
using OpenTK.Platform; using OpenTK.Platform;

View file

@ -0,0 +1,60 @@
namespace Examples.Tests
{
partial class S01_Call_Performance
{
/// <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.SuspendLayout();
//
// glControl1
//
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.glControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl1.Fullscreen = false;
this.glControl1.Location = new System.Drawing.Point(0, 0);
this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(624, 444);
this.glControl1.TabIndex = 0;
//
// S01_Call_Performance
//
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.glControl1);
this.Name = "S01_Call_Performance";
this.Text = "S01_Call_Performance";
this.ResumeLayout(false);
}
#endregion
private OpenTK.GLControl glControl1;
}
}

View file

@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.OpenGL;
using System.Threading;
using System.Runtime.InteropServices;
namespace Examples.Tests
{
public partial class S01_Call_Performance : Form, IExample
{
public S01_Call_Performance()
{
InitializeComponent();
Application.Idle += new EventHandler(Application_Idle);
// Force opengl functions
GL.Viewport(0, 0, this.Width, this.Height);
this.ShowDialog();
}
bool run = false;
float[] v = new float[] { 0.0f, 0.0f };
int i = 0;
void dummy()
{
unsafe
{
//fixed (int* i_ptr = &i)
{
GCHandle h = GCHandle.Alloc(i, GCHandleType.Pinned);//.FromIntPtr((IntPtr)i_ptr);
try
{
i = (int)h.AddrOfPinnedObject();
}
finally
{
h.Free();
}
}
}
}
[DllImport("opengl32.dll", EntryPoint = "glVertex2f")]
extern static void glVertex2f_1(float a, float b);
[System.Security.SuppressUnmanagedCodeSecurity()]
[DllImport("opengl32.dll", EntryPoint = "glVertex2f")]
extern static void glVertex2f_2(float a, float b);
[System.Security.SuppressUnmanagedCodeSecurity()]
[DllImport("opengl32.dll", EntryPoint = "glVertex2fv")]
extern static void glVertex2fv(float[] v);
void Application_Idle(object sender, EventArgs e)
{
long count = 0;
bool stop = false;
if (!run)
{
run = true;
GL.Clear(
GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT |
GL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
//GL.Begin(GL.Enums.BeginMode.POINTS);
System.Threading.Timer timer = new System.Threading.Timer(
new TimerCallback(delegate { stop = true; }), null, 5000, Timeout.Infinite);
while (!stop)
{
GL.Vertex2f(0.0f, 0.0f);
//GL.Vertex2fv(v);
//GL.ARB.ActiveTexture(GL.Enums.ARB_multitexture.TEXTURE0_ARB);
//dummy();
GL.ColorPointer(2, GL.Enums.ColorPointerType.FLOAT, 0, v);
//glVertex2f_1(0.0f, 0.0f);
//glVertex2f_2(0.0f, 0.0f);
//glVertex2fv(v);
count++;
}
//GL.End();
//glControl1.Context.SwapBuffers();
timer.Dispose();
this.Hide();
MessageBox.Show(String.Format("{0} calls/second.", count / 5.0));
Application.Idle -= Application_Idle;
this.Close();
}
}
}
}

View file

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

View file

@ -13,7 +13,7 @@ using System.Windows.Forms;
using OpenTK; using OpenTK;
using OpenTK.OpenGL; using OpenTK.OpenGL;
using OpenTK.Platform; using OpenTK.Platform;
using Enums = OpenTK.OpenGL.Enums; using Enums = OpenTK.OpenGL.GL.Enums;
using OpenTK.Input; using OpenTK.Input;
#endregion #endregion

View file

@ -15,7 +15,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using OpenTK.OpenGL; using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums; using Enums = OpenTK.OpenGL.GL.Enums;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;

View file

@ -76,11 +76,9 @@ namespace Examples.Tutorial
this.Context.MakeCurrent(); this.Context.MakeCurrent();
GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f); GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f);
GL.Enable(OpenTK.OpenGL.Enums.EnableCap.DEPTH_TEST); GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY); GL.EnableClientState(GL.Enums.EnableCap.VERTEX_ARRAY);
GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY); GL.EnableClientState(GL.Enums.EnableCap.INDEX_ARRAY);
//GL.Enable(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY);
//GL.Enable(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY);
LoadCube(); LoadCube();
@ -96,24 +94,24 @@ namespace Examples.Tutorial
base.RenderFrame(); base.RenderFrame();
GL.Clear( GL.Clear(
OpenTK.OpenGL.Enums.ClearBufferMask.COLOR_BUFFER_BIT | GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT |
OpenTK.OpenGL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT); GL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo); GL.BindBuffer(GL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo);
GL.VertexPointer(3, OpenTK.OpenGL.Enums.VertexPointerType.FLOAT, 0, 0); GL.VertexPointer(3, GL.Enums.VertexPointerType.FLOAT, 0, 0);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo); GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo);
GL.IndexPointer(OpenTK.OpenGL.Enums.IndexPointerType.FLOAT, 0, 0); GL.IndexPointer(GL.Enums.IndexPointerType.FLOAT, 0, 0);
GL.Color3f(1.0f, 1.0f, 1.0f); GL.Color3f(1.0f, 1.0f, 1.0f);
GL.DrawElements( GL.DrawElements(
OpenTK.OpenGL.Enums.BeginMode.QUADS, GL.Enums.BeginMode.QUADS,
idata.Length, idata.Length,
OpenTK.OpenGL.Enums.GLenum.UNSIGNED_SHORT, GL.Enums.GLenum.UNSIGNED_SHORT,
idata); idata);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, 0); GL.BindBuffer(GL.Enums.VERSION_1_5.ARRAY_BUFFER, 0);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, 0); GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, 0);
Context.SwapBuffers(); Context.SwapBuffers();
} }
@ -137,7 +135,7 @@ namespace Examples.Tutorial
return; return;
} }
GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.MODELVIEW); GL.MatrixMode(GL.Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity(); GL.LoadIdentity();
Glu.LookAt( Glu.LookAt(
0.0, 5.0, 5.0, 0.0, 5.0, 5.0,
@ -161,7 +159,7 @@ namespace Examples.Tutorial
double ratio = e.Width / (double)e.Height; double ratio = e.Width / (double)e.Height;
GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.PROJECTION); GL.MatrixMode(GL.Enums.MatrixMode.PROJECTION);
GL.LoadIdentity(); GL.LoadIdentity();
Glu.Perspective(45.0, ratio, 1.0, 64.0); Glu.Perspective(45.0, ratio, 1.0, 64.0);
} }
@ -179,15 +177,15 @@ namespace Examples.Tutorial
GL.GenBuffers(1, out ibo); GL.GenBuffers(1, out ibo);
// Upload the vertex data // Upload the vertex data
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo); GL.BindBuffer(GL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo);
GL.BufferData( GL.BufferData(
OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, GL.Enums.VERSION_1_5.ARRAY_BUFFER,
(IntPtr)(vdata.Length * 4), (IntPtr)(vdata.Length * 4),
vdata, vdata,
OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW); GL.Enums.VERSION_1_5.STATIC_DRAW);
GL.GetBufferParameteriv( GL.GetBufferParameteriv(
OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, GL.Enums.VERSION_1_5.ARRAY_BUFFER,
OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE, GL.Enums.VERSION_1_5.BUFFER_SIZE,
out size); out size);
if (vdata.Length * 4 != size) if (vdata.Length * 4 != size)
{ {
@ -195,16 +193,16 @@ namespace Examples.Tutorial
} }
// Upload the index data // Upload the index data
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo); GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo);
GL.BufferData( GL.BufferData(
OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
(IntPtr)(idata.Length * 2), (IntPtr)(idata.Length * 2),
idata, idata,
OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW GL.Enums.VERSION_1_5.STATIC_DRAW
); );
GL.GetBufferParameteriv( GL.GetBufferParameteriv(
OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE, GL.Enums.VERSION_1_5.BUFFER_SIZE,
out size); out size);
if (idata.Length * 2 != size) if (idata.Length * 2 != size)
{ {

View file

@ -15,7 +15,7 @@ using System.Windows.Forms;
using System.Threading; using System.Threading;
using OpenTK.OpenGL; using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums; using Enums = OpenTK.OpenGL.GL.Enums;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
@ -69,24 +69,24 @@ namespace Examples.Tutorial
vertex_shader_object = GL.CreateShader(Enums.VERSION_2_0.VERTEX_SHADER); vertex_shader_object = GL.CreateShader(Enums.VERSION_2_0.VERTEX_SHADER);
fragment_shader_object = GL.CreateShader(Enums.VERSION_2_0.FRAGMENT_SHADER); fragment_shader_object = GL.CreateShader(Enums.VERSION_2_0.FRAGMENT_SHADER);
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, null); GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, (int[])null);
GL.CompileShader(vertex_shader_object); GL.CompileShader(vertex_shader_object);
GL.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status); GL.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)Enums.Boolean.TRUE) if (status != (int)Enums.Boolean.TRUE)
{ {
StringBuilder info = new StringBuilder(1024); StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(vertex_shader_object, info.MaxCapacity, null, info); GL.GetShaderInfoLog(vertex_shader_object, info.MaxCapacity, (int[])null, info);
throw new Exception(info.ToString()); throw new Exception(info.ToString());
} }
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, null); GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, (int[])null);
GL.CompileShader(fragment_shader_object); GL.CompileShader(fragment_shader_object);
GL.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status); GL.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)Enums.Boolean.TRUE) if (status != (int)Enums.Boolean.TRUE)
{ {
StringBuilder info = new StringBuilder(1024); StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(fragment_shader_object, 1024, null, info); GL.GetShaderInfoLog(fragment_shader_object, 1024, (int[])null, info);
throw new Exception(info.ToString()); throw new Exception(info.ToString());
} }

View file

@ -15,7 +15,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using OpenTK.OpenGL; using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums; using Enums = OpenTK.OpenGL.GL.Enums;
using OpenTK.Platform; using OpenTK.Platform;
#endregion #endregion

View file

@ -50,7 +50,7 @@ namespace Examples.WinForms
private void glControl1_Paint(object sender, PaintEventArgs e) private void glControl1_Paint(object sender, PaintEventArgs e)
{ {
GL.Clear(OpenTK.OpenGL.Enums.ClearBufferMask.COLOR_BUFFER_BIT); GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
glControl1.Context.SwapBuffers(); glControl1.Context.SwapBuffers();
} }