// This gets called when the drawing surface is ready protected override void OnLoad(EventArgs e) { base.OnLoad(e); SolidColorMeshShader.Load(); SolidColorMeshShader.SharedInstance.Use(); GL.Viewport(0, 0, Width, Height); Matrix4 mat = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(40.0f), (float)Width / (float)Height, 1.0f, 10000.0f); camera.SetProjection( mat.M11, mat.M12, mat.M13, mat.M14, mat.M21, mat.M22, mat.M23, mat.M24, mat.M31, mat.M32, mat.M33, mat.M34, mat.M41, mat.M42, mat.M43, mat.M44 ); cameraUp = new Vector4(0.0f, 1.0f, 0.0f, 1.0f); cameraRight = new Vector4(1.0f, 0.0f, 0.0f, 1.0f); cameraPos = new Vector4(0.0f, 10.0f, 40.0f, 1.0f); mat = Matrix4.LookAt(cameraPos.Xyz, Vector3.Zero, cameraUp.Xyz); camera.SetView( mat.M11, mat.M12, mat.M13, mat.M14, mat.M21, mat.M22, mat.M23, mat.M24, mat.M31, mat.M32, mat.M33, mat.M34, mat.M41, mat.M42, mat.M43, mat.M44 ); //sphere = ShapeGenerator.MakeCube<VertexPositioned>(SolidColorMeshShader.SharedInstance, VertexFormat.Position); sphere = ShapeGenerator.MakeSphere2 <VertexPositioned>( 10, 20, Axii.Y, (int)All.Lines, SolidColorMeshShader.SharedInstance, VertexFormat.Position ); mat = Matrix4.Scale(1.0f); World3DShaderTransform worldTrans = new World3DShaderTransform(); worldTrans.SetWorld( mat.M11, mat.M12, mat.M13, mat.M14, mat.M21, mat.M22, mat.M23, mat.M24, mat.M31, mat.M32, mat.M33, mat.M34, mat.M41, mat.M42, mat.M43, mat.M44 ); sphere.Transform = worldTrans; SolidColorShaderMaterial material = new SolidColorShaderMaterial(); material.SetColor(0.0f, 1.0f, 1.0f, 1.0f); sphere.DefaultMaterial = sphere.Parts[0].Material = material; // Run the render loop Run(); }