-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.cu
More file actions
69 lines (55 loc) · 2.3 KB
/
Copy pathEngine.cu
File metadata and controls
69 lines (55 loc) · 2.3 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
58
59
60
61
62
63
64
65
66
67
68
69
#include <SDL2/SDL.h>
#include <iostream>
#include "viewport.h"
#include "user.h"
#include "world.h"
#include <vector>
#include "skybox.h"
const int FPS = 300;
const int FRAME_DELAY = 1000 / FPS;
int main(int argc, char* argv[]) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
std::cerr << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
return -1;
}
const char* filename = "Skybox.exr";
const char* meshname = "Dog.stl";
Skybox* skybox = new Skybox(filename);
Viewport screen = Viewport(1000,1000,"Engine");
Object Cuboid = makeCuboid(Vec3(1,1,1),Quaternion(Vec3(13,18,18)));
Object Cuboid2 = makeCuboid(Vec3(3,3,3),Quaternion(Vec3(5,0,3)), Material(Vec3(0,0,0),0.5,0,0.15,Vec3(0.77, 0.78, 0.78)));
Object Cuboid3 = makeCuboid(Vec3(3,8,3),Quaternion(Vec3(0,0,5)), Material(Vec3(0.9,0.9,0.9),1,0,0.00,Vec3(0.2, 0.15, 0.78)));
Object BasePlate = makeCuboid(Vec3(25,1,25),Quaternion(Vec3(0,1,0)), Material(Vec3(0,0,0),1,0,0.00,Vec3(0.4, 0.4, 0.4)));
Object Mesh = makeMesh(meshname,Quaternion(Vec3(0,1.95,0),Vec3(0,0,1),Vec3(-1,0,0),Vec3(0,-1,0)), Vec3(1,1,1),Material(Vec3(0,0,0),1,0,0.00,Vec3(0.3, 0.1, 0.2)));
PointLight light1 = PointLight(Vec3(3,4,0));
PointLight light2 = PointLight(Vec3(1,1,0));
PointLight light3 = PointLight(Vec3(3,3,5));
World world = World(std::vector<Object> {BasePlate,Mesh}, std::vector<PointLight> {light1}, *skybox);
Camera* cam = new Camera(&world, Quaternion(Vec3(1,1.8,1),Vec3(0,1,0),Vec3(0,0,1),Vec3(1,0,0)),1000,1000,2, M_PI/4);
User user = User(*cam, screen);
bool quit = false;
SDL_Event e;
screen.ClearScreen();
screen.Update();
Uint32 frameStart = 0;
while (!quit) {
user.ProcessMovement();
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
quit = true;
}
else if (e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED) {
screen.Resize(e.window.data1,e.window.data2);
}
}
Uint32 TimePassed = SDL_GetTicks() - frameStart;
if (TimePassed >= FRAME_DELAY) {
user.raytrace();
frameStart = SDL_GetTicks();
}
}
screen.Quit();
cam = nullptr;
skybox = nullptr;
return 0;
}