예제 #1
0
        public override void Draw(SceneGraph.Cameras.Camera camera = null)
        {
            var gl = OpenGL;

            if (gl == null)
            {
                return;
            }

            //  TODO: we must decide what to do about drawing - are
            //  cameras completely outside of the responsibility of the scene?
            //  If no camera has been provided, use the current one.
            ScientificCamera currentCamera = this.CurrentCamera;

            currentCamera.Project(gl, ECameraType.Ortho);

            //gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);

            //  Render the root element, this will then render the whole
            //  of the scene tree.
            MyRenderElement(SceneContainer, gl, RenderMode.Design);

            //  TODO: Adding this code here re-enables textures- it should work without it but it
            //  doesn't, look into this.
            //gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
            //gl.Enable(OpenGL.GL_TEXTURE_2D);

            gl.Flush();
        }
예제 #2
0
        /// <summary>
        /// Draw the scene.
        /// </summary>
        /// <param name="renderMode">Use Render for normal rendering and HitTest for picking.</param>
        /// <param name="camera">Keep this to null if <see cref="CurrentCamera"/> is already set up.</param>
        public void Draw(RenderMode renderMode = RenderMode.Render, SceneGraph.Cameras.Camera camera = null)
        {
            var gl = OpenGL;

            if (gl == null)
            {
                return;
            }

            //  TODO: we must decide what to do about drawing - are
            //  cameras completely outside of the responsibility of the scene?
            //  If no camera has been provided, use the current one.
            if (camera == null)
            {
                camera = CurrentCamera;
            }

            if (IsClear)
            {
                if (renderMode == RenderMode.HitTest)
                {
                    // When picking on a position that no model exists,
                    // the picked color would be
                    // = 255
                    // + 255 << 8
                    // + 255 << 16
                    // + 255 << 24
                    // = 255
                    // + 65280
                    // + 16711680
                    // + 4278190080
                    // = 4294967295
                    // This makes it easier to determin whether we picked something or not.
                    gl.ClearColor(1, 1, 1, 1);
                }
                else
                {
                    //	Set the clear color.
                    float[] clear = (SharpGL.SceneGraph.GLColor)ClearColor;

                    gl.ClearColor(clear[0], clear[1], clear[2], clear[3]);
                }
            }

            //  Reproject.
            if (camera != null)
            {
                camera.Project(gl);
            }

            if (IsClear)
            {
                //	Clear.
                gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT |
                         OpenGL.GL_STENCIL_BUFFER_BIT);
            }

            //gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);

            SharedStageInfo info = this.StageInfo;

            info.Reset();

            //  Render the root element, this will then render the whole
            //  of the scene tree.
            MyRenderElement(SceneContainer, gl, renderMode, info);

            //  TODO: Adding this code here re-enables textures- it should work without it but it
            //  doesn't, look into this.
            //gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
            //gl.Enable(OpenGL.GL_TEXTURE_2D);

            gl.Flush();
        }