-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
59 lines (48 loc) · 1.89 KB
/
Copy pathMain.cpp
File metadata and controls
59 lines (48 loc) · 1.89 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
#include <vector>
#include "EntityShaderProgram.h"
#include "Entity.h"
#include "RawEntity.h"
#include "Renderer.h"
#include "Window.h"
#include "Texture.h"
#include "Vector3f.h"
#include "OBJLoader.h"
#include "Terrain.h"
#include "Camera.h"
#include "InputHandler.h"
#include "InteractableEntity.h"
#include "Light.h"
#include "Timer.h"
#include "ViewFrustum.h"
#include "IUpdatable.h"
#include "RayCaster.h"
int main()
{
Window window(800, 450, std::string("Kaimon"));
ViewFrustum frustum(800.0f, 450.0f, 60.0f, 0.1f, 100.0f);
EntityShaderProgram entityShaderProgram("src/shaders/VertexShader.vert", "src/shaders/FragmentShader.frag");
Camera camera(Vector3f(0.0f, 9.0f, 3.0f), Vector3f(0.0f, -3.0f, -1.0f), Vector3f(0.0f, 1.0f, 0.0f));
Light light(Vector3f(0.0f, 10.0f, 0.0f), Vector3f(0.2f, 0.2f, 0.2f), Vector3f(1.0f, 1.0f, 1.0f), Vector3f(1.0f, 1.0f, 1.0f));
entityShaderProgram.loadLight(light);
RawEntity rawEntity = OBJLoader::loadFile("res/models/wallCube2.obj");
RawEntity rawTerrain = Terrain::createTerrain(20, 20);
Texture texture1("res/textures/checker128.png", 0);
Texture texture2("res/textures/wall.jpg", 1);
Entity terrain(rawTerrain, texture1, Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f), 1.0f);
InteractableEntity entity(rawEntity, texture2, Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f), 1.0f);
std::vector<Entity*> entityList = { &terrain, &entity };
std::vector<IUpdatable*> updatableList = { &camera, &frustum, &entity };
RayCaster rayCaster(camera, frustum, updatableList);
InputHandler inputHandler(window, rayCaster, updatableList);
Timer timer;
while (!window.isWindowShouldClose())
{
float deltaTime = timer.getDeltaTime();
rayCaster.update(deltaTime);
for (IUpdatable* updatable : updatableList)
updatable->update(deltaTime);
Renderer::renderEntities(entityShaderProgram, camera, frustum, entityList);
window.update();
}
return 0;
}