Пример #1
0
        /// <summary>
        /// Handles the OpenGLDraw event of the openGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param>
        private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
        {
            //  Get the OpenGL object.
            OpenGL gl = openGLControl.OpenGL;

            //  Clear the color and depth buffer.
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //  Load the identity matrix.
            gl.LoadIdentity();

            //  Rotate around the Y axis.
            gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);

            //  Draw a coloured pyramid.
            DrawPyramid(gl);

            gl.LineWidth(3);// LINES
            this.legacyModel.RenderLegacyOpenGL(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PointSize(20);// POINTS
            this.vertexArrayModel.RenderVertexArray(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.LineWidth(1);// LINE_STRIP
            SharpGL.SceneGraph.Core.IRenderable renderable = this.element;
            renderable.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            //  Nudge the rotation.
            rotation += 3.0f;
        }
        /// <summary>
        /// Render the element that inherts <see cref="IColorCodedPicking"/> for color coded picking.
        /// </summary>
        /// <param name="picking"></param>
        /// <param name="gl"></param>
        /// <param name="renderMode"></param>
        public virtual void RenderForPicking(IColorCodedPicking picking, OpenGL gl, SceneGraph.Core.RenderMode renderMode)
        {
            if (picking != null)
            {
                picking.PickingBaseID = this.RenderedVertexCount;

                //  render the element.
                SharpGL.SceneGraph.Core.IRenderable renderable = picking;
                renderable.Render(gl, renderMode);

                uint rendered = this.RenderedVertexCount + picking.GetVertexCount();
                if (this.RenderedVertexCount <= rendered)
                {
                    this.RenderedVertexCount = rendered;
                }
                else
                {
                    throw new OverflowException(
                              string.Format("Too many geometries({0} + {1} > {2}) for color coded picking.",
                                            this.RenderedVertexCount, picking.GetVertexCount(), uint.MaxValue));
                }
            }
        }