public virtual void Run() { InitializeBuffers(); InitializeLight(); InitializeComponents(); FrameTimer = new Stopwatch(); FrameTimer.Start(); RenderLoop.Run(RenderForm, RenderCallback); }
/// <summary> /// Applies the given sample to the given RenderLoop. /// </summary> /// <param name="renderLoop">The render loop.</param> /// <param name="sampleDesc">The sample to be applied.</param> public SampleBase ApplySample(RenderLoop renderLoop, SampleDescription sampleDesc) { renderLoop.EnsureNotNull(nameof(renderLoop)); sampleDesc.EnsureNotNull(nameof(sampleDesc)); SampleBase sample = Activator.CreateInstance(sampleDesc.SampleClass) as SampleBase; sample.OnStartupAsync(renderLoop); return(sample); }
private void RunRenderForm() { RenderLoop.Run(RenderForm, () => { if (!Frame()) { ShutDown(); } }); }
public void Run() { deviceManager.Context.OutputMerger.SetTargets(deviceManager.BackBuffer); RenderLoop.Run(form, () => { deviceManager.Context.ClearRenderTargetView(deviceManager.BackBuffer, SharpDX.Mathematics.Color.Black); Render(); deviceManager.SwapChain.Present(0, PresentFlags.None); }); }
static void Main(string[] args) { using (var screen = new Screen()) { screen.Width = 720; screen.Height = 480; RenderLoop.Run(screen, () => { }); } }
public void Run(Action update) { if (update == null) { throw new Exception("Update Function is null"); } RenderLoop.Run(this, () => { update(); }); }
static void Main(string[] args) { Application.EnableVisualStyles(); var form = new MainForm("HeadShotter"); RenderLoop.Run(form, () => { form.Render(); }); }
public void Start() { RenderLoop.Run(_renderForm, () => { if (!Frame()) { Stop(); } }); }
public void StartRenderLoop(DataLock dataLock) { Initialize(dataLock); RenderLoop.Run(_form, () => { dataLock.UiRead(() => Update(_timer.Tick())); Draw(); }); _game.Exit(); }
public void Start() { if (this.faceCamera != null) { faceCamera.Start(); } // Start the render loop RenderLoop.Run(renderForm, OnRenderCallback); }
/// <summary> /// Initializes a new instance of the <see cref="SeeingSharpPanelPainter" /> class. /// </summary> public SeeingSharpPanelPainter() { // Create the RenderLoop object GraphicsCore.Touch(); m_renderLoop = new Core.RenderLoop(SynchronizationContext.Current, this); m_renderLoop.ClearColor = Color4.CornflowerBlue; m_renderLoop.CallPresentInUIThread = false; m_detachOnUnload = true; }
private void Run() { //setup initial frame timeKeeper.Start(); OpenVR.Compositor.GetLastPoses(poses, gamePoses); KickoffFramePreparation(); preparedFrame = asyncFramePreparer.FinishPreparingFrame(); RenderLoop.Run(companionWindow.Form, DoFrame); }
public void Run() { LoadContent(); watch = new Stopwatch(); watch.Start(); RenderLoop.Run(window, PerformLoop); UnloadContent(); }
void InitAndClearBuffer(Camera camera, RenderLoop renderLoop) { // We clear only the depth buffer, no need to clear the various color buffer as we overwrite them. // Clear depth/stencil and init buffers { var cmd = new CommandBuffer(); cmd.name = "InitGBuffers and clear Depth/Stencil"; // Init buffer // With scriptable render loop we must allocate ourself depth and color buffer (We must be independent of backbuffer for now, hope to fix that later). // Also we manage ourself the HDR format, here allocating fp16 directly. // With scriptable render loop we can allocate temporary RT in a command buffer, they will not be release with ExecuteCommandBuffer // These temporary surface are release automatically at the end of the scriptable renderloop if not release explicitly int w = camera.pixelWidth; int h = camera.pixelHeight; cmd.GetTemporaryRT(s_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default); cmd.GetTemporaryRT(s_CameraDepthBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth); m_gbufferManager.InitGBuffers(w, h, cmd); cmd.SetRenderTarget(new RenderTargetIdentifier(s_CameraColorBuffer), new RenderTargetIdentifier(s_CameraDepthBuffer)); cmd.ClearRenderTarget(true, false, new Color(0, 0, 0, 0)); renderLoop.ExecuteCommandBuffer(cmd); cmd.Dispose(); } // TEMP: As we are in development and have not all the setup pass we still clear the color in emissive buffer and gbuffer, but this will be removed later. // Clear HDR target { var cmd = new CommandBuffer(); cmd.name = "Clear HDR target"; cmd.SetRenderTarget(new RenderTargetIdentifier(s_CameraColorBuffer), new RenderTargetIdentifier(s_CameraDepthBuffer)); cmd.ClearRenderTarget(false, true, new Color(0, 0, 0, 0)); renderLoop.ExecuteCommandBuffer(cmd); cmd.Dispose(); } // Clear GBuffers { var cmd = new CommandBuffer(); cmd.name = "Clear GBuffer"; // Write into the Camera Depth buffer cmd.SetRenderTarget(m_gbufferManager.GetGBuffers(cmd), new RenderTargetIdentifier(s_CameraDepthBuffer)); // Clear everything // TODO: Clear is not required for color as we rewrite everything, will save performance. cmd.ClearRenderTarget(false, true, new Color(0, 0, 0, 0)); renderLoop.ExecuteCommandBuffer(cmd); cmd.Dispose(); } // END TEMP }
public override async Task OnStartupAsync(RenderLoop mainRenderLoop, SampleSettings settings) { mainRenderLoop.EnsureNotNull(nameof(mainRenderLoop)); var castedSettings = settings as Direct2DTextureSampleSettings ?? new Direct2DTextureSampleSettings(); // 2D rendering is made here _solidBrush = new SolidBrushResource(Color4.Gray); _textFormat = new TextFormatResource("Arial", 36); _textBrush = new SolidBrushResource(Color4.RedColor); var d2DDrawingLayer = new Custom2DDrawingLayer(graphics => { var d2DRectangle = new RectangleF(10, 10, 236, 236); graphics.Clear(Color4.LightBlue); graphics.FillRoundedRectangle( d2DRectangle, 30, 30, _solidBrush); d2DRectangle.Inflate(-10, -10); graphics.DrawText( castedSettings.DisplayText, _textFormat, d2DRectangle, _textBrush); }); // Build 3D scene await mainRenderLoop.Scene.ManipulateSceneAsync(manipulator => { // Create floor this.BuildStandardFloor( manipulator, Scene.DEFAULT_LAYER_NAME); // Define Direct2D texture resource var resD2DTexture = manipulator.AddResource( _ => new Direct2DTextureResource(d2DDrawingLayer, 256, 256)); var resD2DMaterial = manipulator.AddStandardMaterialResource(resD2DTexture, enableShaderGeneratedBorder: true); // Create cube geometry resource var resGeometry = manipulator.AddResource( _ => new GeometryResource(new CubeGeometryFactory())); // Create cube object var cubeMesh = new Mesh(resGeometry, resD2DMaterial); cubeMesh.Color = Color4.GreenColor; cubeMesh.YPos = 0.5f; cubeMesh.BuildAnimationSequence() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_180DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_360DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .CallAction(() => cubeMesh.RotationEuler = Vector3.Zero) .ApplyAndRewind(); manipulator.AddObject(cubeMesh); }); }
public void Create3dObjects() { //Create RenderWindow RenderWindowInstance = new ModelRenderWindow(); FormInstance = RenderWindowInstance.CreateWindow(1080, 1240, FormStartPosition.CenterScreen); //Create SwapChain SwapChainCreator = new ModelSwapChainDesc(); SwapChainD = SwapChainCreator.CreateSwapChain(2, Usage.RenderTargetOutput, FormInstance.Handle, true, 0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm, 1, 0, SwapChainFlags.AllowModeSwitch, SwapEffect.Discard); //Create Device Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, SwapChainD, out GraphicsDevice, out NewSwapChain); //Create Back buffer BackBuffer = Surface.FromSwapChain(NewSwapChain, 0); //Create Factory FactoryD2D FactoryInstance = new FactoryD2D(); //Create RenderTarget RenderTargetInstance = new ModelRenderTarget(); RenderTarget = RenderTargetInstance.CreateRenderTarget(SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT, new PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Ignore), RenderTargetType.Default, RenderTargetUsage.None, BackBuffer, FactoryInstance); RenderLoop.Run(FormInstance, () => { RenderTarget.BeginDraw(); RenderTarget.Transform = Matrix3x2.Identity; RenderTarget.Clear(Color.White); using (var brush = new SolidColorBrush(RenderTarget, Color.Red)) { //for (int x = 0; x < RenderTarget.Size.Width; x += 10) // RenderTarget.DrawLine(new Vector2(x, 0), new Vector2(x, RenderTarget.Size.Height), brush, 0.5f); //for (int y = 0; y < RenderTarget.Size.Height; y += 10) // RenderTarget.DrawLine(new Vector2(0, y), new Vector2(RenderTarget.Size.Width, y), brush, 0.5f); RenderTarget.DrawLine(new Vector2(300, 10), new Vector2(300, 300), brush, 1.5f); // RenderTarget.FillRectangle(new RectangleF(RenderTarget.Size.Width / 2 - 50, RenderTarget.Size.Height / 2 - 50, 100, 100), brush); } // RenderTarget.DrawRectangle( // new RectangleF(RenderTarget.Size.Width / 2 - 100, RenderTarget.Size.Height / 2 - 100, 200, 200), // new SolidColorBrush(RenderTarget, Color.CornflowerBlue)); RenderTarget.EndDraw(); NewSwapChain.Present(0, PresentFlags.None); }); RenderTarget.Dispose(); NewSwapChain.Dispose(); GraphicsDevice.Dispose(); }
/// <summary> /// Runs the demo. /// </summary> public void Run(DemoConfiguration demoConfiguration) { _demoConfiguration = demoConfiguration ?? new DemoConfiguration(); _form = CreateForm(_demoConfiguration); Initialize(_demoConfiguration); bool isFormClosed = false; bool formIsResizing = false; _form.MouseClick += HandleMouseClick; _form.KeyDown += HandleKeyDown; _form.KeyUp += HandleKeyUp; _form.Resize += (o, args) => { if (_form.WindowState != _currentFormWindowState) { HandleResize(o, args); } _currentFormWindowState = _form.WindowState; }; _form.ResizeBegin += (o, args) => { formIsResizing = true; }; _form.ResizeEnd += (o, args) => { formIsResizing = false; HandleResize(o, args); }; _form.Closed += (o, args) => { isFormClosed = true; }; LoadContent(); clock.Start(); BeginRun(); RenderLoop.Run(_form, () => { if (isFormClosed) { return; } OnUpdate(); if (!formIsResizing) { Render(); } }); UnloadContent(); EndRun(); // Dispose explicity Dispose(); }
public void Run() { using (var Loop = new RenderLoop(Form)) { while (Loop.NextFrame()) { Update(); Render(); } } }
private GraphicsLoop(InitFlags initFlags, RenderForm form, IGraphicsFacade graphicsFacade, RenderContext renderer) { _initFlags = initFlags; Form = form; GraphicsFacade = graphicsFacade; Renderer = renderer; RenderLoop = new RenderLoop(Form); Statistics = new GraphicsLoopStatistics(); Input = new InputSomethingOSDJFH(Form); }
private void Loop() { using (var loop = new RenderLoop(Core.Form)) { while (loop.NextFrame()) { Core.Update(); Core.Render(); } } }
public void Run() { Initialize(); GameTime.Start(); RenderLoop.Run(renderForm, () => { GameTime.Update(); Update(); Draw(); }); }
public void Run() { try { RenderLoop.Run(_dxForm, RenderCallback); } catch (Exception ex) { MessageBox.Show(string.Format("Exception running DirectX host window.\r\n{0}", ex.Message), "DirectX Host", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Registers the given RenderLoop object. /// </summary> /// <param name="renderLoop">The RenderLoop to be registered.</param> internal void RegisterRenderLoop(RenderLoop renderLoop) { lock (_registeredRenderLoopsLock) { if (!_registeredRenderLoops.Contains(renderLoop)) { _registeredRenderLoops.Add(renderLoop); renderLoop.IsRegisteredOnMainLoop = true; } } }
public void StartRenderLoop() { RenderLoop.Run(window.GetForm(), () => { gameLoopCallback(); DrawScenes(); PostProcess(); deviceResources.SwapChain.Present(1, PresentFlags.None); }); }
public override Task OnStartupAsync(RenderLoop mainRenderLoop, SampleSettings settings) { mainRenderLoop.EnsureNotNull(nameof(mainRenderLoop)); _castedSettings = (RectangleSampleSettings)settings; _fillBrush = new SolidBrushResource(Color4.Gray); _fillBrushTransparent = new SolidBrushResource(Color4.Gray, 0.5f); return(Task.FromResult <object?>(null)); }
public void Run() { d3dDeviceManager.Context.OutputMerger.SetTargets(d3dDeviceManager.BackBuffer); RenderLoop.Run(form, () => { Update(); d3dDeviceManager.Context.ClearRenderTargetView(d3dDeviceManager.BackBuffer, new RawColor4(0, 0, 0, 1)); Render(); d3dDeviceManager.SwapChain.Present(0, PresentFlags.None); }); }
public void StartGame() { Logger.Log("Starting game " + GameName); if (CurrentWorld == null && GameWorlds.Count > 0) { CurrentWorld = GameWorlds[0]; } RenderLoop.Run(Form, GameLoop); }
public void Start() { //renderForm.Show(); //renderLoop = new RenderLoop(renderForm); renderForm.DoubleClick += new EventHandler((o, ea) => { renderForm.IsFullscreen = !renderForm.IsFullscreen; }); RenderLoop.Run(renderForm, RenderCallback); }
public void Run() { Logger.Info("Starting ..."); Bass.BASS_ChannelSetPosition(_soundStream, Bass.BASS_ChannelSeconds2Bytes(_soundStream, 0.0), BASSMode.BASS_POS_BYTES); Bass.BASS_ChannelPlay(_soundStream, false); _stopwatch.Start(); _globalTime.Start(); RenderLoop.Run(_form, () => Update()); }
private RenderLoop loop; //TODO dispose public RenderContext NextFrame(bool ignoreWindowsMessage = false) { if (loop == null) { loop = StartLoop(); } if (ignoreWindowsMessage || loop.NextFrame()) { return(RenderFrame()); } return(null); }