|
|
|
@ -95,7 +95,7 @@ namespace Renderer { |
|
|
|
|
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); |
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
|
|
|
|
for ( RenderObject *ro: renderObjects )
|
|
|
|
|
for ( RenderObject *ro: renderObjects ) |
|
|
|
|
ro->render(*camera); |
|
|
|
|
|
|
|
|
|
// Record the last frame
|
|
|
|
@ -105,7 +105,7 @@ namespace Renderer { |
|
|
|
|
// Camera
|
|
|
|
|
Camera::Camera(Window* win) { |
|
|
|
|
window = win; |
|
|
|
|
setFOV(DEFAULT_FOV); |
|
|
|
|
FOV = DEFAULT_FOV; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Camera::Camera(Window* win, glm::vec3 pos) : Camera(win) { |
|
|
|
@ -116,8 +116,9 @@ namespace Renderer { |
|
|
|
|
setRotation(angle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::setFOV(float fov) { |
|
|
|
|
projection = glm::perspective(glm::radians(fov), (float)window->width() / (float)window->height(), NEAR_PLANE, FAR_PLANE); |
|
|
|
|
glm::mat4 Camera::getProjection() { |
|
|
|
|
projection = glm::perspective(glm::radians(FOV), (float)window->width() / (float)window->height(), NEAR_PLANE, FAR_PLANE); |
|
|
|
|
return projection; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::updateCameraTransforms() { |
|
|
|
@ -125,7 +126,7 @@ namespace Renderer { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// RenderObject
|
|
|
|
|
RenderObject::RenderObject(std::vector<float> verts, std::vector<unsigned int> indices)
|
|
|
|
|
RenderObject::RenderObject(std::vector<float> verts, std::vector<unsigned int> indices) |
|
|
|
|
: shader(VERT_SHADER_SRC_FILE, FRAG_SHADER_SRC_FILE) { |
|
|
|
|
vertsVec = verts; |
|
|
|
|
indicesVec = indices; |
|
|
|
@ -173,7 +174,7 @@ namespace Renderer { |
|
|
|
|
shader.setMat4("model", modelTransform); |
|
|
|
|
|
|
|
|
|
shader.setMat4("view", cam.view); |
|
|
|
|
shader.setMat4("projection", cam.projection); |
|
|
|
|
shader.setMat4("projection", cam.getProjection()); |
|
|
|
|
|
|
|
|
|
shader.use(); |
|
|
|
|
|
|
|
|
|