Esempio n. 1
0
        public RenderTarget CreateRenderTarget(string name, Renderer.RenderTargets.Definition definition)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name");
            if (definition == null)
                throw new ArgumentNullException("definition");

            int[] textureHandles;

            var renderTarget = new RenderTarget(definition.Width, definition.Height);

            renderTarget.Handle = RenderSystem.CreateRenderTarget(definition, out textureHandles, (handle, success, errors) =>
            {
                renderTarget.IsReady = true;
            });

            var textures = new Resources.Texture[textureHandles.Length];
            for (var i = 0; i < textureHandles.Length; i++)
            {
                var texture = new Resources.Texture("_sys/render_targets/" + name + "_" + StringConverter.ToString(i), "");
                texture.Handle = textureHandles[i];
                texture.Width = definition.Width;
                texture.Height = definition.Height;

                ResourceManager.Manage(texture);

                textures[i] = texture;
            }

            renderTarget.Textures = textures;

            return renderTarget;
        }
Esempio n. 2
0
        /// <summary>
        /// Begin to render a new pass to the specified render target
        /// </summary>
        /// <param name="renderTarget"></param>
        /// <param name="clearColor"></param>
        public void BeginPass(RenderTarget renderTarget, Vector4 clearColor, bool clearDepth = true)
        {
            PrimaryBuffer.Writer.Write((byte)OpCode.BeginPass);
            if (renderTarget == null)
            {
                PrimaryBuffer.Writer.Write(0);
                PrimaryBuffer.Writer.Write(Width);
                PrimaryBuffer.Writer.Write(Height);
            }
            else
            {
                PrimaryBuffer.Writer.Write(renderTarget.Handle);
                PrimaryBuffer.Writer.Write(renderTarget.Width);
                PrimaryBuffer.Writer.Write(renderTarget.Height);
            }

            PrimaryBuffer.Writer.Write(true);
            PrimaryBuffer.Writer.Write(clearColor);
            PrimaryBuffer.Writer.Write(clearDepth);
        }
Esempio n. 3
0
 public void ChangeRenderTarget(RenderTarget renderTarget)
 {
     PrimaryBuffer.Writer.Write((byte)OpCode.ChangeRenderTarget);
     if (renderTarget == null)
     {
         PrimaryBuffer.Writer.Write(0);
         PrimaryBuffer.Writer.Write(Width);
         PrimaryBuffer.Writer.Write(Height);
     }
     else
     {
         PrimaryBuffer.Writer.Write(renderTarget.Handle);
         PrimaryBuffer.Writer.Write(renderTarget.Width);
         PrimaryBuffer.Writer.Write(renderTarget.Height);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Begin to render a new pass to the specified render target
        /// </summary>
        /// <param name="renderTarget"></param>
        /// <param name="clearColor"></param>
        public void BeginPass(RenderTarget renderTarget)
        {
            PrimaryBuffer.Writer.Write((byte)OpCode.BeginPass);
            if (renderTarget == null)
            {
                PrimaryBuffer.Writer.Write(0);
                PrimaryBuffer.Writer.Write(Width);
                PrimaryBuffer.Writer.Write(Height);
            }
            else
            {
                PrimaryBuffer.Writer.Write(renderTarget.Handle);
                PrimaryBuffer.Writer.Write(renderTarget.Width);
                PrimaryBuffer.Writer.Write(renderTarget.Height);
            }

            PrimaryBuffer.Writer.Write(false);
        }