Exemple #1
0
        /// <summary>
        /// Creates a new RenderTarget based in a previously created RenderTarget from C++
        /// </summary>
        /// <param name="engine"></param>
        /// <param name="name"></param>
        /// <param name="internalRenderTarget"></param>
        internal RenderTarget(VisualEngine engine, StringBuilder name, _RenderTarget internalRenderTarget)
            : this(engine, name)
        {
            Engine.Log.AddInformation(TAG, new StringBuilder("Create " + Name + " (C++ _RenderTarget based)"));

            Internal = internalRenderTarget;

            Texture = new Texture2D(engine, name, Internal.GetTexture());
        }
Exemple #2
0
        /// <summary>
        /// Resize the RenderTarget if needed
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        internal void Resize(int width, int height)
        {
            if (width == Texture.Width && height == Texture.Height)
            {
                return;
            }

            Engine.Log.AddInformation(TAG, new StringBuilder("Resize " + Name + ": " + Width + "x" + Height));

            if (Internal.IsSwapChain)
            {
                Internal.Resize(width, height);
                return;
            }

            // Destroys Texture2D

            Texture.Destroy();

            // Destroys _RenderTarget

            Internal.Destroy();

            if (Internal.IsDX9BackBuffer)
            {
                Engine.Log.AddInformation(TAG, new StringBuilder("Recreating " + Name));

                _RenderTarget renderTarget = Engine.Device.CreateDX9SharedRenderTarget(Name.ToString(), width, height);
                Internal         = renderTarget;
                Texture.Internal = renderTarget.GetTexture();
            }
            else
            {
                Texture.CreateForRenderTargetUse(Texture.Name, width, height, Texture.Format);

                Internal = new _RenderTarget(Engine.Device, Texture.InternalTexture2D);
            }
        }