コード例 #1
0
        public RenderManager(int width, int height)
        {
            gBuffer = new DeferredGBuffer(width, height);

            EventSystem.On <Events.WindowResized>(evt =>
            {
                if (gBuffer == null || evt.NewPixelWidth != gBuffer.Width || evt.NewPixelHeight != gBuffer.Height)
                {
                    if (gBuffer != null)
                    {
                        gBuffer.Dispose();
                    }
                    gBuffer = new DeferredGBuffer(evt.NewPixelWidth, evt.NewPixelHeight);
                }
            });

            EnableRasterizerCulling.OnChangedAndNow(c =>
            {
                if (c.Bool)
                {
                    rasterizer = new SoftwareDepthRasterizer(200, 100);
                }
                else
                {
                    rasterizer = null;
                }
            });

            ShowRasterizerContents.OnChangedAndNow(c =>
            {
                if (c.Bool)
                {
                    rasterizer?.Show();
                }
                else
                {
                    rasterizer?.Hide();
                }
            });

            paraller = new ParallerRunner(Environment.ProcessorCount - 2, "render manager", ThreadPriority.Highest);
        }