Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Renderer.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef ENGINE_RENDERER
8#define ENGINE_RENDERER
9
10#include "Mesh.hpp"
11#include "Shader.hpp"
12#include "Texture.hpp"
13#include "Material.hpp"
14#include "../GameObject.hpp"
15#include "../GameObjects/Camera.hpp"
16#include <memory>
17#include <GLES3/gl3.h>
18
19namespace Engine::Graphics {
20
33 class Renderer {
34 private:
35 unsigned long m_context;
36 const char* m_id;
37
38 unsigned int m_vbo;
39 unsigned int m_vao;
40 unsigned int m_ebo;
41
42 unsigned int m_currentShaderProgram;
43
44 Camera* m_camera;
45
46 public:
47
53 Renderer(const char* id = "canvas");
54
58 void ClearBuffer();
59
77 void DrawMesh(Mesh* mesh, Vec3f position = {0, 0, 0},
78 Vec3f scale = {1, 1, 1}, Vec3f rotation = {0, 0, 0});
79
86 void UseShader(Shader& shader);
87
118 void UseTexture(Texture& texture, unsigned int slot = GL_TEXTURE0);
119
127 void UseMaterial(Material* material);
128
138 void SetCameraReference(Camera& camera);
139
145 void SetBackgroundColor(Vec3f color);
146 };
147}
148
149#endif
Camera class for the game engine.
Definition Camera.hpp:19
an semi-abstract class that represents a material to a shader
Definition Material.hpp:43
a class used to interact with html canvases
Definition Renderer.hpp:33
void SetCameraReference(Camera &camera)
Sets the camera reference.
Definition Renderer.cpp:160
void UseShader(Shader &shader)
Sets the currently loaded shader.
Definition Renderer.cpp:144
void ClearBuffer()
Clears the canvas to the default clear color.
Definition Renderer.cpp:65
void SetBackgroundColor(Vec3f color)
Sets the background color of the canvas.
Definition Renderer.cpp:164
void UseTexture(Texture &texture, unsigned int slot=GL_TEXTURE0)
Takes the texture and binds it to the specified slot.
Definition Renderer.cpp:149
void DrawMesh(Mesh *mesh, Vec3f position={0, 0, 0}, Vec3f scale={1, 1, 1}, Vec3f rotation={0, 0, 0})
Draws a mesh to the canvas.
Definition Renderer.cpp:69
void UseMaterial(Material *material)
Sets the currently loaded material.
Definition Renderer.cpp:155
A class used to load and use shaders.
Definition Shader.hpp:37
A wrapper class for a texture for the game engine.
Definition Texture.hpp:35
A 3D vector struct with overloaded operators.
Definition Utils.hpp:86