Exemplo n.º 1
0
        public void Render(StereoMode mode)
        {
#if true
            float[]      offset           = { -1.0f, 1.0f };
            float        stereoSeparation = sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0];
            IFramebuffer framebuffer      = views[0];
            for (int viewIndex = 0; viewIndex < 2; ++viewIndex)
            {
                framebuffer = views[viewIndex];

                renderer.Requested.Camera   = sceneManager.Camera;
                renderer.Requested.Viewport = framebuffer.Viewport;
                framebuffer.Begin();
                //framebufferManager.Default.Begin();

                sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0] = offset[viewIndex] * stereoSeparation;
                mainSceneRenderer.Render(viewIndex);
                framebuffer.End();
            }
            sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0] = stereoSeparation;
#endif

#if true
            Debug.WriteLine("=== Render Stereo Combine");

            renderer.Requested.Viewport = highLevelRenderer.WindowViewport;
            renderer.Requested.Camera   = sceneManager.Camera;
            renderer.RenderCurrentClear();

            highLevelRenderer.Use2DCamera();

            renderer.Requested.Mesh     = quadRenderer.Mesh;
            renderer.Requested.Material = stereoMerge;
            renderer.Requested.Program  = (mode != null && mode.Program != null) ? mode.Program : blend;
            renderer.Requested.MeshMode = MeshMode.PolygonFill;
            renderer.SetFrame(renderer.DefaultFrame);
            renderer.SetTexture("t_left", views[0][FramebufferAttachment.ColorAttachment0]);
            renderer.SetTexture("t_right", views[1][FramebufferAttachment.ColorAttachment0]);
            renderer.RenderCurrent();
#endif
        }
Exemplo n.º 2
0
        public void Render()
        {
            int px, py;

            MouseInScreen(out px, out py);

            Debug.WriteLine("=== Render");

            HandleResize();

            renderer.Global.Floats("add_color").Set(0.0f, 0.0f, 0.0f);
            renderer.Global.Floats("alpha").Set(1.0f);
            renderer.Global.Sync();

            // \todo LineRenderer should have Clear()
            if (lineRenderer != null)
            {
                lineRenderer.Begin();
                lineRenderer.End();
            }

            if (true)
            {
                #region Id
                if (
                    (selectionManager != null) &&
                    (RuntimeConfiguration.disableReadPixels == false)
                    )
                {
                    if (Configuration.idBuffer && (idRenderer != null))
                    {
                        using (var t = new TimerScope(timers.ID))
                        {
                            idRenderer.Render(px, py);
                            selectionManager.ProcessIdBuffer(idRenderer.Hover, px, py);
                        }
                    }

                    selectionManager.Update(px, py);
                }
                #endregion
                #region Shadowmaps
                if (sceneManager.UpdateShadowMap && (RenderStack.Graphics.Configuration.useGl1 == false))
                {
                    using (var t = new TimerScope(timers.Shadow))
                    {
                        shadowRenderer.UpdateShadowMaps();
                    }
                }
                #endregion
                #region CurveTool RenderT
                if ((curveTool != null) && curveTool.Enabled)
                {
                    if (RenderStack.Graphics.Configuration.useGl1 == false)
                    {
                        curveTool.RenderT(px, py, sceneManager.Camera);
                    }
                    curveTool.CheckForUpdates();
                }
                #endregion
                #region Main scene mono/stereo
                using (var t = new TimerScope(timers.Render3D))
                {
                    renderer.PartialGLStateResetToDefaults();
                    if (RenderStack.Graphics.Configuration.useGl1 == false)
                    {
                        renderer.SetTexture("t_shadowmap", shadowRenderer.ShadowMap);
                    }

                    StereoMode mode = (userInterfaceManager != null) ? userInterfaceManager.CurrentStereoMode : null;
                    if ((mode != null) && (mode.Program != null) && (mode.Program.Valid == true))
                    {
                        stereoscopicRenderer.Render(mode);
                    }
                    else
                    {
                        renderer.Requested.Viewport = windowViewport;
                        renderer.Requested.Camera   = sceneManager.Camera;
                        renderer.Requested.Viewport = windowViewport;
                        if (RenderStack.Graphics.Configuration.canUseFramebufferObject)
                        {
                            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                        }
                        mainSceneRenderer.Render(0);
                    }
                }
                #endregion
                #region voxelTest
                if (Configuration.voxelTest)
                {
                    voxelEditor.RenderCubes(px, py, sceneManager.Camera);
                }
                #endregion
            }
            else
            {
                #region Alternative path without normal 3d scene
                // path without normal 3d scene
                renderer.Requested.Viewport = windowViewport;
                renderer.Requested.Camera   = sceneManager.Camera;
                renderer.Requested.Viewport = windowViewport;
                if (RenderStack.Graphics.Configuration.canUseFramebufferObject)
                {
                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                }
                renderer.RenderCurrentClear();
                renderer.ApplyViewport();
                #endregion
            }

            renderer.Requested.Viewport = windowViewport;
            renderer.Requested.Camera   = sceneManager.Camera;
            renderer.Requested.Viewport = windowViewport;
            renderer.ApplyViewport();

            if (RuntimeConfiguration.debugInfo && Configuration.graphicalUserInterface)
            {
                using (var t = new TimerScope(timers.GUI))
                {
                    userInterfaceManager.Render();
                }
            }

            window.SwapBuffers();
        }