Ejemplo n.º 1
0
        public override void PrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks, VertexBuffer vb)
        {
            if (MyModel != null)
            {
                foreach (Mesh msh in MyModel.Meshes)
                {
                    msh.m_VertexBufferArray.BindVertexBufferArray();

                    vb.BindBuffer();

                    foreach (VertexBufferLayoutKind vblk in vblks)
                    {
                        rc.EnableVertexAttribute((int)vblk.AttributeID);
                        rc.VertexAttributePointer(vblk);
                        rc.VertexAttributeDivisor((int)vblk.AttributeID, 1);
                    }

                    vb.UnbindBuffer();

                    msh.m_VertexBufferArray.UnbindVertexBufferArray();
                }
            }
            else
                this.ErrorCount++;
        }
Ejemplo n.º 2
0
 public override void DrawInstanced(RendererContext rc, int count)
 {
     if (MyModel != null)
     {
         MyModel.EnableLighting = !NoLighting;
         rc.DrawModel(MyModel, count == 1 ? WorldMatrix : FreezingArcher.Math.Matrix.Identity, count, Scene);
     }
     else
         this.ErrorCount++;
 }
Ejemplo n.º 3
0
 public override void Draw(RendererContext rc)
 {
     if (MyModel != null)
     {
         MyModel.EnableLighting = !NoLighting;
         rc.DrawModel(MyModel, this.WorldMatrix, 1, Scene);
     }
     else
         this.ErrorCount++;
 }
Ejemplo n.º 4
0
        public override void Draw(RendererContext rc)
        {
            Vector2 pos = Position.Xy;
            Vector2 size = Scaling.Xy;
            Color4 col = Color;

            if (!Filled)
                rc.DrawRectangleAbsolute(ref pos, ref size, LineWidth, ref col);
            else
                rc.DrawFilledRectangleAbsolute(ref pos, ref size, ref col, 1);
        }
Ejemplo n.º 5
0
        public override void DrawInstanced(RendererContext rc, int count)
        {
            Vector2 pos = Vector2.Zero;
            Vector2 size = new Vector2(1, 1);
            Color4 col = new Color4(0, 0, 0, 0);

            if (!Filled)
                rc.DrawRectangleAbsolute(ref pos, ref size, LineWidth, ref col);
            else
                rc.DrawFilledRectangleAbsolute(ref pos, ref size, ref col, count);
        }
Ejemplo n.º 6
0
        public BasicCompositor(ObjectManager objm, RendererContext rc)
        {
            graphLock = new object();

            _CompositorGraph = objm.CreateOrRecycle<DirectedWeightedGraph<CompositorNode, CompositorEdgeDescriptionListWrapper>>();
            _CompositorGraph.Init();

            _Nodes = new List<DirectedWeightedNode<CompositorNode, CompositorEdgeDescriptionListWrapper>>();
            _Edges = new List<DirectedWeightedEdge<CompositorNode, CompositorEdgeDescriptionListWrapper>>();

            DummyNode = _CompositorGraph.AddNode(null);

            RendererContext = rc;
        }
        public void ThreadFunction()
        {
            if (this.srcArgs.Surface.Scan0.MaySetAllowWrites)
            {
                this.srcArgs.Surface.Scan0.AllowWrites = false;
            }

            try
            {
                if (tileCount > 0)
                {
                    Rectangle[] subRegion = this.tileRegions[0];

                    this.effect.Render(this.effectTokenCopy, this.dstArgs, this.srcArgs, subRegion);

                    PdnRegion subPdnRegion = this.tilePdnRegions[0];
                    OnRenderedTile(new RenderedTileEventArgs(subPdnRegion, this.tileCount, 0));
                }

                EffectConfigToken[] tokens = new EffectConfigToken[workerThreads];

                int i;
                for (i = 0; i < workerThreads; ++i)
                {
                    if (this.threadShouldStop)
                    {
                        break;
                    }

                    if (this.effectTokenCopy == null)
                    {
                        tokens[i] = null;
                    }
                    else
                    {
                        tokens[i] = (EffectConfigToken)this.effectTokenCopy.Clone();
                    }

                    RendererContext rc = new RendererContext(this, tokens[i], i, (i == 0) ? 1 : 0);
                    threadPool.QueueUserWorkItem(new WaitCallback(rc.Renderer2));
                }

                if (i == workerThreads)
                {
                    threadPool.Drain();
                    OnFinishedRendering();
                }
            }

            catch (Exception ex)
            {
                this.exceptions.Add(ex);
            }

            finally
            {
                threadPool.Drain();

                Exception[] newExceptions = threadPool.Exceptions;

                if (newExceptions.Length > 0)
                {
                    foreach (Exception exception in newExceptions)
                    {
                        this.exceptions.Add(exception);
                    }
                }

                if (this.srcArgs.Surface.Scan0.MaySetAllowWrites)
                {
                    this.srcArgs.Surface.Scan0.AllowWrites = true;
                }
            }
        }
