using SharpGL; using SharpGL.SceneGraph.Assets; using SharpGL.SceneGraph.Effects; using SharpGL.SceneGraph.Lighting; using SharpGL.SceneGraph.Primitives; using SharpGL.SceneGraph.Quadrics; namespace Yw.WinFrmUI.HydroL3d { public partial class NetworkScenePanel : DevExpress.XtraEditors.XtraUserControl { public NetworkScenePanel() { InitializeComponent(); } private void sceneControl1_OpenGLDraw(object sender, RenderEventArgs args) { //// 获取 OpenGL 对象 //var gl = sceneControl.OpenGL; //// 清除颜色和深度缓冲区 //gl.ClearColor(0.2f, 0.3f, 0.3f, 1.0f); //gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); SharpGL.SceneGraph.Quadrics.Sphere sphere = new SharpGL.SceneGraph.Quadrics.Sphere(); sphere.Transformation.TranslateX = 2; sphere.Transformation.TranslateY = 2; // Create a cone. SharpGL.SceneGraph.Quadrics.Cylinder cone = new SharpGL.SceneGraph.Quadrics.Cylinder() { Name = "Cone" }; cone.BaseRadius = 1.5; cone.TopRadius = 0; cone.Height = 2; cone.Transformation.TranslateX = -2; cone.Transformation.TranslateY = -2; // Create a cylinder. SharpGL.SceneGraph.Quadrics.Cylinder cylinder = new SharpGL.SceneGraph.Quadrics.Cylinder() { Name = "Cylinder" }; cylinder.BaseRadius = 1.5; cylinder.TopRadius = 1.5; cylinder.Height = 2; cylinder.Transformation.TranslateX = -2; cylinder.Transformation.TranslateY = 2; // Create a cube. Cube cube = new Cube(); cube.Transformation.TranslateX = 2; cube.Transformation.TranslateY = -2; cube.Transformation.RotateZ = 45f; // Add them. sceneControl.Scene.SceneContainer.AddChild(sphere); sceneControl.Scene.SceneContainer.AddChild(cube); sceneControl.Scene.SceneContainer.AddChild(cone); sceneControl.Scene.SceneContainer.AddChild(cylinder); this.sceneControl.Invalidate(); } private void sceneControl1_Resized(object sender, EventArgs e) { } private void sceneControl1_Load(object sender, EventArgs e) { // Create a sphere. } } }