added batch rendering
This commit is contained in:
@@ -34,13 +34,13 @@ namespace OpenEngine {
|
||||
bool OnWindowResize(WindowResizeEvent& event);
|
||||
|
||||
private:
|
||||
inline static Application* instance;
|
||||
|
||||
bool running = true;
|
||||
std::unique_ptr<Window> window;
|
||||
|
||||
Ref<ImGuiLayer> imgui_layer;
|
||||
inline static Application* instance;
|
||||
bool running = true;
|
||||
|
||||
LayerStack layer_stack;
|
||||
Ref<ImGuiLayer> imgui_layer;
|
||||
|
||||
friend int ::main(int argc, char **argv);
|
||||
};
|
||||
|
||||
@@ -9,9 +9,12 @@ namespace OpenEngine {
|
||||
class OpenGLVertexBuffer : public VertexBuffer
|
||||
{
|
||||
public:
|
||||
OpenGLVertexBuffer(uint32_t size);
|
||||
OpenGLVertexBuffer(float* vertices, uint32_t size);
|
||||
virtual ~OpenGLVertexBuffer();
|
||||
|
||||
virtual void SetData(const void* data, uint32_t size) override;
|
||||
|
||||
virtual void Bind() const override;
|
||||
virtual void UnBind() const override;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OPENGL_RENDERER_API_HPP
|
||||
|
||||
#include "open_engine/renderer/renderer_api.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace OpenEngine {
|
||||
class OpenGLRendererAPI : public RendererAPI
|
||||
@@ -14,7 +15,7 @@ namespace OpenEngine {
|
||||
virtual void SetClearColor(const glm::vec4& color) override;
|
||||
virtual void Clear() override;
|
||||
|
||||
virtual void DrawIndexed(const Ref<VertexArray>& vertex_array) override;
|
||||
virtual void DrawIndexed(const Ref<VertexArray>& vertex_array, uint32_t index_count = 0) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,12 +61,15 @@ namespace OpenEngine {
|
||||
public:
|
||||
virtual ~VertexBuffer() = default;
|
||||
|
||||
virtual void SetData(const void* data, uint32_t size) = 0;
|
||||
|
||||
virtual void Bind() const = 0;
|
||||
virtual void UnBind() const = 0;
|
||||
|
||||
virtual const BufferLayout& GetLayout() const = 0;
|
||||
virtual void SetLayout(const BufferLayout& layout) = 0;
|
||||
|
||||
static Ref<VertexBuffer> Create(uint32_t size);
|
||||
static Ref<VertexBuffer> Create(float* vertices, uint32_t size);
|
||||
};
|
||||
|
||||
@@ -80,7 +83,7 @@ namespace OpenEngine {
|
||||
|
||||
virtual uint32_t GetCount() const = 0;
|
||||
|
||||
static Ref<IndexBuffer> Create(uint32_t* indices, uint32_t size);
|
||||
static Ref<IndexBuffer> Create(uint32_t* indices, uint32_t count);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace OpenEngine {
|
||||
api->Clear();
|
||||
};
|
||||
|
||||
inline static void DrawIndexed(const Ref<VertexArray>& vertex_array)
|
||||
inline static void DrawIndexed(const Ref<VertexArray>& vertex_array, uint32_t count = 0)
|
||||
{
|
||||
OE_PROFILE_FUNCTION();
|
||||
|
||||
api->DrawIndexed(vertex_array);
|
||||
api->DrawIndexed(vertex_array, count);
|
||||
};
|
||||
|
||||
inline static void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef RENDERER2D_HPP
|
||||
#define RENDERER2D_HPP
|
||||
|
||||
#include "open_engine/logging.hpp"
|
||||
#include "open_engine/orthographic_camera.hpp"
|
||||
#include "open_engine/renderer/texture.hpp"
|
||||
#include "open_engine/ref_scope.hpp"
|
||||
@@ -23,6 +24,7 @@ namespace OpenEngine {
|
||||
|
||||
static void BeginScene(const OrthographicCamera& camera);
|
||||
static void EndScene();
|
||||
static void Flush();
|
||||
|
||||
static void DrawQuad(const Transform& transform_data, const glm::vec4& color);
|
||||
static void DrawQuad(const Transform& transform_data, const Ref<Texture2D>& texture, float tiling_factor = 1.0f);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "open_engine/renderer/vertex_array.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace OpenEngine {
|
||||
@@ -22,7 +23,7 @@ namespace OpenEngine {
|
||||
virtual void SetClearColor(const glm::vec4& color) = 0;
|
||||
virtual void Clear() = 0;
|
||||
|
||||
virtual void DrawIndexed(const Ref<VertexArray>& vertex_array) = 0;
|
||||
virtual void DrawIndexed(const Ref<VertexArray>& vertex_array, uint32_t count = 0) = 0;
|
||||
|
||||
static inline API GetAPI() { return api; };
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define VERTEX_ARRAY_HPP
|
||||
|
||||
#include "open_engine/renderer/buffer.hpp"
|
||||
#include "open_engine/core.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user