Ejemplo n.º 8
0
        public override void PrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks, VertexBuffer vb)
        {
            rc._2DVertexBufferArray.BindVertexBufferArray();

            vb.BindBuffer();

            for (int i = 0; i < vblks.Length; i++)
            {
                rc.EnableVertexAttribute((int)vblks[i].AttributeID);
                rc.VertexAttributePointer(vblks[i]);
                rc.VertexAttributeDivisor((int)vblks[i].AttributeID, 1);
            }

            vb.UnbindBuffer();

            rc._2DVertexBufferArray.UnbindVertexBufferArray();
        }
Ejemplo n.º 9
0
        public virtual void Draw(RendererContext rc)
        {

        }
Ejemplo n.º 10
0
 public CompositorNodeStart(RendererContext rc, Messaging.MessageProvider mp) : base("NodeStart", rc, mp)
 {
 }
Ejemplo n.º 11
0
 internal abstract void Render(VisualElement element, RendererContext context);
Ejemplo n.º 12
0
        public override void Draw(RendererContext rc)
        {
            lock (ListLock)
            {
                //Preparing
                if (InstanceDataVertexBuffer != null && SceneObjects.Count > 0)
                {
                    VertexBufferLayoutKind[] vblk = new VertexBufferLayoutKind[6];

                    //Set information
                    for (int i = 0; i < 4; i++)
                    {
                        VertexBufferLayoutKind v = new VertexBufferLayoutKind();
                        v.AttributeID = (uint)LayoutLocationOffset + (uint)i;
                        v.AttributeSize = 4;
                        v.AttributeType = RendererVertexAttribType.Float;
                        v.Normalized = false;
                        v.Offset = sizeof(float) * 4 * i;
                        v.Stride = SceneObjectArrayInstanceData.SIZE;

                        vblk[i] = v;
                    }

                    vblk[4] = new VertexBufferLayoutKind()
                    {AttributeID = (uint)LayoutLocationOffset + 4, AttributeSize = 4, AttributeType = RendererVertexAttribType.Float,
                        Normalized = false, Offset = sizeof(float) * 4 * 4, Stride = SceneObjectArrayInstanceData.SIZE
                    };

                    vblk[5] = new VertexBufferLayoutKind()
                    {AttributeID = (uint)LayoutLocationOffset + 5, AttributeSize = 4, AttributeType = RendererVertexAttribType.Float,
                        Normalized = false, Offset = sizeof(float) * 4 * 4 + sizeof(float) * 4, Stride = SceneObjectArrayInstanceData.SIZE
                    };

                    //Send it to Renderer
                    SceneObjects[0].PrepareInstanced(rc, vblk, InstanceDataVertexBuffer);
                    SceneObjects[0].DrawInstanced(rc, SceneObjects.Count);
                    SceneObjects[0].UnPrepareInstanced(rc, vblk);
                }
            }
        }
