public IngameRenderer(IGraphicsDeviceService deviceService, IRenderPipeline renderPipeline) { this.deviceService = deviceService; this.starfield = new Starfield(this.deviceService); this.renderPipeline = renderPipeline; }
public AGSTextComponent(IRenderPipeline pipeline, IBoundingBoxBuilder boundingBoxBuilder, IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes, IGLUtils glUtils, IGraphicsBackend graphics, IFontFactory fonts, IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events) { _pipeline = pipeline; _afterCropTextBoundingBoxes = new AGSBoundingBoxes(); _state = state; _events = events; Width = 1f; Height = 1f; _matricesPool = new GLMatrices[3]; _messagePump = messagePump; OnLabelSizeChanged = new AGSEvent(); _graphics = graphics; _fonts = fonts; _bitmapPool = bitmapPool; _labelBoundingBoxes = labelBoundingBoxes; _textBoundingBoxes = textBoundingBoxes; _boundingBoxBuilder = boundingBoxBuilder; _virtualResolution = settings.VirtualResolution; _settings = settings; _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder(); _instructionPool = new ObjectPool <Instruction>(pool => new Instruction(pool, glUtils, textureRenderer, _glTextHitTest), 0); TextVisible = true; subscribeTextConfigChanges(); PropertyChanged += onPropertyChanged; _shouldUpdateBoundingBoxes = true; }
/// <summary> /// Initializes a new instance of the <see cref="Protogame.RenderPipelineRenderContext"/> class. /// </summary> /// <param name="renderPipeline">The render pipeline shared with the <see cref="RenderPipelineWorldManager"/> instance.</param> /// <param name="availableSemantics">The available effect semantics in the game.</param> public RenderPipelineRenderContext( IRenderPipeline renderPipeline, IEffectSemantic[] availableSemantics) { _renderPipeline = renderPipeline; _availableSemantics = availableSemantics; }
internal static void CleanupRenderPipeline() { if (RenderPipelineManager.s_CurrentPipelineAsset != null) { RenderPipelineManager.s_CurrentPipelineAsset.DestroyCreatedInstances(); } RenderPipelineManager.s_CurrentPipelineAsset = null; RenderPipelineManager.currentPipeline = null; }
internal static void CleanupRenderPipeline() { if (s_CurrentPipelineAsset != null) { s_CurrentPipelineAsset.DestroyCreatedInstances(); } s_CurrentPipelineAsset = null; currentPipeline = null; }
public AGSBorderComponent(IRenderPipeline pipeline) { _pipeline = pipeline; var backPool = new ObjectPool <BorderBackInstruction>(pool => new BorderBackInstruction(pool), 2); var frontPool = new ObjectPool <BorderFrontInstruction>(pool => new BorderFrontInstruction(pool), 2); _back = new BorderBack(this, backPool); _front = new BorderFront(this, frontPool); }
public void Render() { foreach (var pipeline in RenderPipelines) { ObjectManager.PushDebugGroup("Render", pipeline); CurrentPipeline = pipeline; pipeline.Render(this, Camera); ObjectManager.PopDebugGroup(); } }
protected override void ConfigureRenderPipeline(IRenderPipeline pipeline, IKernel kernel) { var factory = kernel.Get <IGraphicsFactory>(); // Add a 3D render pass in which we render the main game world. pipeline.AddFixedRenderPass(factory.Create3DRenderPass()); // Add a 2D batched render pass in which we render the UI. pipeline.AddFixedRenderPass(factory.Create2DBatchedRenderPass()); }
internal static void CleanupRenderPipeline() { if (s_CurrentPipelineAsset != null) { s_CurrentPipelineAsset.DestroyCreatedInstances(); s_CurrentPipelineAsset = null; currentPipeline = null; SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); } }
public IRenderPipeline CreatePipeline() { IRenderPipeline renderPipeline = this.InternalCreatePipeline(); if (renderPipeline != null) { this.m_CreatedPipelines.Add(renderPipeline); } return(renderPipeline); }
public static void PushDebugGroup(string verb, IRenderPipeline obj) { if (!Enabled) { return; } var name = $"{verb} RenderPipeline {obj.GetType().Name}]"; GL.PushDebugGroup(DebugSourceExternal.DebugSourceApplication, -1, name.Length, name); }
/// <summary> /// Renders the entire scene. /// </summary> /// <param name="doWaitForNextFame"><c>true</c>, if this method should wait to the correct frame start time /// before it renders, else <c>false</c>.</param> /// <returns><c>true</c>, if the caller should wait some milliseconds before rendering the next time.</returns> public static bool Render(bool doWaitForNextFame) { if (_device == null || !_deviceOk) { return(true); } IRenderStrategy renderStrategy = RenderStrategy; IRenderPipeline pipeline = RenderPipeline; renderStrategy.BeginRender(doWaitForNextFame); _renderAndResourceAccessLock.EnterReadLock(); bool doReset = false; try { Fire(DeviceSceneBegin); pipeline.BeginRender(); pipeline.Render(); pipeline.EndRender(); Fire(DeviceSceneEnd); _device.PresentEx(renderStrategy.PresentMode); Fire(DeviceScenePresented); ContentManager.Instance.Clean(); } catch (SharpDXException e) { doReset = true; DeviceState state = CheckDeviceState(); ServiceRegistration.Get <ILogger>().Warn("GraphicsDevice: DirectX Exception, DeviceState: {0}", e, state); _deviceOk = state == DeviceState.Ok; return(!_deviceOk); } finally { _renderAndResourceAccessLock.ExitReadLock(); // If there are exceptions during render pass, the device can stay in an invalid state, even if the CheckDeviceState returns "ok". // So we prefer to reset the device and try continue rendering. if (doReset) { Reset(); } } return(false); }
public void UsePipeline(IRenderPipeline pipeline) { if (pipeline == null) { return; } if (!RenderPipelines.Contains(pipeline)) { RenderPipelines.Add(pipeline); } }
protected override void ConfigureRenderPipeline(IRenderPipeline pipeline, IKernel kernel) { pipeline.AddFixedRenderPass(kernel.Get <ICanvasRenderPass>()); /* * var ProfilerRenderPass = kernel.Get<IProfilerRenderPass>(); * ProfilerRenderPass.Position = ProfilerPosition.TopRight; * ProfilerRenderPass.Visualisers.Add(kernel.Get<IGraphicsMetricsProfilerVisualiser>()); * ProfilerRenderPass.Visualisers.Add(kernel.Get<IGCMetricsProfilerVisualiser>()); * ProfilerRenderPass.Visualisers.Add(kernel.Get<IKernelMetricsProfilerVisualiser>()); * ProfilerRenderPass.Visualisers.Add(kernel.Get<IOperationCostProfilerVisualiser>()); * pipeline.AddFixedRenderPass(ProfilerRenderPass); */ }
public override void Init() { if (Mesh == null) { return; } if (Mesh.Materials.Any(m => m.CastShadow)) { UsePipeline <PointShadowRenderPipeline>(); UsePipeline <DirectionalShadowRenderPipeline>(); } if (PrimaryRenderPipeline == null) { PrimaryRenderPipeline = Context.PrimaryRenderPipeline; } if (_MaterialTmp != null) { Mesh.Material = _MaterialTmp; _MaterialTmp = null; } if (Mesh.Materials.All(m => m.RenderPipeline == null)) { UsePipeline(PrimaryRenderPipeline); } VaoList.Clear(); if (Mesh.HasData) { foreach (var materialId in Mesh.MaterialIds) { var m = Mesh.GetMaterial(materialId); UsePipeline(m.RenderPipeline); m.CreateShaders(); var data = Mesh.GetMeshData(materialId); var vao = new VertexArrayObject(data.BindLayoutToShader(m.Shader)); vao.SetData(data); VaoList.Add(new VertexArrayObjectMaterial { Vao = vao, Material = m, }); } } }
private static void PrepareRenderPipeline(IRenderPipelineAsset pipe) { if (RenderPipelineManager.s_CurrentPipelineAsset != pipe) { if (RenderPipelineManager.s_CurrentPipelineAsset != null) { RenderPipelineManager.CleanupRenderPipeline(); } RenderPipelineManager.s_CurrentPipelineAsset = pipe; } if (RenderPipelineManager.s_CurrentPipelineAsset != null && (RenderPipelineManager.currentPipeline == null || RenderPipelineManager.currentPipeline.disposed)) { RenderPipelineManager.currentPipeline = RenderPipelineManager.s_CurrentPipelineAsset.CreatePipeline(); } }
private static bool PrepareRenderPipeline(IRenderPipelineAsset pipe) { if (s_CurrentPipelineAsset != pipe) { if (s_CurrentPipelineAsset != null) { CleanupRenderPipeline(); } s_CurrentPipelineAsset = pipe; } if (s_CurrentPipelineAsset != null && (currentPipeline == null || currentPipeline.disposed)) { currentPipeline = s_CurrentPipelineAsset.CreatePipeline(); } return(s_CurrentPipelineAsset != null); }
public AGSImageComponent(IHasImage image, IGraphicsFactory factory, IRenderPipeline pipeline, IGLTextureRenderer renderer, ITextureCache textures, ITextureFactory textureFactory, IGLColorBuilder colorBuilder) { IsImageVisible = true; _getTextureFunc = textureFactory.CreateTexture; //Creating a delegate in advance to avoid memory allocations on critical path _textures = textures; _colorBuilder = colorBuilder; _image = image; _factory = factory; _colorAdjusters = new IHasImage[2]; _image.PropertyChanged += onPropertyChanged; _pipeline = pipeline; _boxesPool = new ObjectPool <AGSBoundingBoxes>(_ => new AGSBoundingBoxes(), 2); _instructionPool = new ObjectPool <Instruction>(instructionPool => new Instruction(instructionPool, _boxesPool, renderer), 2); }
/// <summary> /// Renders the entire scene. /// </summary> /// <param name="doWaitForNextFame"><c>true</c>, if this method should wait to the correct frame start time /// before it renders, else <c>false</c>.</param> /// <returns><c>true</c>, if the caller should wait some milliseconds before rendering the next time.</returns> public static bool Render(bool doWaitForNextFame) { if (_device == null || !_deviceOk) { return(true); } IRenderStrategy renderStrategy = RenderStrategy; IRenderPipeline pipeline = RenderPipeline; renderStrategy.BeginRender(doWaitForNextFame); _renderAndResourceAccessLock.EnterReadLock(); try { Fire(DeviceSceneBegin); pipeline.BeginRender(); pipeline.Render(); pipeline.EndRender(); Fire(DeviceSceneEnd); _device.PresentEx(renderStrategy.PresentMode); Fire(DeviceScenePresented); ContentManager.Instance.Clean(); } catch (SharpDXException e) { DeviceState state = CheckDeviceState(); ServiceRegistration.Get <ILogger>().Warn("GraphicsDevice: DirectX Exception, DeviceState: {0}", e, state); _deviceOk = state == DeviceState.Ok; return(!_deviceOk); } finally { _renderAndResourceAccessLock.ExitReadLock(); } return(false); }
private static void PrepareRenderPipeline(IRenderPipelineAsset pipe) { // UnityObject overloads operator == and treats destroyed objects and null as equals // However here is needed to differentiate them in other to bookkeep RenderPipeline lifecycle if ((object)s_CurrentPipelineAsset != (object)pipe) { if (s_CurrentPipelineAsset != null) { // Required because when switching to a RenderPipeline asset for the first time // it will call OnValidate on the new asset before cleaning up the old one. Thus we // reset the rebuild in order to cleanup properly. CleanupRenderPipeline(); } s_CurrentPipelineAsset = pipe; } if (s_CurrentPipelineAsset != null && (currentPipeline == null || currentPipeline.disposed)) { currentPipeline = s_CurrentPipelineAsset.CreatePipeline(); } }
public bool IsPipelineCompatible(IRenderPipeline renderPipeline) { return(true); }
public RenderPipelineWorldManager(IRenderPipeline renderPipeline) { _renderPipeline = renderPipeline; }
protected override void ConfigureRenderPipeline(IRenderPipeline pipeline, IKernel kernel) { pipeline.AddFixedRenderPass(kernel.Get <ICanvasRenderPass>()); }
/// <summary> /// Initializes a new instance of the <see cref="Protogame.RenderPipelineRenderContext"/> class. /// </summary> /// <param name="renderPipeline">The render pipeline shared with the <see cref="RenderPipelineWorldManager"/> instance.</param> public RenderPipelineRenderContext(IRenderPipeline renderPipeline) { _renderPipeline = renderPipeline; }
public static void SetPipeline(IRenderPipeline pipeline) { activePipeline = pipeline; }
public GLLineRenderer(IGLUtils glUtils, IRenderPipeline pipeline) { _pipeline = pipeline; _pool = new ObjectPool <Instruction>(pool => new Instruction(pool, glUtils), 2); }
/// <summary> /// Calls <see cref="ConfigureRenderPipeline"/>, which needs to be implemented by /// your game to configure the render pipeline. /// </summary> /// <param name="pipeline">The render pipeline to configure.</param> protected sealed override void InternalConfigureRenderPipeline(IRenderPipeline pipeline) { ConfigureRenderPipeline(pipeline, _kernel); }
/// <summary> /// Configure the render pipeline before the game begins. /// <para> /// In the new rendering system, you need to add render passes to the render pipeline /// of your game to indicate how things will be rendered. Use /// <see cref="IRenderPipeline.AddFixedRenderPass"/> or /// <see cref="IRenderPipeline.AppendTransientRenderPass"/> to add passes to the render pipeline. /// </para> /// </summary> /// <param name="pipeline">The render pipeline to configure.</param> /// <param name="kernel"> /// The dependency injection kernel, on which you can call <c>Get</c> on to create /// new render passes for adding to the pipeline. /// </param> protected abstract void ConfigureRenderPipeline(IRenderPipeline pipeline, IKernel kernel);
protected override void ConfigureRenderPipeline(IRenderPipeline pipeline, IKernel kernel) { var factory = kernel.Get <IGraphicsFactory>(); pipeline.AddFixedRenderPass(factory.Create2DBatchedRenderPass()); }