private void SampleGraphicsControl_GraphicsContextCreated(object sender, GraphicsControlEventArgs e) { GraphicsContext ctx = e.Context; GraphicsSurface framebuffer = e.Framebuffer; #if DEBUG _GeometryClipmapObject = new GeometryClipmapObject(6, 7, _BlockUnit); #else _GeometryClipmapObject = new GeometryClipmapObject(9, 11, _BlockUnit); #endif string workingDir = Directory.GetCurrentDirectory(); _GeometryClipmapObject.SetTerrainElevationFactory(Path.Combine(workingDir, @"..\..\..\Data\Terrain.vrt"), 45.5, 10.5); _GeometryClipmapScene = new SceneGraph(); _GeometryClipmapScene.AddChild(new SceneGraphCameraObject()); _GeometryClipmapScene.AddChild(_GeometryClipmapObject); _GeometryClipmapScene.Create(ctx); // Set projection _GeometryClipmapScene.CurrentView.ProjectionMatrix = new PerspectiveProjectionMatrix( _ViewFov / 16.0f * 9.0f, (float)ClientSize.Width / (float)ClientSize.Height, 1.0f, _ViewDepth );; // Clear color framebuffer.SetClearColor(new ColorRGBAF(0.0f, 0.0f, 0.0f)); }
private void SampleGraphicsControl_GraphicsContextCreated(object sender, GraphicsControlEventArgs e) { GraphicsContext ctx = e.Context; GraphicsSurface framebuffer = e.Framebuffer; // Create Newton program _NewtonProgram = ShadersLibrary.Instance.CreateProgram("Newton"); _NewtonProgram.AddFeedbackVarying("hal_VertexPosition"); _NewtonProgram.AddFeedbackVarying("hal_VertexSpeed"); _NewtonProgram.AddFeedbackVarying("hal_VertexAcceleration"); _NewtonProgram.AddFeedbackVarying("hal_VertexMass"); _NewtonProgram.Create(ctx); // Initialize first vertex array NewtonVertex[] newtonArray = new NewtonVertex[VertexCount]; Random random = new Random(); for (int i = 0; i < newtonArray.Length; i++) { NewtonVertex newtonVertex = new NewtonVertex(); newtonVertex.Position = new Vertex3f(RandomNormalized(), RandomNormalized(), RandomNormalized()); newtonVertex.Speed = new Vertex3f(RandomNormalized(), RandomNormalized(), RandomNormalized()); newtonVertex.Acceleration = new Vertex3f(); newtonVertex.Mass = RandomNormalized(); newtonArray[i] = newtonVertex; } // Create vertex arrays ArrayBufferObjectBase newtonVertexArrayBuffer1, newtonVertexArrayBuffer2; _NewtonVertexArray1 = CreateVertexArray(newtonArray, out newtonVertexArrayBuffer1); _NewtonVertexArray2 = CreateVertexArray(null, out newtonVertexArrayBuffer2); _NewtonVertexArray1.SetTransformFeedback(CreateFeedbackBuffer(newtonVertexArrayBuffer2)); _NewtonVertexArray2.SetTransformFeedback(CreateFeedbackBuffer(newtonVertexArrayBuffer1)); _NewtonVertexArray1.Create(ctx); _NewtonVertexArray2.Create(ctx); // Starts from initialized buffer _NewtonVertexArray = _NewtonVertexArray1; // Clear color framebuffer.SetClearColor(new ColorRGBAF(0.0f, 0.0f, 0.0f)); }