Beispiel #1
0
        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;
            });
        }
Beispiel #3
0
 public void Dispose()
 {
     AXProfiler.Capture(() =>
     {
         _host.StopAsync().GetAwaiter().GetResult();
         _host.Dispose();
     });
 }
Beispiel #4
0
        protected override void Dispose(bool manual)
        {
            Logger.Assert(manual, $"Memory leak detected on object: {this}");


            AXProfiler.Capture(
                () => { _gl.DeleteShader(_rendererID); });
        }
Beispiel #5
0
 public AXHostApplication(AXWindowOptions windowOptions)
 {
     AXProfiler.Capture(() =>
     {
         _host = AXHost.Create(windowOptions).Build();
         _host.Start();
     });
 }
Beispiel #6
0
 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);
     });
 }
Beispiel #8
0
 public override void SetIndexBuffer(IndexBuffer indexBuffer)
 {
     AXProfiler.Capture(() =>
     {
         Bind();
         indexBuffer.Bind();
         _indexBuffer = indexBuffer;
     });
 }
Beispiel #9
0
 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);
     });
 }
Beispiel #10
0
        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);
        }
Beispiel #12
0
        private bool OnUpdate(AppUpdateEvent e)
        {
            if (!_minimized)
            {
                AXProfiler.Capture(() =>
                {
                    foreach (Layer layer in _layers)
                    {
                        layer.OnUpdate(e.DeltaTime);
                    }
                });
            }

            return(true);
        }
Beispiel #13
0
        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;
            });
        }
Beispiel #14
0
        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);
            });
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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);
            });
        }
Beispiel #17
0
 public override void Unbind()
 {
     AXProfiler.Capture(() => { _gl.BindTexture(_textureTarget, 0); });
 }
Beispiel #18
0
 public override void Use(TextureSlot slot)
 {
     AXProfiler.Capture(() => { _gl.BindTextureUnit((uint)slot, _rendererID); });
 }
Beispiel #19
0
 public override void Unbind()
 {
     AXProfiler.Capture(() => { _gl.UseProgram(0); });
 }
Beispiel #20
0
 public override void Bind()
 {
     AXProfiler.Capture(() => { _gl.UseProgram(_rendererID); });
 }
Beispiel #21
0
 public override void Unbind()
 {
     AXProfiler.Capture(() => { _gl.BindVertexArray(0); });
 }
Beispiel #22
0
 public override void Bind()
 {
     AXProfiler.Capture(() => { _gl.BindTexture(_textureTarget, _rendererID); });
 }
Beispiel #23
0
 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);
        }
Beispiel #25
0
 public override void Unbind()
 {
     AXProfiler.Capture(() => { _gl.BindBuffer(BufferTargetARB.ArrayBuffer, 0); });
 }
Beispiel #26
0
 public override void Bind()
 {
     AXProfiler.Capture(() => { _gl.BindVertexArray(_rendererID); });
 }