예제 #1
0
        public void Begin(int fixWidth = -1, int fixHeight = -1)
        {
            ImGuiHelper.AnimatingElement();
            var renderWidth  = Math.Max(120, (int)ImGui.GetWindowWidth() - MarginW);
            var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - MarginH);

            if (fixWidth > 0)
            {
                renderWidth = fixWidth;
            }
            if (fixHeight > 0)
            {
                renderHeight = fixHeight;
            }
            //Generate render target
            if (rh != renderHeight || rw != renderWidth)
            {
                if (RenderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(RenderTarget.Texture);
                    RenderTarget.Dispose();
                }
                RenderTarget = new RenderTarget2D(renderWidth, renderHeight);
                rid          = ImGuiHelper.RegisterTexture(RenderTarget.Texture);
                rw           = renderWidth;
                rh           = renderHeight;
            }
            if (mw.Config.MSAA != 0 && ((mrw != rw) || (mrh != rh) || (msamples != mw.Config.MSAA)))
            {
                if (msaa != null)
                {
                    msaa.Dispose();
                }
                msaa = new MultisampleTarget(rw, rh, mw.Config.MSAA);
            }
            else if (msaa != null)
            {
                msaa.Dispose();
                mrw      = mrh = -1;
                msamples = 0;
                msaa     = null;
            }
            cc = rstate.ClearColor;
            if (mw.Config.MSAA != 0)
            {
                rstate.RenderTarget = msaa;
            }
            else
            {
                rstate.RenderTarget = RenderTarget;
            }
            vps.Push(0, 0, rw, rh);
            rstate.Cull         = true;
            rstate.DepthEnabled = true;
            rstate.ClearColor   = Background;
            rstate.ClearAll();
        }