Exemple #1
0
        public static void Run(RenderManager rm, bool multithread, Action <RenderContext> action)
        {
            if (multithread)
            {
                var signal       = new ShutdownSignal();
                var renderThread = new Thread(new ThreadStart(delegate()
                {
                    int counter = 0;
                    while (!signal.shutdown)
                    {
                        var frame = rm.NextFrame(true);
                        if (frame == null)
                        {
                            break;
                        }

                        if (++counter >= 60)
                        {
                            signal.fps       = frame.Fps;
                            signal.fpsUpdate = true;
                            counter          = 0;
                        }

                        action(frame);
                    }
                }));

                rm.ShowWindow();
                renderThread.Start();
                RenderLoop.Run(rm.Form, delegate
                {
                    Thread.Sleep(5);
                    if (signal.fpsUpdate)
                    {
                        rm.Form.Text     = "FPS: " + signal.fps;
                        signal.fpsUpdate = false;
                    }
                });
                signal.shutdown = true;
                renderThread.Join();
            }
            else
            {
                rm.ShowWindow();
                int counter = 0;
                while (true)
                {
                    var frame = rm.NextFrame(false);
                    if (frame == null)
                    {
                        break;
                    }

                    if (++counter >= 60)
                    {
                        rm.Form.Text = "FPS: " + frame.Fps;
                        counter      = 0;
                    }

                    action(frame);
                }
            }
        }
 public MyRenderContext(RenderManager m) :
     base(m.device.ImmediateContext, m.swapChain, m.screen)
 {
 }
Exemple #3
0
 public static Shader <T> CreateFromFile(RenderManager manager, string filename)
 {
     return(null);
 }