/// <inheritdoc /> internal override void Run() { OnInitialization(this, EventArgs.Empty); try { // Use custom render loop Control.Show(); using (RenderLoop = new RenderLoop(Control) { UseApplicationDoEvents = DesktopContext.UseApplicationDoEvents }) { while (RenderLoop.NextFrame()) { if (Exiting) { if (Control != null) { Control.Dispose(); Control = null; } break; } OnTick(this, EventArgs.Empty); } } } finally { OnShutdown(this, EventArgs.Empty); } }
static void Main() { var form = new RenderForm("DirectX 12 : CSharp") { Width = 640, Height = 480, WindowState = System.Windows.Forms.FormWindowState.Maximized }; form.Show(); using (var app = new HelloTriangle()) { app.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { app.Update(); app.Render(); } } } }
internal void Start() { if (isStarted) { return; } new KeyboardController().SetupKeyboardHooks(); Form.Show(); Form.MainForm.Show(); Form.MainForm.BringToFront(); EventsAndGlobalsController.NeedRedraw += () => ForceNextFrame(); looper = new RenderLoop(Form); Boolean firstRender = false; while (true) { if (!looper.NextFrame()) { break; } if (!firstRender) { NextFrame(); firstRender = true; } Thread.Sleep((Int32)Utils.GetUpdateTimeForFPS(60)); } }
private void buttonEnableD3D_Click(object sender, EventArgs e) { var form = new RenderForm("Hello Texture") { Width = 640, Height = 640 }; form.Show(); form.Location = new Point( this.Location.X, this.Location.Y + this.Height); _hardwareRenderer = new HelloTexture(volume, renderer); _hardwareRenderer.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { _hardwareRenderer.Update(); _hardwareRenderer.Render(); } _hardwareRenderer.Dispose(); } _hardwareRenderer = null; }
private void Loop() { var frameCounter = new System.Diagnostics.Stopwatch(); var timer = new System.Diagnostics.Stopwatch(); int frameCounted = 0; System.TimeSpan elapsedTime = System.TimeSpan.Zero; timer.Start(); while (running) { frameCounter.Restart(); double newTime = timer.Elapsed.TotalSeconds; RenderContext.deltaTime = newTime - RenderContext.elsapsedTime; RenderContext.elsapsedTime = newTime; if (immediateContext.ShaderBank.ShaderNeedsReload()) { immediateContext.ShaderBank.ReloadQueuedShaders(); } if (renderLoop.NextFrame()) { Render(); } frameCounter.Stop(); frameCounted++; elapsedTime += frameCounter.Elapsed; if (frameCounted >= 60) { form.Text = string.Format("Raytracer - Framerate: {0}fps", System.Math.Floor(1000.0 / (elapsedTime.TotalMilliseconds / frameCounted))); elapsedTime = System.TimeSpan.Zero; frameCounted = 0; } } }
public void Run() { using (var Loop = new RenderLoop(Form)) { while (Loop.NextFrame()) { Update(); Render(); } } }
private void Loop() { using (var loop = new RenderLoop(Core.Form)) { while (loop.NextFrame()) { Core.Update(); Core.Render(); } } }
private void InitRenderStuff() { SharedRenderItems = new SharedRenderItemsStorage(this); switch (m_RenderPathType) { case RenderPathEnum.Forward: RenderPath = new ForwardBaseD3D11RenderPath(); break; case RenderPathEnum.Deffered: // TODO: Deffered RenderPath = new DefferedD3D11RenderPath(); break; case RenderPathEnum.TiledForward: // TODO: TiledForward RenderPath = new TiledForwardD3D11RenderPath(); break; } RenderPath.Init(this); m_ConsoleRenderer = new ConsoleRenderer(); m_ConsoleRenderer.Initialize(this); ScreenProps.Width = DisplayRef.Width; ScreenProps.Height = DisplayRef.Height; ScreenProps.AspectRatio = DisplayRef.Width / (float)DisplayRef.Height; EngineOnRunned?.Invoke(); if (!IsSingleFormMode) { return; } using (var loop = new RenderLoop(Surface)) { while (loop.NextFrame()) { if (IsExitRequest) { if (IsSingleFormMode) { ((Form)Surface).Close(); } break; } //profiler.Begin(Context); DisplayRef.Render(IntPtr.Zero, false); //profiler.End(Context); } } Deinitialize(); }
private RenderLoop loop; //TODO dispose public RenderContext NextFrame(bool ignoreWindowsMessage = false) { if (loop == null) { loop = StartLoop(); } if (ignoreWindowsMessage || loop.NextFrame()) { return(RenderFrame()); } return(null); }
internal Boolean ForceNextFrame() { for (Int32 i = 0; i < 3; i++) { if (!looper.NextFrame()) { continue; } NextFrame(); return(true); } return(false); }
public bool IsRunning(out IRenderContext renderer, out InputSomethingOSDJFH input) { Input.HandlePreWindowingEvents(); if (RenderLoop.NextFrame()) { GraphicsFacade.Device.DoEvents(); Statistics.HandleFrameEnter((_initFlags & InitFlags.EnableDebugStats) != 0 ? Form : null); Input.HandleFrameEnter(); renderer = Renderer; input = Input; return(true); } renderer = null; input = null; return(false); }
public void RunMainLoop(Control control) { using (var loop = new RenderLoop(control)) while (loop.NextFrame()) { MainLoop(control.Size); } // main loop is done; release resources arrowDefault.Dispose(); whiteDefault.Dispose(); TextureManager.DisposeTextures(); Cube.Dispose(); Pyramid.Dispose(); Cylinder.Dispose(); Sphere.Dispose(); Plane.Dispose(); basicBuffer.Dispose(); basicShader.Dispose(); defaultBuffer.Dispose(); defaultShader.Dispose(); tintedBuffer.Dispose(); tintedShader.Dispose(); foreach (SharpMesh mesh in RenderWareModelFile.completeMeshList) { if (mesh != null) { mesh.Dispose(); } } foreach (var bf in completeVertexBufferList) { if (bf != null) { bf.Dispose(); } } device.Dispose(); }
private void RunRenderLoop() { Debug.Assert(InitCallback != null); Debug.Assert(RunCallback != null); InitCallback(); try { // Use custom render loop // Show the control for WinForm, let HwndHost show it for WPF if (wpfBorderControl == null) { Control.Show(); } using (renderLoop = new RenderLoop(Control) { UseApplicationDoEvents = GameContext.UseApplicationDoEvents }) { while (renderLoop.NextFrame()) { if (Exiting) { if (Control != null) { Control.Dispose(); Control = null; } break; } RunCallback(); } } } finally { if (ExitCallback != null) { ExitCallback(); } } }
public void Run() { if (!IsInitialized || _hasRun) { return; } IsRunning = true; _hasRun = true; Timer.Reset(); ControlWindow.Show(); ControlWindow.Focus(); using (var renderLoop = new RenderLoop(ControlWindow)) { while (renderLoop.NextFrame()) { Render(); } } }
static void Main(string[] args) { var form = new RenderForm("CubeRender"); using (var app = new CubeRender()) { form.Show(); app.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { app.Update(); app.Render(); } } } }
static void Main(string[] args) { var form = new RenderForm("HelloWorldD3D12"); using (var helloTriangle = new HelloWorld()) { form.Show(); helloTriangle.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { helloTriangle.Update(); helloTriangle.Render(); } } } }
public static void Run() { var form = new RenderForm("HelloWorld D3D12"); form.Icon = null; using (var helloTriangle = new DX12Test()) { form.Show(); helloTriangle.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { helloTriangle.Update(); helloTriangle.Render(); } } } }
public override void Run() { using (var loop = new RenderLoop(IntDis.Form)) { Init?.Invoke(); while (loop.NextFrame()) { Update?.Invoke(); IntDis.BeginDraw(); Draw?.Invoke(); IntDis.EndDraw(); } } base.Run(); }
static void Main(string[] args) { var form = new RenderForm("ModelRender"); using (var app = new ModelRender()) { form.Width = 1440; form.Height = 900; form.Show(); app.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { app.Update(); app.Render(); } } } }
static void Main(string[] args) { var form = new RenderForm("HelloWorldD3D12"); using (var helloTriangle = new HelloWorldShared.HelloWorld()) { form.Show(); form.ClientSizeChanged += (o, e) => helloTriangle.Resize(form.ClientSize.Width, form.ClientSize.Height); helloTriangle.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { helloTriangle.Update(); helloTriangle.Render(); } } } }
static void Main(string[] args) { Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); var supported = Device.GetSupportedFeatureLevel(); Console.WriteLine("device supported {0}", supported); if (supported < SharpDX.Direct3D.FeatureLevel.Level_10_0) { return; } TSOConfig tso_config; string tso_config_file = Path.Combine(Application.StartupPath, @"config.xml"); if (File.Exists(tso_config_file)) { tso_config = TSOConfig.Load(tso_config_file); } else { tso_config = new TSOConfig(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); TSOForm form = new TSOForm(tso_config, args); form.Show(); using (RenderLoop loop = new RenderLoop(form)) { while (loop.NextFrame()) { form.Render(); } } }
private void RunRenderLoop() { OnInitialization(this, EventArgs.Empty); try { // Use custom render loop // Show the control for WinForm, let HwndHost show it for WPF if (wpfBorderControl == null) { Control.Show(); } using (RenderLoop = new RenderLoop(Control) { UseApplicationDoEvents = DesktopContext.UseApplicationDoEvents }) { while (RenderLoop.NextFrame()) { if (Exiting) { if (Control != null) { Control.Dispose(); Control = null; } break; } OnTick(this, EventArgs.Empty); } } } finally { OnShutdown(this, EventArgs.Empty); } }
static void Main() { var form = new RenderForm("Hello Window"); form.Width = 1280; form.Height = 800; form.Show(); using (HelloWindow app = new HelloWindow()) { app.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { app.Update(); app.Render(); } } } }
/// <inheritdoc /> internal override void Run() { Debug.Assert(InitCallback != null); Debug.Assert(RunCallback != null); InitCallback(); try { // Use custom render loop Control.Show(); using (renderLoop = new RenderLoop(Control)) { while (renderLoop.NextFrame()) { if (Exiting) { if (Control != null) { Control.Dispose(); Control = null; } break; } RunCallback(); } } } finally { if (ExitCallback != null) { ExitCallback(); } } }
static void Main() { var form = new RenderForm("Hello Texture") { Width = 1280, Height = 800 }; form.Show(); using (var app = new HelloTexture()) { app.Initialize(form); using (var loop = new RenderLoop(form)) { while (loop.NextFrame()) { app.Update(); app.Render(); } } } }
static void Main() { for (int i = 0; i < Diagnostics.Length; i++) { Diagnostics[i] = 0; } // Create render target window form = new RenderForm(); form.StartPosition = FormStartPosition.CenterScreen; form.ClientSize = new System.Drawing.Size(160 * 4, 144 * 4); form.WindowState = FormWindowState.Minimized; form.Show(); form.Focus(); form.WindowState = FormWindowState.Normal; // Create swap chain description var swapChainDesc = new SwapChainDescription() { BufferCount = 2, Usage = Usage.RenderTargetOutput, OutputHandle = form.Handle, IsWindowed = true, ModeDescription = new ModeDescription(160, 144, new Rational(60, 1), Format.R8G8B8A8_UNorm), SampleDescription = new SampleDescription(1, 0), Flags = SwapChainFlags.AllowModeSwitch, SwapEffect = SwapEffect.Discard }; // Create swap chain and Direct3D device // The BgraSupport flag is needed for Direct2D compatibility otherwise new RenderTarget() will fail! Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, swapChainDesc, out Device device, out swapChain); // Get back buffer in a Direct2D-compatible format (DXGI surface) backBuffer = Surface.FromSwapChain(swapChain, 0); // Create Direct2D factory using (var factory = new FactoryD2D()) { var dpi = factory.DesktopDpi; // Create bitmap render target from DXGI surface renderTarget = new RenderTarget(factory, backBuffer, new RenderTargetProperties() { DpiX = 0, DpiY = 0, MinLevel = SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT, PixelFormat = new PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Ignore), Type = RenderTargetType.Hardware, Usage = RenderTargetUsage.None }); } backBufferBMP = new Bitmap(renderTarget, new Size2(160, 144), new BitmapProperties(renderTarget.PixelFormat)); Color[] palette = new Color[4]; palette[0] = Color.White; palette[1] = Color.LightGray; palette[2] = Color.DarkGray; palette[3] = Color.Black; Color[] bitmap = new Color[160 * 144]; while (true) { STOP = false; OpenFileDialog of = new OpenFileDialog { Filter = "Game Boy Files (*.gb)|*.gb|Game Boy Color Files (*.gbc)|*.gbc", RestoreDirectory = true }; of.ShowDialog(); DMGBoard Board = DMGBoard.Builder(of.FileName); AddKeyListeners(form, Board); Debugger d = new Debugger(Board); //d.Show(); //Application.Run(); RenderLoop rl = new RenderLoop(form); while (rl.NextFrame() && !STOP) { int[] temp = Board.RunOneFrame(); for (int i = 0; i < temp.Length; i++) { bitmap[i] = palette[temp[i]]; } renderTarget.BeginDraw(); renderTarget.Transform = Matrix3x2.Identity; renderTarget.Clear(Color.Black); backBufferBMP.CopyFromMemory(bitmap, 160 * 4); renderTarget.DrawBitmap(backBufferBMP, 1f, BitmapInterpolationMode.NearestNeighbor); renderTarget.EndDraw(); swapChain.Present(1, PresentFlags.Restart); } d.Dispose(); } renderTarget.Dispose(); swapChain.Dispose(); device.Dispose(); //Application.Run(); }
public bool NextFrame() { return(_renderLoop.NextFrame()); }