-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.h
83 lines (70 loc) · 2.12 KB
/
View.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __VIEW_H__
#define __VIEW_H__
#include "../include/Light.h"
#include "sgraph/RaycastRenderer.hpp"
#ifndef GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_NONE
#endif
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <cstdio>
#include <ShaderProgram.h>
#include "sgraph/SGNodeVisitor.h"
#include "ObjectInstance.h"
#include "PolygonMesh.h"
#include "VertexAttrib.h"
#include "Camera.hpp"
#include "Callbacks.h"
#include "sgraph/IScenegraph.h"
#include "Model.h"
#include <stack>
using namespace std;
class View
{
struct LightLocation {
int ambient, diffuse, specular, position, spotDirection, spotCutoff;
LightLocation() {
ambient = diffuse = specular = position = spotDirection = spotCutoff = -1;
}
};
public:
View(bool useOpenGl = false);
~View();
void init(Callbacks* callbacks, Model& model);
float display(sgraph::IScenegraph *scenegraph, vector<Camera*>& cameras, Camera* activeCamera);
void resize();
bool shouldWindowClose();
void closeWindow();
void output_raytrace(sgraph::IScenegraph *scenegraph, Camera* activeCamera);
private:
void initObjects(Model& model);
vector<glm::vec4> getLightPositions(const glm::mat4& transformation);
void initLights(Model& model);
void initShaderVariables();
GLFWwindow* window;
float aspectRatio;
util::ShaderProgram program;
util::ShaderLocationsVault shaderLocations;
map<string,util::ObjectInstance *> objects;
map<string,util::TextureImage *> textures;
util::ObjectInstance* cameraObj;
glm::mat4 projection;
stack<glm::mat4> modelview;
sgraph::SGNodeVisitor *renderer;
sgraph::RaycastRenderer *raycastRenderer;
int frames;
double time;
double deltaTime;
//the lights in our scene
vector<util::Light> lights;
//the shader locations for all lights, for convenience
vector<LightLocation> lightLocations;
//either name of object, or world, or view
vector<string> lightCoordinateSystems;
//texture ids
map<string,unsigned int> textureIds;
//mipmapping or not
// bool mipmapped;
bool useRaycast = false;
};
#endif