Untitled Game engine no.5  1.0
GLRenderer.hpp
1 #ifndef GLRENDERER_H
2 #define GLRENDERER_H
3 #include "SDL2/SDL.h"
4 #include "Renderer.hpp"
5 #include "Buffer.hpp"
6 #include "RenderTag.hpp"
7 
8 namespace Engine {
12  class GLRenderer : public Renderer {
13  public:
14  GLRenderer();
16  ~GLRenderer();
17 
19  void Init() override;
20 
22  void Shutdown() override;
23 
26  void SetClearColor(uint32_t c) override;
27 
29  void Clear() override;
30 
35  void Submit(const std::string& tag, const Ref <Transform> &transform, const Ref <MeshRenderer>& renderer) override;
36 
43  float AddTexture(const Ref<Texture>& texture);
44 
51  void AddTag(const std::string& name, RenderTag tag, ViewProjection projection = ViewProjection::PROJECTION) override;
52 
56  void Flush() override;
57 
58  private:
60  static const size_t MaxQuadCount = 1000;
62  static const size_t MaxVertexCount = MaxQuadCount * 4;
64  static const size_t MaxIndexCount = MaxQuadCount * 6;
66  static const uint8_t MaxTags = 32;
67 
69  GLenum GLDrawTypeFromDrawType(DrawType d);
70 
71 
73  int textureCount = 0;
74  std::vector<Ref<Texture>> boundTextures;
75 
77  std::vector<std::string> m_order;
78  std::unordered_map<std::string, std::vector<Vertex>> m_Vertices;
80  std::unordered_map<std::string, RenderTag> m_Tags;
81  std::unordered_map<std::string, ViewProjection> m_View;
82  //uint32_t m_Indices[MaxTags][MaxIndexCount]{};
83  uint32_t m_Indices[MaxIndexCount]{};
85  uint8_t tagcount;
87  Ref<VertexBuffer> m_vbo{nullptr};
89  Ref<IndexBuffer> m_ibo{nullptr};
90  };
91 }
92 #endif
93 
Engine::GLRenderer::Init
void Init() override
sets up the renderer
Definition: GLRenderer.cpp:21
Engine::GLRenderer::Flush
void Flush() override
Definition: GLRenderer.cpp:145
Engine::GLRenderer::Shutdown
void Shutdown() override
Shutdown the render api.
Definition: GLRenderer.cpp:60
Engine::Ref
std::shared_ptr< T > Ref
Has stuff for making references a lot more easily shared smart pointer.
Definition: Base.hpp:21
Engine::GLRenderer::Submit
void Submit(const std::string &tag, const Ref< Transform > &transform, const Ref< MeshRenderer > &renderer) override
Definition: GLRenderer.cpp:109
Engine::GLRenderer::SetClearColor
void SetClearColor(uint32_t c) override
Definition: GLRenderer.cpp:64
Engine::RenderTag
Definition: RenderTag.hpp:31
Engine::GLRenderer::AddTag
void AddTag(const std::string &name, RenderTag tag, ViewProjection projection=ViewProjection::PROJECTION) override
Adds a rendering step to the Flush cycle.
Definition: GLRenderer.cpp:77
Engine
Definition: Animation.hpp:14
Engine::GLRenderer::~GLRenderer
~GLRenderer()
Destructor.
Definition: GLRenderer.cpp:19
Engine::GLRenderer
Definition: GLRenderer.hpp:12
Engine::GLRenderer::Clear
void Clear() override
Clear the screen.
Definition: GLRenderer.cpp:73
Engine::GLRenderer::AddTexture
float AddTexture(const Ref< Texture > &texture)
Definition: GLRenderer.cpp:252
Engine::Renderer
Definition: Renderer.hpp:15