diff --git a/FinalProject/FinalProject.vcxproj b/FinalProject/FinalProject.vcxproj
index 8b69438..1e7c925 100644
--- a/FinalProject/FinalProject.vcxproj
+++ b/FinalProject/FinalProject.vcxproj
@@ -64,11 +64,17 @@
xcopy /y "$(SolutionDir)Libs\*.dll" "$(TargetDir)"
+
+ $(SolutionDir)Libs\*.lib;%(AdditionalDependencies)
+
xcopy /y "$(SolutionDir)Libs\*.dll" "$(TargetDir)"
+
+ $(SolutionDir)Libs\*.lib;%(AdditionalDependencies)
+
diff --git a/FinalProject/camera.cpp b/FinalProject/camera.cpp
index 338c59e..e834b51 100644
--- a/FinalProject/camera.cpp
+++ b/FinalProject/camera.cpp
@@ -17,45 +17,6 @@ Camera::Camera(glm::vec3 position, glm::vec3 direction, glm::vec3 right, glm::ve
updateCameraState();
}
-inline glm::mat4 Camera::viewMatrix() {
- return glm::lookAt(_position, _position + _front, _up);
-}
-
-inline void Camera::move(glm::vec3 direction, float step) {
- _position += direction * step;
- updateCameraState();
-}
-
-inline void Camera::pitch(float deltaAngle) {
- _pitch += deltaAngle;
- updateCameraState();
-}
-
-inline void Camera::setPitch(float angle) {
- _pitch = angle;
- updateCameraState();
-}
-
-inline void Camera::yaw(float deltaAngle) {
- _yaw += deltaAngle;
- updateCameraState();
-}
-
-inline void Camera::setYaw(float angle) {
- _yaw = angle;
- updateCameraState();
-}
-
-inline void Camera::roll(float deltaAngle) {
- _roll += deltaAngle;
- updateCameraState();
-}
-
-inline void Camera::setRoll(float angle) {
- _roll = angle;
- updateCameraState();
-}
-
void Camera::updateCameraState() {
// TODO: Implement vector update with roll pitch, and *roll*
}
\ No newline at end of file
diff --git a/FinalProject/camera.h b/FinalProject/camera.h
index 408e902..022895b 100644
--- a/FinalProject/camera.h
+++ b/FinalProject/camera.h
@@ -46,3 +46,42 @@ public:
private:
void updateCameraState();
};
+
+inline glm::mat4 Camera::viewMatrix() {
+ return glm::lookAt(_position, _position + _front, _up);
+}
+
+inline void Camera::move(glm::vec3 direction, float step) {
+ _position += direction * step;
+ updateCameraState();
+}
+
+inline void Camera::pitch(float deltaAngle) {
+ _pitch += deltaAngle;
+ updateCameraState();
+}
+
+inline void Camera::setPitch(float angle) {
+ _pitch = angle;
+ updateCameraState();
+}
+
+inline void Camera::yaw(float deltaAngle) {
+ _yaw += deltaAngle;
+ updateCameraState();
+}
+
+inline void Camera::setYaw(float angle) {
+ _yaw = angle;
+ updateCameraState();
+}
+
+inline void Camera::roll(float deltaAngle) {
+ _roll += deltaAngle;
+ updateCameraState();
+}
+
+inline void Camera::setRoll(float angle) {
+ _roll = angle;
+ updateCameraState();
+}
diff --git a/FinalProject/ebo.cpp b/FinalProject/ebo.cpp
index 9996aaf..a76f2ec 100644
--- a/FinalProject/ebo.cpp
+++ b/FinalProject/ebo.cpp
@@ -1,7 +1,6 @@
#pragma once
#include "ebo.h"
-#include "utils.h"
ElementBufferObject::ElementBufferObject() {
OPENGL_EXTRA_FUNCTIONS->glGenBuffers(1, &_id);
@@ -32,7 +31,3 @@ ElementBufferObject::ElementBufferObject(std::vector&& indices) :
);
OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
-
-inline void ElementBufferObject::dispose() const {
- OPENGL_EXTRA_FUNCTIONS->glDeleteBuffers(1, &_id);
-}
diff --git a/FinalProject/ebo.h b/FinalProject/ebo.h
index 5e847b1..677ad9e 100644
--- a/FinalProject/ebo.h
+++ b/FinalProject/ebo.h
@@ -2,6 +2,8 @@
#include
+#include "utils.h"
+
class ElementBufferObject
{
private:
@@ -17,4 +19,8 @@ public:
inline std::vector indices() const { return _indices; }
inline void dispose() const;
-};
\ No newline at end of file
+};
+
+inline void ElementBufferObject::dispose() const {
+ OPENGL_EXTRA_FUNCTIONS->glDeleteBuffers(1, &_id);
+}
\ No newline at end of file
diff --git a/FinalProject/logger.cpp b/FinalProject/logger.cpp
index 4947e46..577f913 100644
--- a/FinalProject/logger.cpp
+++ b/FinalProject/logger.cpp
@@ -21,7 +21,7 @@ void Logger::log(LogLevel level, std::string message) {
case WARNING:
std::cout << "[WARNING] " << message << std::endl;
break;
- case ERROR:
+ case ERR:
std::cout << "[ERROR] " << message << std::endl;
break;
}
@@ -40,5 +40,5 @@ void Logger::warning(std::string message) {
}
void Logger::error(std::string message) {
- log(ERROR, message);
+ log(ERR, message);
}
diff --git a/FinalProject/logger.h b/FinalProject/logger.h
index dc88e54..3723415 100644
--- a/FinalProject/logger.h
+++ b/FinalProject/logger.h
@@ -6,7 +6,7 @@
class Logger {
public:
- enum LogLevel { DEBUG, INFO, WARNING, ERROR };
+ enum LogLevel { DEBUG, INFO, WARNING, ERR };
private:
static LogLevel _level;
diff --git a/FinalProject/mesh.cpp b/FinalProject/mesh.cpp
index 986cf26..3c316c1 100644
--- a/FinalProject/mesh.cpp
+++ b/FinalProject/mesh.cpp
@@ -38,7 +38,7 @@ void Mesh::render(const ShaderProgram& shader) const {
OPENGL_EXTRA_FUNCTIONS->glActiveTexture(GL_TEXTURE0);
_vao.setActive();
- glDrawElements(GL_TRIANGLES, _indices.size(), GL_UNSIGNED_INT, 0);
+ OPENGL_EXTRA_FUNCTIONS->glDrawElements(GL_TRIANGLES, _indices.size(), GL_UNSIGNED_INT, 0);
_vao.setInactive();
}
diff --git a/FinalProject/renderable.cpp b/FinalProject/renderable.cpp
index 4497556..40b735b 100644
--- a/FinalProject/renderable.cpp
+++ b/FinalProject/renderable.cpp
@@ -1,7 +1,5 @@
#pragma once
-#include
-
#include "renderable.h"
Renderable::Renderable(Model* model) : _model(model) {}
@@ -32,14 +30,6 @@ void Renderable::setScale(float scale) {
_scale = glm::vec3(scale);
}
-inline glm::mat4 Renderable::modelMatrix() const {
- glm::mat4 model = glm::mat4(1.0f);
- model = glm::translate(model, _position);
- model = model * _rotation;
- model = glm::scale(model, _scale);
- return model;
-}
-
void Renderable::render(ShaderProgram shader) {
_model->render(shader);
}
diff --git a/FinalProject/renderable.h b/FinalProject/renderable.h
index d4e811d..7e5912a 100644
--- a/FinalProject/renderable.h
+++ b/FinalProject/renderable.h
@@ -1,6 +1,7 @@
#pragma once
#include
+#include
#include "model.h"
#include "shader.h"
@@ -29,3 +30,11 @@ public:
public:
void render(ShaderProgram shader);
};
+
+inline glm::mat4 Renderable::modelMatrix() const {
+ glm::mat4 model = glm::mat4(1.0f);
+ model = glm::translate(model, _position);
+ model = model * _rotation;
+ model = glm::scale(model, _scale);
+ return model;
+}
diff --git a/FinalProject/shader.cpp b/FinalProject/shader.cpp
index b43038b..f9811ac 100644
--- a/FinalProject/shader.cpp
+++ b/FinalProject/shader.cpp
@@ -3,14 +3,8 @@
#include
#include "shader.h"
-#include "utils.h"
#include "logger.h"
-inline void Shader::dispose() {
- OPENGL_EXTRA_FUNCTIONS->glDeleteShader(_shaderId);
- _shaderId = 0;
-}
-
VertexShader::VertexShader(const std::string& source){
_shaderId = OPENGL_EXTRA_FUNCTIONS->glCreateShader(GL_VERTEX_SHADER);
compile(source);
@@ -105,17 +99,4 @@ ShaderProgram::ShaderProgram(VertexShader vertexShader, FragmentShader fragmentS
vertexShader.dispose();
fragmentShader.dispose();
geometryShader.dispose();
-}
-
-inline void ShaderProgram::setActive() {
- OPENGL_EXTRA_FUNCTIONS->glUseProgram(_programId);
-}
-
-inline void ShaderProgram::setInactive() {
- OPENGL_EXTRA_FUNCTIONS->glUseProgram(0);
-}
-
-inline void ShaderProgram::dispose() {
- OPENGL_EXTRA_FUNCTIONS->glDeleteProgram(_programId);
- _programId = 0;
}
\ No newline at end of file
diff --git a/FinalProject/shader.h b/FinalProject/shader.h
index e27e588..1e75a34 100644
--- a/FinalProject/shader.h
+++ b/FinalProject/shader.h
@@ -4,6 +4,8 @@
#include
#include
+#include "utils.h"
+
class Shader {
protected:
unsigned int _shaderId = -1;
@@ -18,6 +20,11 @@ protected:
virtual void compile(const std::string& sourceFilePath) = 0;
};
+inline void Shader::dispose() {
+ OPENGL_EXTRA_FUNCTIONS->glDeleteShader(_shaderId);
+ _shaderId = 0;
+}
+
class VertexShader : public Shader {
public:
VertexShader() {}
@@ -67,3 +74,16 @@ public:
inline void dispose();
};
+
+inline void ShaderProgram::setActive() {
+ OPENGL_EXTRA_FUNCTIONS->glUseProgram(_programId);
+}
+
+inline void ShaderProgram::setInactive() {
+ OPENGL_EXTRA_FUNCTIONS->glUseProgram(0);
+}
+
+inline void ShaderProgram::dispose() {
+ OPENGL_EXTRA_FUNCTIONS->glDeleteProgram(_programId);
+ _programId = 0;
+}
diff --git a/FinalProject/texture.cpp b/FinalProject/texture.cpp
index b9ba746..d8086a4 100644
--- a/FinalProject/texture.cpp
+++ b/FinalProject/texture.cpp
@@ -1,4 +1,5 @@
#pragma once
+#define STB_IMAGE_IMPLEMENTATION
#include
#include
@@ -6,7 +7,6 @@
#include "texture.h"
#include "logger.h"
-#include "utils.h"
QOpenGLContext* sharedContext;
@@ -17,7 +17,7 @@ Texture::Texture(TextureType type, std::string path) {
OPENGL_FUNCTIONS->glGenTextures(1, &_id);
OPENGL_FUNCTIONS->glBindTexture(GL_TEXTURE_2D, _id);
-
+
// Set the texture wrapping parameters
OPENGL_FUNCTIONS->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture wrapping to GL_REPEAT (usually basic wrapping method)
OPENGL_FUNCTIONS->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@@ -39,6 +39,10 @@ Texture::Texture(TextureType type, std::string path) {
else if (nrChannels == 4) {
format = GL_RGBA;
}
+ else {
+ Logger::error("Unexpected channel count");
+ return;
+ }
OPENGL_FUNCTIONS->glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
OPENGL_FUNCTIONS->glGenerateMipmap(GL_TEXTURE_2D);
diff --git a/FinalProject/texture.h b/FinalProject/texture.h
index 52c222d..65fd7a1 100644
--- a/FinalProject/texture.h
+++ b/FinalProject/texture.h
@@ -3,6 +3,8 @@
#include
#include
+#include "utils.h"
+
enum TextureType { DIFFUSE, SPECULAR };
class Texture {
@@ -19,6 +21,14 @@ public:
inline TextureType type() const { return _type; }
inline std::string path() const { return _path; }
- inline void bind() const;
- inline void unbind() const;
+ void bind() const;
+ void unbind() const;
};
+
+inline void Texture::bind() const {
+ OPENGL_FUNCTIONS->glBindTexture(GL_TEXTURE_2D, _id);
+}
+
+inline void Texture::unbind() const {
+ OPENGL_FUNCTIONS->glBindTexture(GL_TEXTURE_2D, 0);
+}
diff --git a/FinalProject/vao.cpp b/FinalProject/vao.cpp
index 27fb6db..429a143 100644
--- a/FinalProject/vao.cpp
+++ b/FinalProject/vao.cpp
@@ -1,10 +1,6 @@
#pragma once
-#include
-
#include "vao.h"
-#include "utils.h"
-#include "logger.h"
VertexArrayObject::VertexArrayObject() {
OPENGL_EXTRA_FUNCTIONS->glGenVertexArrays(1, &_id);
@@ -42,66 +38,4 @@ VertexArrayObject::VertexArrayObject(VertexBufferObject&& vbo, ElementBufferObje
OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, _vbo.id());
OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo.id());
OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::setActive() const {
- // Check is id is valid
- if (_id == -1) {
- Logger::error("Binding an invalid VertexArrayObject");
- return;
- }
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
-}
-
-inline void VertexArrayObject::setInactive() const {
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::bindVertexBufferObject(const VertexBufferObject& vbo) {
- _vbo = vbo;
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
- OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, _vbo.id());
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::bindVertexBufferObject(VertexBufferObject&& vbo) {
- _vbo = std::move(vbo);
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
- OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, _vbo.id());
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::bindElementBufferObject(const ElementBufferObject& ebo) {
- _ebo = ebo;
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
- OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo.id());
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::bindElementBufferObject(ElementBufferObject&& ebo) {
- _ebo = std::move(ebo);
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
- OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo.id());
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
-}
-
-inline void VertexArrayObject::setVertexAttributePointer(
- unsigned int index,
- int size,
- unsigned int type,
- bool normalized,
- unsigned int stride,
- const void* pointer
-) const {
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
- OPENGL_EXTRA_FUNCTIONS->glVertexAttribPointer(
- index,
- size,
- type,
- normalized,
- stride,
- pointer
- );
- OPENGL_EXTRA_FUNCTIONS->glEnableVertexAttribArray(index);
- OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
}
\ No newline at end of file
diff --git a/FinalProject/vao.h b/FinalProject/vao.h
index 668490b..5cbd93a 100644
--- a/FinalProject/vao.h
+++ b/FinalProject/vao.h
@@ -4,6 +4,8 @@
#include "vbo.h"
#include "ebo.h"
+#include "utils.h"
+#include "logger.h"
class VertexArrayObject {
private:
@@ -31,4 +33,78 @@ public:
inline void setVertexAttributePointer(unsigned int index, int size, unsigned int type, bool normalized, unsigned int stride, const void* pointer) const;
inline void enableVertexAttribute(unsigned int index) const;
inline void disableVertexAttribute(unsigned int index) const;
-};
\ No newline at end of file
+};
+
+inline void VertexArrayObject::setActive() const {
+ // Check is id is valid
+ if (_id == -1) {
+ Logger::error("Binding an invalid VertexArrayObject");
+ return;
+ }
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+}
+
+inline void VertexArrayObject::setInactive() const {
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::bindVertexBufferObject(const VertexBufferObject& vbo) {
+ _vbo = vbo;
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, _vbo.id());
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::bindVertexBufferObject(VertexBufferObject&& vbo) {
+ _vbo = std::move(vbo);
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, _vbo.id());
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::bindElementBufferObject(const ElementBufferObject& ebo) {
+ _ebo = ebo;
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo.id());
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::bindElementBufferObject(ElementBufferObject&& ebo) {
+ _ebo = std::move(ebo);
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo.id());
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::setVertexAttributePointer(
+ unsigned int index,
+ int size,
+ unsigned int type,
+ bool normalized,
+ unsigned int stride,
+ const void* pointer
+) const {
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glVertexAttribPointer(
+ index,
+ size,
+ type,
+ normalized,
+ stride,
+ pointer
+ );
+ OPENGL_EXTRA_FUNCTIONS->glEnableVertexAttribArray(index);
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::enableVertexAttribute(unsigned int index) const {
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glEnableVertexAttribArray(index);
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
+
+inline void VertexArrayObject::disableVertexAttribute(unsigned int index) const {
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(_id);
+ OPENGL_EXTRA_FUNCTIONS->glDisableVertexAttribArray(index);
+ OPENGL_EXTRA_FUNCTIONS->glBindVertexArray(0);
+}
\ No newline at end of file
diff --git a/FinalProject/vbo.cpp b/FinalProject/vbo.cpp
index 115ed72..9f24404 100644
--- a/FinalProject/vbo.cpp
+++ b/FinalProject/vbo.cpp
@@ -1,7 +1,6 @@
#pragma once
#include "vbo.h"
-#include "utils.h"
VertexBufferObject::VertexBufferObject() {
OPENGL_EXTRA_FUNCTIONS->glGenBuffers(1, &_id);
@@ -32,7 +31,3 @@ VertexBufferObject::VertexBufferObject(std::vector&& vertices) :
);
OPENGL_EXTRA_FUNCTIONS->glBindBuffer(GL_ARRAY_BUFFER, 0);
}
-
-inline void VertexBufferObject::dispose() const {
- OPENGL_EXTRA_FUNCTIONS->glDeleteBuffers(1, &_id);
-}
diff --git a/FinalProject/vbo.h b/FinalProject/vbo.h
index 69230ff..75daad2 100644
--- a/FinalProject/vbo.h
+++ b/FinalProject/vbo.h
@@ -3,6 +3,7 @@
#include
#include "vertex.h"
+#include "utils.h"
class VertexBufferObject {
private:
@@ -18,4 +19,8 @@ public:
inline std::vector vertices() const { return _vertices; }
inline void dispose() const;
-};
\ No newline at end of file
+};
+
+inline void VertexBufferObject::dispose() const {
+ OPENGL_EXTRA_FUNCTIONS->glDeleteBuffers(1, &_id);
+}
\ No newline at end of file
diff --git a/Libs/assimp-vc143-mtd.lib b/Libs/assimp-vc143-mtd.lib
new file mode 100644
index 0000000..49ea296
Binary files /dev/null and b/Libs/assimp-vc143-mtd.lib differ