Ejemplo n.º 13
0
 private void ThreadFunction()
 {
     if (this.srcArgs.Surface.Scan0.MaySetAllowWrites)
     {
         this.srcArgs.Surface.Scan0.AllowWrites = false;
     }
     try
     {
         this.threadInitialized.Set();
         this.effect.SetRenderInfo(this.effectTokenCopy, this.dstArgs, this.srcArgs);
         RendererContext context = new RendererContext(this);
         if (this.threadShouldStop)
         {
             this.effect.SignalCancelRequest();
         }
         else if (this.tileCount > 0)
         {
             context.RenderNextTile(this.effectTokenCopy);
         }
         WaitCallback rcwc = new WaitCallback(context.RenderNextTileProc);
         for (int i = 0; i < this.tileCount; i++)
         {
             if (this.threadShouldStop)
             {
                 this.effect.SignalCancelRequest();
                 break;
             }
             EffectConfigToken token = (this.effectTokenCopy == null) ? null : this.effectTokenCopy.CloneT <EffectConfigToken>();
             this.threadPool.Enqueue(() => rcwc(token));
         }
         this.threadPool.Join();
     }
     catch (Exception exception)
     {
         this.exceptions.Add(exception);
     }
     finally
     {
         EffectRendererWorkItemQueue threadPool = this.threadPool;
         if (!this.disposed && (threadPool != null))
         {
             try
             {
                 threadPool.Join();
             }
             catch (Exception)
             {
             }
         }
         this.OnFinishedRendering();
         RenderArgs srcArgs = this.srcArgs;
         if (srcArgs != null)
         {
             Surface surface = srcArgs.Surface;
             if (surface != null)
             {
                 MemoryBlock block = surface.Scan0;
                 if (((block != null) && !this.disposed) && block.MaySetAllowWrites)
                 {
                     try
                     {
                         block.AllowWrites = true;
                     }
                     catch (ObjectDisposedException)
                     {
                     }
                 }
             }
         }
     }
 }
 public CompositorNodeSceneDepthAlphaMerger(RendererContext rc, MessageProvider prov) : base("NodeDepthAlphaMerger", rc, prov)
 {
 }
Ejemplo n.º 15
0
        public CompositorNodeScene(RendererContext rc, MessageProvider prov) : base("NodeStart", rc, prov)
        {
            PostRenderingObjects = new List<SceneObject>();

            ValidMessages = new[] { (int)MessageId.WindowResize };
            prov += this;
        }
Ejemplo n.º 16
0
 public override bool Init(RendererContext rc)
 {
     return base.Init(rc);
 }
Ejemplo n.º 17
0
        public void Write(MetadataSerializer serializer, Utf8JsonWriter writer, object value, IEnumerable <string> valuePath, RendererContext context)
        {
            writer.WriteString("type", "object");
            writer.WriteString("extendedType", MetadataConverter.GetFullName(value.GetType()));

            var dict = value as Dictionary <TKey, TValue>;

            writer.WriteStartObject("children");

            foreach (var kv in dict)
            {
                writer.WriteStartObject(kv.Key.ToString());
                serializer.Serialize(writer, kv.Value, valuePath, context);
                writer.WriteEndObject();
            }

            writer.WriteEndObject();
        }
Ejemplo n.º 18
0
        public override bool Init(RendererContext rc)
        {
            if (!IsInitialized)
            {
                if (LoadModel)
                    MyModel = rc.LoadModel(ModelPath);

                PrivateRendererContext = rc;

                IsInitialized = true;
            }

            return true;
        }
Ejemplo n.º 19
0
 public CompositorNodeOutput(RendererContext rc, Messaging.MessageProvider mp) : base("NodeOutput", rc, mp)
 {
     EnableUI = true;
 }
Ejemplo n.º 20
0
        public override void UnPrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks)
        {
            if (MyModel != null)
            {
                foreach (Mesh msh in MyModel.Meshes)
                {
                    msh.m_VertexBufferArray.BindVertexBufferArray();

                    foreach (VertexBufferLayoutKind vblk in vblks)
                        rc.DisableVertexAttribute((int)vblk.AttributeID);

                    msh.m_VertexBufferArray.UnbindVertexBufferArray();
                }
            }
            else
                this.ErrorCount++;
        }
Ejemplo n.º 21
0
        public override bool Init(RendererContext rc)
        {
            PrivateRendererContext = rc;

            IsInitialized = true;

            return true;
        }
Ejemplo n.º 22
0
        public override void UnPrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks)
        {
            rc._2DVertexBufferArray.BindVertexBufferArray();

            for (int i = 0; i < vblks.Length; i++)
                rc.DisableVertexAttribute((int)vblks[i].AttributeID);

            rc._2DVertexBufferArray.UnbindVertexBufferArray();
        }
Ejemplo n.º 23
0
 public override void DrawInstanced(RendererContext rc, int count)
 {
     //Whooo, how should I draw myself multiple times? It would be crazy
 }
Ejemplo n.º 24
0
        public override bool Init(RendererContext rc)
        {
            IsInitialized = true;

            return base.Init(rc);
        }