コード例 #1
0
        bool CreateRenderTarget()
        {
            DestroyRenderTarget();

            if (RendererWorld.Instance == null)
            {
                return(false);
            }

            Vec2I size = new Vec2I(ClientRectangle.Size.Width, ClientRectangle.Size.Height);

            if (size.X < 1 || size.Y < 1)
            {
                return(false);
            }

            renderWindow = RendererWorld.Instance.CreateRenderWindow(Handle, size);
            if (renderWindow == null)
            {
                return(false);
            }

            renderWindow.AutoUpdate          = false;
            renderWindow.AllowAdditionalMRTs = true;

            camera = SceneManager.Instance.CreateCamera(
                SceneManager.Instance.GetUniqueCameraName("UserControl"));
            camera.Purpose = Camera.Purposes.MainCamera;

            //update camera settings
            camera.NearClipDistance = cameraNearFarClipDistance.Minimum;
            camera.FarClipDistance  = cameraNearFarClipDistance.Maximum;
            camera.AspectRatio      = (float)renderWindow.Size.X / (float)renderWindow.Size.Y;
            camera.FixedUp          = cameraFixedUp;
            camera.Position         = cameraPosition;
            camera.Direction        = cameraDirection;
            camera.Fov               = cameraFov;
            camera.ProjectionType    = cameraProjectionType;
            camera.OrthoWindowHeight = cameraOrthoWindowHeight;

            viewport = renderWindow.AddViewport(camera);

            //Initialize HDR compositor for HDR render technique
            if (EngineApp.RenderTechnique == "HDR")
            {
                viewport.AddCompositor("HDR", 0);
                viewport.SetCompositorEnabled("HDR", true);
            }

            //Initialize Fast Approximate Antialiasing (FXAA)
            {
                bool   useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering;
                string fsaa   = RendererWorld.InitializationOptions.FullSceneAntialiasing;
                if ((useMRT && (fsaa == "" || fsaa == "RecommendedSetting") && IsActivateFXAAByDefault()) ||
                    fsaa == "FXAA")
                {
                    if (RenderSystem.Instance.HasShaderModel3())
                    {
                        InitializeFXAACompositor();
                    }
                }
            }

            //add listener
            renderTargetListener = new ViewRenderTargetListener(this);
            renderWindow.AddListener(renderTargetListener);

            if (guiRenderer == null)
            {
                guiRenderer = new GuiRenderer(viewport);
            }
            else
            {
                guiRenderer.ChangeViewport(viewport);
            }

            if (controlManager == null)
            {
                controlManager = new ScreenControlManager(guiRenderer);
            }

            return(true);
        }
コード例 #2
0
        private bool CreateRenderTarget()
        {
            DestroyRenderTarget();

            if (RendererWorld.Instance == null)
                return false;

            Vec2I size = new Vec2I(ClientRectangle.Size.Width, ClientRectangle.Size.Height);
            if (size.X < 1 || size.Y < 1)
                return false;

            renderWindow = RendererWorld.Instance.CreateRenderWindow(Handle, size);
            if (renderWindow == null)
                return false;

            renderWindow.AutoUpdate = false;
            renderWindow.AllowAdditionalMRTs = true;

            camera = SceneManager.Instance.CreateCamera(
                SceneManager.Instance.GetUniqueCameraName("UserControl"));
            camera.Purpose = Camera.Purposes.MainCamera;

            //update camera settings
            camera.NearClipDistance = cameraNearFarClipDistance.Minimum;
            camera.FarClipDistance = cameraNearFarClipDistance.Maximum;
            camera.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y;
            camera.FixedUp = cameraFixedUp;
            camera.Position = cameraPosition;
            camera.Direction = cameraDirection;
            camera.Fov = cameraFov;
            camera.ProjectionType = cameraProjectionType;
            camera.OrthoWindowHeight = cameraOrthoWindowHeight;

            viewport = renderWindow.AddViewport(camera);

            //Initialize HDR compositor for HDR render technique
            if (EngineApp.RenderTechnique == "HDR")
            {
                viewport.AddCompositor("HDR", 0);
                viewport.SetCompositorEnabled("HDR", true);
            }

            //Initialize Fast Approximate Antialiasing (FXAA)
            {
                bool useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering;
                string fsaa = RendererWorld.InitializationOptions.FullSceneAntialiasing;
                if ((useMRT && (fsaa == "" || fsaa == "RecommendedSetting") && IsActivateFXAAByDefault()) ||
                    fsaa == "FXAA")
                {
                    if (RenderSystem.Instance.HasShaderModel3())
                        InitializeFXAACompositor();
                }
            }

            //add listener
            renderTargetListener = new ViewRenderTargetListener(this);
            renderWindow.AddListener(renderTargetListener);

            if (guiRenderer == null)
                guiRenderer = new GuiRenderer(viewport);
            else
                guiRenderer.ChangeViewport(viewport);

            if (controlManager == null)
                controlManager = new ScreenControlManager(guiRenderer);

            return true;
        }