private bool OnRender(AppRenderEvent e) { if (!_minimized) { AXProfiler.Capture(() => { AXProfiler.Capture("OnDraw", () => { foreach (Layer layer in _layers) { layer.OnRender(e.DeltaTime); } }); AXProfiler.Capture("OnImGuiRender", () => { // This is currently not tied to our renderer api _imGuiLayer.Begin(e.DeltaTime); foreach (Layer layer in _layers) { layer.OnImGuiRender(e); } _imGuiLayer.End(); }); }); } return(true); }
public void OnUpdate(double deltaTime) { AXProfiler.Capture(() => { if (KeyboardState.IsKeyPressed(AXKey.J)) { _cameraPosition.X -= _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.L)) { _cameraPosition.X += _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.I)) { _cameraPosition.Y += _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.K)) { _cameraPosition.Y -= _cameraSpeed * (float)deltaTime; } Camera.Position = _cameraPosition; }); }
public void Dispose() { AXProfiler.Capture(() => { _host.StopAsync().GetAwaiter().GetResult(); _host.Dispose(); }); }
protected override void Dispose(bool manual) { Logger.Assert(manual, $"Memory leak detected on object: {this}"); AXProfiler.Capture( () => { _gl.DeleteShader(_rendererID); }); }
public AXHostApplication(AXWindowOptions windowOptions) { AXProfiler.Capture(() => { _host = AXHost.Create(windowOptions).Build(); _host.Start(); }); }
public void PushLayer(Layer layer) { AXProfiler.Capture(() => { _layers.PushLayer(layer); layer.OnAttach(); }); }
public void OnEvent(Event e) { AXProfiler.Capture(() => { var eventDispatcher = new EventDispatcher(e); eventDispatcher.Dispatch <MouseScrollEvent>(OnMouseScroll); eventDispatcher.Dispatch <WindowResizeEvent>(OnWindowResize); }); }
public override void SetIndexBuffer(IndexBuffer indexBuffer) { AXProfiler.Capture(() => { Bind(); indexBuffer.Bind(); _indexBuffer = indexBuffer; }); }
public override unsafe void SetData(void *data, uint size) { AXProfiler.Capture(() => { // bytes per pixel int bpp = _dataFormat == PixelFormat.Rgba ? 4 : 3; Logger.Assert(size == _width * _height * bpp, "Data must be entire texture"); _gl.TextureSubImage2D(_rendererID, 0, 0, 0, _width, _height, _dataFormat, PixelType.UnsignedByte, data); }); }
protected override void Dispose(bool manual) { Logger.Assert(manual, $"Memory leak detected on object: {this}"); AXProfiler.Capture(() => { _gl.DeleteFramebuffers(1, _rendererID); _gl.DeleteTextures(1, _colorAttachmentRendererID); _gl.DeleteTextures(1, _depthAttachmentRendererID); }); }
private bool OnMouseScroll(MouseScrollEvent e) { AXProfiler.Capture(() => { _zoomLevel -= e.Offset.Y * _zoomSpeed; _zoomLevel = Math.Max(_zoomLevel, 0.25f); Camera.SetProjection(-_aspectRatio * _zoomLevel, _aspectRatio * _zoomLevel, -_zoomLevel, _zoomLevel); }); return(false); }
private bool OnUpdate(AppUpdateEvent e) { if (!_minimized) { AXProfiler.Capture(() => { foreach (Layer layer in _layers) { layer.OnUpdate(e.DeltaTime); } }); } return(true); }
public OrthographicCamera(float left, float right, float bottom, float top) { AXProfiler.Capture(() => { Left = left; Right = right; Bottom = bottom; Top = top; Rotation = 0; _viewMatrix = Matrix4x4.Identity; ProjectionMatrix = Matrix4x4.CreateOrthographicOffCenter(left, right, bottom, top, 0.0f, 100.0f); ViewProjectionMatrix = ProjectionMatrix * _viewMatrix; }); }
protected override void Dispose(bool manual) { Logger.Assert(manual, $"Memory leak detected on object: {this}"); AXProfiler.Capture(() => { foreach (VertexBuffer vertexBuffer in _vertexBuffers) { vertexBuffer.Dispose(); } _vertexBuffers.Clear(); _indexBuffer.Dispose(); _gl.DeleteVertexArrays(1, _rendererID); }); }
private bool OnLoad(AppLoadEvent e) { AXProfiler.Capture(() => { _imGuiLayer = _layerFactory.CreateImGuiLayer(_window.NativeWindow, _window.InputContext); PushLayer(_imGuiLayer); foreach (Layer layer in _layers) { layer.OnLoad(); } _renderCommandDispatcher.Init(); }); return(true); }
public override unsafe void AddVertexBuffer(VertexBuffer vertexBuffer) { AXProfiler.Capture(() => { Bind(); vertexBuffer.Bind(); BufferLayout?layout = vertexBuffer.GetLayout(); Logger.Assert(layout.HasValue, "Layout should be initialized"); foreach (BufferElement element in layout) { _gl.EnableVertexAttribArray(_vertexAttributeIndex); _gl.VertexAttribPointer(_vertexAttributeIndex, element.GetComponentCount(), ShaderDataTypeToOpenGLBaseType(element.Type), element.Normalized, layout.Value.Stride, (void *)element.Offset); _vertexAttributeIndex++; } _vertexBuffers.Add(vertexBuffer); }); }
public override void Unbind() { AXProfiler.Capture(() => { _gl.BindTexture(_textureTarget, 0); }); }
public override void Use(TextureSlot slot) { AXProfiler.Capture(() => { _gl.BindTextureUnit((uint)slot, _rendererID); }); }
public override void Unbind() { AXProfiler.Capture(() => { _gl.UseProgram(0); }); }
public override void Bind() { AXProfiler.Capture(() => { _gl.UseProgram(_rendererID); }); }
public override void Unbind() { AXProfiler.Capture(() => { _gl.BindVertexArray(0); }); }
public override void Bind() { AXProfiler.Capture(() => { _gl.BindTexture(_textureTarget, _rendererID); }); }
public override void Bind() { AXProfiler.Capture( () => { _gl.BindBuffer(BufferTargetARB.ArrayBuffer, _rendererID); }); }
private bool OnWindowResize(WindowResizeEvent e) { AXProfiler.Capture(() => { OnFramebufferResize(e.Size.X, e.Size.Y); }); return(false); }
public override void Unbind() { AXProfiler.Capture(() => { _gl.BindBuffer(BufferTargetARB.ArrayBuffer, 0); }); }
public override void Bind() { AXProfiler.Capture(() => { _gl.BindVertexArray(_rendererID); }); }