diff --git a/Source/Examples/OpenGL/Basic/NoFramework/QueryModesForm.cs b/Source/Examples/OpenGL/Basic/NoFramework/QueryModesForm.cs index ea3a8e39..1a179888 100644 --- a/Source/Examples/OpenGL/Basic/NoFramework/QueryModesForm.cs +++ b/Source/Examples/OpenGL/Basic/NoFramework/QueryModesForm.cs @@ -8,7 +8,7 @@ using System.Text; using System.Windows.Forms; using OpenTK.OpenGL; -using Enums = OpenTK.OpenGL.Enums; +using Enums = OpenTK.OpenGL.GL.Enums; using OpenTK; using OpenTK.Platform; diff --git a/Source/Examples/Tests/S01_Call_Performance.Designer.cs b/Source/Examples/Tests/S01_Call_Performance.Designer.cs new file mode 100644 index 00000000..0bace08b --- /dev/null +++ b/Source/Examples/Tests/S01_Call_Performance.Designer.cs @@ -0,0 +1,60 @@ +namespace Examples.Tests +{ + partial class S01_Call_Performance + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/Source/Examples/Tests/S01_Call_Performance.cs b/Source/Examples/Tests/S01_Call_Performance.cs new file mode 100644 index 00000000..dd2eb48d --- /dev/null +++ b/Source/Examples/Tests/S01_Call_Performance.cs @@ -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(); + } + } + } +} \ No newline at end of file diff --git a/Source/Examples/Tests/S01_Call_Performance.resx b/Source/Examples/Tests/S01_Call_Performance.resx new file mode 100644 index 00000000..ff31a6db --- /dev/null +++ b/Source/Examples/Tests/S01_Call_Performance.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/Examples/Tutorial/T03_RotatingCube.cs b/Source/Examples/Tutorial/T03_RotatingCube.cs index b5374f4b..c072409a 100644 --- a/Source/Examples/Tutorial/T03_RotatingCube.cs +++ b/Source/Examples/Tutorial/T03_RotatingCube.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; using OpenTK; using OpenTK.OpenGL; using OpenTK.Platform; -using Enums = OpenTK.OpenGL.Enums; +using Enums = OpenTK.OpenGL.GL.Enums; using OpenTK.Input; #endregion diff --git a/Source/Examples/Tutorial/T07_DisplayLists_Cube.cs b/Source/Examples/Tutorial/T07_DisplayLists_Cube.cs index 17179d30..7a1af07f 100644 --- a/Source/Examples/Tutorial/T07_DisplayLists_Cube.cs +++ b/Source/Examples/Tutorial/T07_DisplayLists_Cube.cs @@ -15,7 +15,7 @@ using System.Text; using System.Windows.Forms; using OpenTK.OpenGL; -using Enums = OpenTK.OpenGL.Enums; +using Enums = OpenTK.OpenGL.GL.Enums; using OpenTK; using OpenTK.Input; diff --git a/Source/Examples/Tutorial/T08_VBO.cs b/Source/Examples/Tutorial/T08_VBO.cs index 809ac3d6..59442370 100644 --- a/Source/Examples/Tutorial/T08_VBO.cs +++ b/Source/Examples/Tutorial/T08_VBO.cs @@ -76,11 +76,9 @@ namespace Examples.Tutorial this.Context.MakeCurrent(); GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f); - GL.Enable(OpenTK.OpenGL.Enums.EnableCap.DEPTH_TEST); - GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY); - GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY); - //GL.Enable(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY); - //GL.Enable(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY); + GL.Enable(GL.Enums.EnableCap.DEPTH_TEST); + GL.EnableClientState(GL.Enums.EnableCap.VERTEX_ARRAY); + GL.EnableClientState(GL.Enums.EnableCap.INDEX_ARRAY); LoadCube(); @@ -96,24 +94,24 @@ namespace Examples.Tutorial base.RenderFrame(); GL.Clear( - OpenTK.OpenGL.Enums.ClearBufferMask.COLOR_BUFFER_BIT | - OpenTK.OpenGL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT); + GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT | + GL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT); - GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo); - GL.VertexPointer(3, OpenTK.OpenGL.Enums.VertexPointerType.FLOAT, 0, 0); + GL.BindBuffer(GL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo); + GL.VertexPointer(3, GL.Enums.VertexPointerType.FLOAT, 0, 0); - GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo); - GL.IndexPointer(OpenTK.OpenGL.Enums.IndexPointerType.FLOAT, 0, 0); + GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo); + GL.IndexPointer(GL.Enums.IndexPointerType.FLOAT, 0, 0); GL.Color3f(1.0f, 1.0f, 1.0f); GL.DrawElements( - OpenTK.OpenGL.Enums.BeginMode.QUADS, + GL.Enums.BeginMode.QUADS, idata.Length, - OpenTK.OpenGL.Enums.GLenum.UNSIGNED_SHORT, + GL.Enums.GLenum.UNSIGNED_SHORT, idata); - GL.BindBuffer(OpenTK.OpenGL.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.ARRAY_BUFFER, 0); + GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, 0); Context.SwapBuffers(); } @@ -137,7 +135,7 @@ namespace Examples.Tutorial return; } - GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.MODELVIEW); + GL.MatrixMode(GL.Enums.MatrixMode.MODELVIEW); GL.LoadIdentity(); Glu.LookAt( 0.0, 5.0, 5.0, @@ -161,7 +159,7 @@ namespace Examples.Tutorial double ratio = e.Width / (double)e.Height; - GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.PROJECTION); + GL.MatrixMode(GL.Enums.MatrixMode.PROJECTION); GL.LoadIdentity(); Glu.Perspective(45.0, ratio, 1.0, 64.0); } @@ -179,15 +177,15 @@ namespace Examples.Tutorial GL.GenBuffers(1, out ibo); // 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( - OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, + GL.Enums.VERSION_1_5.ARRAY_BUFFER, (IntPtr)(vdata.Length * 4), vdata, - OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW); + GL.Enums.VERSION_1_5.STATIC_DRAW); GL.GetBufferParameteriv( - OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, - OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE, + GL.Enums.VERSION_1_5.ARRAY_BUFFER, + GL.Enums.VERSION_1_5.BUFFER_SIZE, out size); if (vdata.Length * 4 != size) { @@ -195,16 +193,16 @@ namespace Examples.Tutorial } // 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( - OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, + GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, (IntPtr)(idata.Length * 2), idata, - OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW + GL.Enums.VERSION_1_5.STATIC_DRAW ); GL.GetBufferParameteriv( - OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, - OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE, + GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, + GL.Enums.VERSION_1_5.BUFFER_SIZE, out size); if (idata.Length * 2 != size) { diff --git a/Source/Examples/Tutorial/T10_GLSL_Cube.cs b/Source/Examples/Tutorial/T10_GLSL_Cube.cs index 512e233e..ae306501 100644 --- a/Source/Examples/Tutorial/T10_GLSL_Cube.cs +++ b/Source/Examples/Tutorial/T10_GLSL_Cube.cs @@ -15,7 +15,7 @@ using System.Windows.Forms; using System.Threading; using OpenTK.OpenGL; -using Enums = OpenTK.OpenGL.Enums; +using Enums = OpenTK.OpenGL.GL.Enums; using OpenTK; using OpenTK.Input; @@ -69,24 +69,24 @@ namespace Examples.Tutorial vertex_shader_object = GL.CreateShader(Enums.VERSION_2_0.VERTEX_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.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status); if (status != (int)Enums.Boolean.TRUE) { 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()); } - 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.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status); if (status != (int)Enums.Boolean.TRUE) { 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()); } diff --git a/Source/Examples/WinForms/Cube.cs b/Source/Examples/WinForms/Cube.cs index c824ce53..ed0ae7c0 100644 --- a/Source/Examples/WinForms/Cube.cs +++ b/Source/Examples/WinForms/Cube.cs @@ -15,7 +15,7 @@ using System.Text; using System.Windows.Forms; using OpenTK.OpenGL; -using Enums = OpenTK.OpenGL.Enums; +using Enums = OpenTK.OpenGL.GL.Enums; using OpenTK.Platform; #endregion diff --git a/Source/Examples/WinForms/W01_First_Window.cs b/Source/Examples/WinForms/W01_First_Window.cs index 732cc481..486c970a 100644 --- a/Source/Examples/WinForms/W01_First_Window.cs +++ b/Source/Examples/WinForms/W01_First_Window.cs @@ -50,7 +50,7 @@ namespace Examples.WinForms 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(); }