diff --git a/Source/Examples/OpenGL/1.1/Picking.cs b/Source/Examples/OpenGL/1.1/Picking.cs index f650494b..123a7b5a 100644 --- a/Source/Examples/OpenGL/1.1/Picking.cs +++ b/Source/Examples/OpenGL/1.1/Picking.cs @@ -209,7 +209,7 @@ namespace Examples.Tutorial { GL.Viewport(ClientRectangle); - Matrix4 projection = Matrix4.Perspective(45.0f, this.Width / (float)this.Height, 0.1f, 10.0f); + Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, this.Width / (float)this.Height, 0.1f, 10.0f); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection); } diff --git a/Source/Examples/OpenGL/1.1/StencilCSG.cs b/Source/Examples/OpenGL/1.1/StencilCSG.cs index 65356af2..f3e388f7 100644 --- a/Source/Examples/OpenGL/1.1/StencilCSG.cs +++ b/Source/Examples/OpenGL/1.1/StencilCSG.cs @@ -31,20 +31,28 @@ namespace Examples.Tutorial float CameraZoom; float CameraRotX; float CameraRotY; - Vector3 EyePosition = new Vector3( 0f, 0f, 5f ); + 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; + Keyboard.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.Perspective( 45f, Width / (float)Height, 0.1f, 15.0f); + Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 64.0f); GL.LoadMatrix(ref p); } #endregion Window @@ -142,7 +150,7 @@ namespace Examples.Tutorial for (int i = 0; i < tempVertices.Length; i++) { - tempVertices[i].Normal.Mult(-1.0); + tempVertices[i].Normal *= -1.0; tempVertices[i].Normal.Normalize(); } @@ -162,17 +170,6 @@ namespace Examples.Tutorial protected override void OnUpdateFrame( FrameEventArgs e ) { - - if (Keyboard[OpenTK.Input.Key.Escape]) - { - this.Exit(); - } - - if (Keyboard[Key.Space]) - { - ShowDebugWireFrame = !ShowDebugWireFrame; - } - #region Magic numbers for camera CameraRotX = -Mouse.X * .5f; CameraRotY = Mouse.Y * .5f; @@ -260,7 +257,7 @@ namespace Examples.Tutorial protected override void OnRenderFrame( FrameEventArgs e ) { - this.Title = WindowTitle + " fps: " + ( 1f / e.Time ); + this.Title = WindowTitle + " fps: " + ( 1f / e.Time ).ToString("0."); MySphereZOffset += (float)( e.Time * 3.1 ); MySphereXOffset += (float)( e.Time * 4.2 ); @@ -284,9 +281,10 @@ namespace Examples.Tutorial if ( ShowDebugWireFrame ) { + GL.Color3(System.Drawing.Color.LightGray); GL.Disable( EnableCap.StencilTest ); GL.Disable( EnableCap.Lighting ); - GL.Disable( EnableCap.DepthTest ); + //GL.Disable( EnableCap.DepthTest ); GL.PolygonMode( MaterialFace.Front, PolygonMode.Line ); DrawOperandB(); GL.PolygonMode( MaterialFace.Front, PolygonMode.Fill ); diff --git a/Source/Examples/OpenGL/1.1/TextureMatrix.cs b/Source/Examples/OpenGL/1.1/TextureMatrix.cs index 615c132d..950a5559 100644 --- a/Source/Examples/OpenGL/1.1/TextureMatrix.cs +++ b/Source/Examples/OpenGL/1.1/TextureMatrix.cs @@ -78,7 +78,7 @@ namespace Examples.Tutorial { GL.Viewport(this.ClientRectangle); - Matrix4 projection = Matrix4.Perspective(45.0f, Width / (float)Height, 1.0f, 50.0f); + Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 1.0f, 50.0f); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection); } diff --git a/Source/Examples/OpenGL/GLSL/DDSCubeMap.cs b/Source/Examples/OpenGL/GLSL/DDSCubeMap.cs index 77ca65d6..2ae44c36 100644 --- a/Source/Examples/OpenGL/GLSL/DDSCubeMap.cs +++ b/Source/Examples/OpenGL/GLSL/DDSCubeMap.cs @@ -49,7 +49,7 @@ namespace Examples.Tutorial DrawableShape sphere; // Camera - Vector3 EyePos = new Vector3( 0.0f, 0.0f, 3.0f ); + Vector3 EyePos = new Vector3( 0.0f, 0.0f, 6.0f ); Vector3 Trackball = Vector3.Zero; #endregion internal Fields @@ -60,22 +60,19 @@ namespace Examples.Tutorial { this.VSync = VSyncMode.Off; - /* // Check for necessary capabilities: - if ( !GL.SupportsExtension( "VERSION_2_0" ) ) + string extensions = GL.GetString(StringName.Extensions); + if (!GL.GetString(StringName.Extensions).Contains("GL_ARB_shading_language")) { - MessageBox.Show( "You need at least OpenGL 2.0 to run this example. Aborting.", - "GLSL not supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); - this.Exit( ); + throw new NotSupportedException(String.Format("This example requires OpenGL 2.0. Found {0}. Aborting.", + GL.GetString(StringName.Version).Substring(0, 3))); } - if ( !GL.SupportsExtension( "GL_ARB_texture_compression" ) || - !GL.SupportsExtension( "GL_EXT_texture_compression_s3tc" ) ) + if (!extensions.Contains("GL_ARB_texture_compression") || + !extensions.Contains("GL_EXT_texture_compression_s3tc")) { - MessageBox.Show( "Texture compression extensions not found. Trying to run anyways.", - "Possible problem", MessageBoxButtons.OK, MessageBoxIcon.Warning ); + throw new NotSupportedException("This example requires support for texture compression. Aborting."); } - */ #region GL State @@ -193,7 +190,7 @@ namespace Examples.Tutorial GL.Viewport( 0, 0, Width, Height ); GL.MatrixMode( MatrixMode.Projection ); - Matrix4 p = Matrix4.Perspective( 45.0f, Width / (float) Height, 0.1f, 10.0f ); + Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 10.0f); GL.LoadMatrix(ref p); GL.MatrixMode( MatrixMode.Modelview ); @@ -225,7 +222,7 @@ namespace Examples.Tutorial /// There is no need to call the base implementation. protected override void OnRenderFrame(FrameEventArgs e) { - this.Title = "FPS: " + 1 / e.Time; + this.Title = "FPS: " + (1 / e.Time).ToString("0."); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); diff --git a/Source/Examples/OpenGL/GLSL/SwizzledParallax.cs b/Source/Examples/OpenGL/GLSL/SwizzledParallax.cs index 214d5e09..bf61f260 100644 --- a/Source/Examples/OpenGL/GLSL/SwizzledParallax.cs +++ b/Source/Examples/OpenGL/GLSL/SwizzledParallax.cs @@ -219,7 +219,7 @@ namespace Examples.Tutorial GL.Viewport( 0, 0, Width, Height ); GL.MatrixMode( MatrixMode.Projection ); - Matrix4 p = Matrix4.Perspective( 45.0f, Width / (float) Height, 0.1f, 100.0f ); + Matrix4 p = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Width / (float)Height, 0.1f, 100.0f); GL.LoadMatrix(ref p); GL.MatrixMode( MatrixMode.Modelview ); @@ -281,7 +281,7 @@ namespace Examples.Tutorial /// There is no need to call the base implementation. protected override void OnRenderFrame( FrameEventArgs e ) { - this.Title = "FPS: " + 1 / e.Time; + this.Title = "FPS: " + (1 / e.Time).ToString("0."); GL.Clear( ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit ); diff --git a/Source/Examples/Shapes/Helpers/TetrahedronFace.cs b/Source/Examples/Shapes/Helpers/TetrahedronFace.cs index 3a95bdba..c312a1cd 100644 --- a/Source/Examples/Shapes/Helpers/TetrahedronFace.cs +++ b/Source/Examples/Shapes/Helpers/TetrahedronFace.cs @@ -37,15 +37,15 @@ namespace Examples.Shapes // find the 3 points AB, BC, CA Vector3d CenterAB; Vector3d.Add( ref this.APosition, ref this.BPosition, out temp ); - Vector3d.Mult( ref temp, 0.5f, out CenterAB ); + Vector3d.Multiply( ref temp, 0.5f, out CenterAB ); Vector3d CenterBC; Vector3d.Add( ref this.BPosition, ref this.CPosition, out temp ); - Vector3d.Mult( ref temp, 0.5f, out CenterBC ); + Vector3d.Multiply( ref temp, 0.5f, out CenterBC ); Vector3d CenterCA; Vector3d.Add( ref this.CPosition, ref this.APosition, out temp ); - Vector3d.Mult( ref temp, 0.5f, out CenterCA ); + Vector3d.Multiply( ref temp, 0.5f, out CenterCA ); // find the 3 points AD, BD, CD Vector3d CenterAD; @@ -93,21 +93,21 @@ namespace Examples.Shapes Vector3d.Lerp( ref this.BPosition, ref this.CPosition, 0.5, out CenterBC ); Vector3d.Lerp( ref this.CPosition, ref this.APosition, 0.5, out CenterCA ); CenterD = CenterAB; - CenterD.Add( ref CenterBC ); - CenterD.Add( ref CenterCA ); - CenterD.Div( 3.0 ); + Vector3d.Add(ref CenterD, ref CenterBC, out CenterD); + Vector3d.Add(ref CenterD, ref CenterCA, out CenterD); + CenterD /= 3.0; Vector3d E = CenterD + ( this.Normal * 0.5 ); Vector3d temp = this.Normal; - temp.Mult( height ); - CenterD.Add( temp ); + temp *= height; + Vector3d.Add(ref CenterD, ref temp, out CenterD); Vector2d.Lerp( ref this.ATexCoord, ref this.BTexCoord, 0.5, out TexCoordAB ); Vector2d.Lerp( ref this.BTexCoord, ref this.CTexCoord, 0.5, out TexCoordBC ); Vector2d.Lerp( ref this.CTexCoord, ref this.ATexCoord, 0.5, out TexCoordCA ); TexCoordD = TexCoordAB; - TexCoordD.Add( ref TexCoordBC ); - TexCoordD.Add( ref TexCoordCA ); - TexCoordD.Div( 3.0 ); + Vector2d.Add(ref TexCoordD, ref TexCoordBC, out TexCoordD); + Vector2d.Add(ref TexCoordD, ref TexCoordCA, out TexCoordD); + TexCoordD /= 3.0; #region 1 first.APosition = this.APosition; first.ATexCoord = this.ATexCoord; @@ -120,8 +120,8 @@ namespace Examples.Shapes first.Normal = this.Normal; temp = ( this.APosition + CenterAB + CenterCA ); - temp.Div( 3.0 ); - temp.Add( this.Normal * -1.0 ); + temp /= 3.0; + temp += this.Normal * -1.0; first.DPosition = temp; #endregion 1 #region 2 @@ -137,8 +137,8 @@ namespace Examples.Shapes second.Normal = this.Normal; temp = CenterAB + this.BPosition + CenterBC; - temp.Div( 3.0 ); - temp.Add( this.Normal * -1.0 ); + temp /= 3.0; + temp += this.Normal * -1.0; second.DPosition = temp; #endregion 2 @@ -154,8 +154,8 @@ namespace Examples.Shapes third.Normal = this.Normal; temp = CenterBC + this.CPosition + CenterCA; - temp.Div( 3.0 ); - temp.Add( this.Normal * -1.0 ); + temp /= 3.0; + temp += this.Normal * -1.0; third.DPosition = temp; #endregion 3 #region 4 diff --git a/Source/Examples/Shapes/Old/SierpinskiTetrahedron.cs b/Source/Examples/Shapes/Old/SierpinskiTetrahedron.cs index 2e6aa219..158298cc 100644 --- a/Source/Examples/Shapes/Old/SierpinskiTetrahedron.cs +++ b/Source/Examples/Shapes/Old/SierpinskiTetrahedron.cs @@ -148,24 +148,24 @@ namespace Examples.Shapes { Vector3d temp1, temp2, temp3; - Vector3d.Sub( ref A, ref D, out temp1 ); - Vector3d.Sub( ref B, ref D, out temp2 ); - Vector3d.Sub( ref C, ref D, out temp3 ); + Vector3d.Subtract( ref A, ref D, out temp1 ); + Vector3d.Subtract( ref B, ref D, out temp2 ); + Vector3d.Subtract( ref C, ref D, out temp3 ); Vector3d.Add( ref temp1, ref temp2, out result ); - result.Add( ref temp3 ); + Vector3d.Add(ref result, ref temp3, out result); result.Normalize(); } internal static void FindNormal( ref Vector3d A, ref Vector3d B, ref Vector3d C, out Vector3d result ) { Vector3d temp1, temp2; - Vector3d.Sub( ref A, ref B, out temp1 ); + Vector3d.Subtract( ref A, ref B, out temp1 ); temp1.Normalize(); - Vector3d.Sub( ref C, ref B, out temp2 ); + Vector3d.Subtract(ref C, ref B, out temp2); temp2.Normalize(); Vector3d.Cross( ref temp1, ref temp2, out result ); - result.Mult( -1.0 ); + result *= -1.0; result.Normalize(); } diff --git a/Source/Examples/Shapes/SlicedHose.cs b/Source/Examples/Shapes/SlicedHose.cs index 7cff0c49..b3411ecd 100644 --- a/Source/Examples/Shapes/SlicedHose.cs +++ b/Source/Examples/Shapes/SlicedHose.cs @@ -133,7 +133,7 @@ namespace Examples.Shapes Slerp( ref start, ref end, Multiplier, out temp[i].Normal ); temp[i].Normal.Normalize(); temp[i].Position = temp[i].Normal; - temp[i].Position.Mult( scale ); + temp[i].Position *= scale; } VertexArray = new VertexT2dN3dV3d[temp.Length * 2]; @@ -184,8 +184,8 @@ namespace Examples.Shapes double t2 = System.Math.Sin( ( 1.0 - factor ) * theta ) * temp; double t3 = System.Math.Sin( factor * theta ) * temp; - Vector3d v1 = Vector3d.Mult( a, t2); - Vector3d v2 = Vector3d.Mult( b, t3 ); + Vector3d v1 = Vector3d.Multiply( a, t2); + Vector3d v2 = Vector3d.Multiply( b, t3 ); result = Vector3d.Add( v1, v2 ); } diff --git a/Source/Examples/Shapes/SlicedSphere.cs b/Source/Examples/Shapes/SlicedSphere.cs index 732c7831..23ea573e 100644 --- a/Source/Examples/Shapes/SlicedSphere.cs +++ b/Source/Examples/Shapes/SlicedSphere.cs @@ -93,7 +93,7 @@ namespace Examples.Shapes for (int i=0; i