Exemplo n.º 1
0
 public void setRenderTargets(RenderTargetCollection collection)
 {
     RenderTargetBinding[] renderTargets = new RenderTargetBinding[collection.Targets.Length]; // collection.Targets.Length
     bool none = true;
     for (int i = 0; i < collection.Targets.Length; ++i)
     {
         if (collection.Targets[i] is RenderTarget2D)
         {
             renderTargets[i] = collection.Targets[i] as RenderTarget2D;
             none = false;
         }
     }
     if (none)
         GraphicsDevice.SetRenderTargets(null);
     else
         GraphicsDevice.SetRenderTargets(renderTargets);
 }
Exemplo n.º 2
0
 public void pushRenderTargets(RenderTargetCollection collection)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // register elements
            IObjectBuilder objectBuilder = Game.Services.GetService(typeof(IObjectBuilder)) as IObjectBuilder;
            if (objectBuilder != null)
            {
                registerElements(objectBuilder);
            }

            // performance
            PerformanceMonitor perfMon = Game.Services.GetService(typeof(PerformanceMonitor)) as PerformanceMonitor;
            if (perfMon != null)
            {
                m_mainTimer = perfMon.addPerformanceMeter(new XnaScrapId("CBeroRenderManager"));
                m_sceneTimer = m_mainTimer.addSubTimer("Scene");
                m_overlayTimer = m_mainTimer.addSubTimer("Overlays");
            }

            #if WINDOWS
            // register REST stuff
            NetCtrlService netCtrlService = Game.Services.GetService(typeof(NetCtrlService)) as NetCtrlService;
            if (netCtrlService != null)
            {
                netCtrlService.AddServiceNode(new RenderManagerNode(this), this);
            }
            #endif
            base.Initialize();
            m_spriteBatch = new SpriteBatch(GraphicsDevice);
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            #region materials
            BasicEffect basicEffect = new BasicEffect(GraphicsDevice);
            basicEffect.EnableDefaultLighting();
            basicEffect.PreferPerPixelLighting = true;
            m_basicEffectMaterial.Effect = basicEffect;
            m_basicEffectMaterial.Technique = basicEffect.Techniques.First().Name;
            Material.ParameterMapping worldviewprojection = new Material.ParameterMapping();
            worldviewprojection.name = "WorldViewProj";
            worldviewprojection.perInstance = true;
            worldviewprojection.semantic = Material.ShaderParameterSemantic.MODEL_VIEW_PROJECTION_MATRIX;
            m_basicEffectMaterial.ParameterMappings.Add(worldviewprojection);

            SkinnedEffect skinnedEffect = new SkinnedEffect(GraphicsDevice);
            skinnedEffect.EnableDefaultLighting();
            m_skinnedEffectMaterial.Effect = skinnedEffect;
            m_skinnedEffectMaterial.Technique = skinnedEffect.Techniques.First().Name;

            RenderState.PushMaterial(m_basicEffectMaterial);
            #endregion

            #region effects
            m_defaultEffect = new CBeroEffect(this);
            m_defaultCollection = new RenderTargetCollection(DefaultRenderTarget.GetInstance().Id, new IRenderTarget[] { DefaultRenderTarget.GetInstance() });
            m_defaultCollection.Effect = m_defaultEffect;
            m_defaultEffect.AddPass(new RenderSceneWithMaterialsPass(this, m_defaultCollection));
            m_defaultEffect.AddPass(new RenderOverlaysPass(this, m_defaultCollection));

            // add DefaultRenderTarget
            m_renderTargets.Add(DefaultRenderTarget.GetInstance().Id, m_defaultCollection);
            #endregion
        }
Exemplo n.º 4
0
        public bool addRemoteRenderTarget(  IntPtr overrideWindowHandle,
            Nullable<Rectangle> sourceRectangle = null,
            Nullable<Rectangle> destinationRectangle = null
            )
        {
            RemoteWindowRenderTarget remoteTarget = new RemoteWindowRenderTarget(sourceRectangle, destinationRectangle, overrideWindowHandle, GraphicsDevice);
            CBeroEffect effect = new CBeroEffect(this);
            RenderTargetCollection remoteCollection = new RenderTargetCollection(remoteTarget.Id, new IRenderTarget[] { remoteTarget });
            remoteCollection.Effect = effect;
            effect.AddPass(new RenderSceneWithMaterialsPass(this, remoteCollection));
            effect.AddPass(new RenderOverlaysPass(this, remoteCollection));

            remoteTarget.Cameras.Add(m_defaultCollection.Cameras.First());

            // add DefaultRenderTarget
            m_renderTargets.Add(remoteTarget.Id, remoteCollection);
            return true;
        }
 public RenderSceneWithMaterialsPass(RenderManager renderManager, RenderTargetCollection output)
 {
     m_renderManager = renderManager;
     m_outputs = output;
 }
Exemplo n.º 6
0
 public RenderOverlaysPass(RenderManager renderManager, RenderTargetCollection output)
 {
     m_renderManager = renderManager;
     m_outputs = output;
 }