-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrimitiveActor.hpp
More file actions
45 lines (33 loc) · 987 Bytes
/
PrimitiveActor.hpp
File metadata and controls
45 lines (33 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "ShaderProgram.hpp"
#include "Vertex.hpp"
#include "VertexBufferObject.hpp"
#include "DrawList.hpp"
#include "Math.hpp"
struct PrimitiveActor : DrawableObject
{
std::shared_ptr<Texture2D> Texture;
PrimitiveActor() = default;
PrimitiveActor(std::vector<Vertex> InVertices, Location InLocation, std::shared_ptr<Texture2D> InTexture)
{
Vertices = InVertices;
Loc = InLocation;
Texture = InTexture;
VAO.Bind();
VBO.Data(Vertices);
}
virtual void Draw(std::shared_ptr<ShaderProgram> Shader) override
{
VAO.Bind();
CalculateAABB();
Texture->Bind();
glm::mat4 Model = glm::translate(glm::mat4(1.0f), Loc.Vec);
Shader->Uniform("model", Model);
glDrawArrays(GL_TRIANGLES, 0, Vertices.size());
Texture->Unbind();
VAO.Unbind();
}
};