// Secțiunea de randare a scenei 3D pe controlul GL. Este declanșată de invalidarea acestuia la // utilizarea metodei "Invalidate()" (printre altele). Randarea aceasta se poate face programatic // (de către sistem) când acesta are nevoie, sau comandat dacă am făcut vreo actualizate în mod // explicit în modelul 3D. private void GlControlDemo_Paint(object sender, PaintEventArgs e) { GlControlDemo.MakeCurrent(); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Clear(ClearBufferMask.DepthBufferBit); //Setări preliminară pentru mediul 3D. //GL.MatrixMode(MatrixMode.Projection); //GL.LoadIdentity(); //GL.Ortho(0, 0, 0, 0, -1, 1); //GL.MatrixMode(MatrixMode.Projection); //GL.LoadIdentity(); //float halfWidth = (float)(this.GlControlDemo.Width / 2); //float halfHeight = (float)(this.GlControlDemo.Height / 2); //GL.Ortho(-halfWidth, halfWidth, halfHeight, -halfHeight, 1000, -1000); //GL.Viewport(this.GlControlDemo.Size); Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref lookat); GL.Enable(EnableCap.DepthTest); //Corecții de adâncime. GL.DepthFunc(DepthFunction.Less); /* * // Controlul rotației cu mouse-ul (2D). * if (mouse2DControlStat == true) { * GL.Rotate(mousePos.X, 0, 1, 0); * } * // Controlul rotației cu mouse-ul (3D). * if (mouse2DControlStat == true) { * GL.Rotate(mousePos.X, 0, 1, 1); * } */ GenerateAxes(); GlControlDemo.SwapBuffers(); }
private void BtnBKG_Blue_Click(object sender, EventArgs e) { GL.ClearColor(Color.MidnightBlue); GlControlDemo.Invalidate(); }
private void BtnBKG_Green_Click(object sender, EventArgs e) { GL.ClearColor(Color.IndianRed); GlControlDemo.Invalidate(); }
private void BtnBKG_Black_Click(object sender, EventArgs e) { GL.ClearColor(Color.Black); GlControlDemo.Invalidate(); }