mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Support for out-of-source builds.
Uses environment variable to tell the program where to find resource files. Sharder sources are still search for in the current workind directory.
This commit is contained in:
49
includes/learnopengl/filesystem.h
Normal file
49
includes/learnopengl/filesystem.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef FILESYSTEM_H
|
||||||
|
#define FILESYSTEM_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class FileSystem
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
typedef std::string (*Builder) (const std::string& path);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::string getPath(const std::string& path)
|
||||||
|
{
|
||||||
|
static std::string(*pathBuilder)(std::string const &) = getPathBuilder();
|
||||||
|
return (*pathBuilder)(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::string const & getRoot()
|
||||||
|
{
|
||||||
|
static char const * givenRoot {getenv("LOGL_ROOT_PATH")};
|
||||||
|
static std::string root {givenRoot != nullptr ? givenRoot : ""};
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
//static std::string(*foo (std::string const &)) getPathBuilder()
|
||||||
|
static Builder getPathBuilder()
|
||||||
|
{
|
||||||
|
if (getRoot() != "")
|
||||||
|
return &FileSystem::getPathRelativeRoot;
|
||||||
|
else
|
||||||
|
return &FileSystem::getPathRelativeBinary;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string getPathRelativeRoot(const std::string& path)
|
||||||
|
{
|
||||||
|
return getRoot() + std::string("/") + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string getPathRelativeBinary(const std::string& path)
|
||||||
|
{
|
||||||
|
return "../../../" + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// FILESYSTEM_H
|
||||||
|
#endif
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
// Constructor, expects a filepath to a 3D model.
|
// Constructor, expects a filepath to a 3D model.
|
||||||
Model(GLchar* path, bool gamma = false) : gammaCorrection(gamma)
|
Model(string const & path, bool gamma = false) : gammaCorrection(gamma)
|
||||||
{
|
{
|
||||||
this->loadModel(path);
|
this->loadModel(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -105,7 +105,9 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image = SOIL_load_image("../../../resources/textures/container.jpg", &width, &height, 0, SOIL_LOAD_RGB);
|
|
||||||
|
unsigned char* image = SOIL_load_image(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
@@ -122,7 +124,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
image = SOIL_load_image("../../../resources/textures/awesomeface.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -109,7 +109,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image = SOIL_load_image("../../../resources/textures/container.jpg", &width, &height, 0, SOIL_LOAD_RGB);
|
unsigned char* image = SOIL_load_image(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
@@ -126,7 +126,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
image = SOIL_load_image("../../../resources/textures/awesomeface.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -150,7 +150,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image = SOIL_load_image("../../../resources/textures/container.jpg", &width, &height, 0, SOIL_LOAD_RGB);
|
unsigned char* image = SOIL_load_image(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
@@ -167,7 +167,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
image = SOIL_load_image("../../../resources/textures/awesomeface.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -162,7 +163,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image = SOIL_load_image("../../../resources/textures/container.jpg", &width, &height, 0, SOIL_LOAD_RGB);
|
unsigned char* image = SOIL_load_image(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
@@ -177,7 +178,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
// Load, create texture and generate mipmaps
|
// Load, create texture and generate mipmaps
|
||||||
image = SOIL_load_image("../../../resources/textures/awesomeface.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
SOIL_free_image_data(image);
|
SOIL_free_image_data(image);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
#include <learnopengl/camera.h>
|
#include <learnopengl/camera.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -163,7 +163,7 @@ int main()
|
|||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image;
|
unsigned char* image;
|
||||||
// Diffuse map
|
// Diffuse map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
@@ -173,7 +173,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
// Specular map
|
// Specular map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2_specular.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2_specular.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, specularMap);
|
glBindTexture(GL_TEXTURE_2D, specularMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
#include <learnopengl/camera.h>
|
#include <learnopengl/camera.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -176,7 +176,7 @@ int main()
|
|||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image;
|
unsigned char* image;
|
||||||
// Diffuse map
|
// Diffuse map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
@@ -186,7 +186,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
// Specular map
|
// Specular map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2_specular.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2_specular.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, specularMap);
|
glBindTexture(GL_TEXTURE_2D, specularMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// Other includes
|
// Other includes
|
||||||
#include <learnopengl/shader.h>
|
#include <learnopengl/shader.h>
|
||||||
#include <learnopengl/camera.h>
|
#include <learnopengl/camera.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
@@ -183,7 +183,7 @@ int main()
|
|||||||
int width, height;
|
int width, height;
|
||||||
unsigned char* image;
|
unsigned char* image;
|
||||||
// Diffuse map
|
// Diffuse map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
glBindTexture(GL_TEXTURE_2D, diffuseMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
@@ -193,7 +193,7 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
// Specular map
|
// Specular map
|
||||||
image = SOIL_load_image("../../../resources/textures/container2_specular.png", &width, &height, 0, SOIL_LOAD_RGB);
|
image = SOIL_load_image(FileSystem::getPath("resources/textures/container2_specular.png").c_str(), &width, &height, 0, SOIL_LOAD_RGB);
|
||||||
glBindTexture(GL_TEXTURE_2D, specularMap);
|
glBindTexture(GL_TEXTURE_2D, specularMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -74,7 +75,7 @@ int main()
|
|||||||
Shader shader("shader.vs", "shader.frag");
|
Shader shader("shader.vs", "shader.frag");
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
Model ourModel("../../../resources/objects/nanosuit/nanosuit.obj");
|
Model ourModel(FileSystem::getPath("resources/objects/nanosuit/nanosuit.obj").c_str());
|
||||||
|
|
||||||
// Draw in wireframe
|
// Draw in wireframe
|
||||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -28,7 +29,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -156,8 +157,8 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/marble.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/marble.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
@@ -213,7 +214,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
|
|
||||||
@@ -67,8 +69,8 @@ int main()
|
|||||||
Shader instanceShader("instanced_asteroids.vs", "instanced_asteroids.frag");
|
Shader instanceShader("instanced_asteroids.vs", "instanced_asteroids.frag");
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
Model rock("../../../resources/objects/rock/rock.obj");
|
Model rock(FileSystem::getPath("resources/objects/rock/rock.obj").c_str());
|
||||||
Model planet("../../../resources/objects/planet/planet.obj");
|
Model planet(FileSystem::getPath("resources/objects/planet/planet.obj").c_str());
|
||||||
|
|
||||||
// Set projection matrix
|
// Set projection matrix
|
||||||
glm::mat4 projection = glm::perspective(45.0f, (GLfloat)screenWidth/(GLfloat)screenHeight, 1.0f, 10000.0f);
|
glm::mat4 projection = glm::perspective(45.0f, (GLfloat)screenWidth/(GLfloat)screenHeight, 1.0f, 10000.0f);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -28,7 +29,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -160,8 +161,8 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/marble.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/marble.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
@@ -260,7 +261,7 @@ void DrawScene()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -28,7 +29,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha = false);
|
GLuint loadTexture(GLchar const * path, GLboolean alpha = false);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -177,9 +178,9 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/marble.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/marble.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
GLuint transparentTexture = loadTexture("../../../resources/textures/grass.png", true);
|
GLuint transparentTexture = loadTexture(FileSystem::getPath("resources/textures/grass.png").c_str(), true);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
std::vector<glm::vec3> vegetation;
|
std::vector<glm::vec3> vegetation;
|
||||||
@@ -252,7 +253,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha)
|
GLuint loadTexture(GLchar const * path, GLboolean alpha)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -29,7 +30,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha = false);
|
GLuint loadTexture(GLchar const * path, GLboolean alpha = false);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -180,9 +181,9 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/marble.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/marble.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
GLuint transparentTexture = loadTexture("../../../resources/textures/window.png", true);
|
GLuint transparentTexture = loadTexture(FileSystem::getPath("resources/textures/window.png").c_str(), true);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
std::vector<glm::vec3> windows;
|
std::vector<glm::vec3> windows;
|
||||||
@@ -263,7 +264,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha)
|
GLuint loadTexture(GLchar const * path, GLboolean alpha)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using namespace std;
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -30,7 +31,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha = false);
|
GLuint loadTexture(GLchar const * path, GLboolean alpha = false);
|
||||||
GLuint generateAttachmentTexture(GLboolean depth, GLboolean stencil);
|
GLuint generateAttachmentTexture(GLboolean depth, GLboolean stencil);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
@@ -182,8 +183,8 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/container.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/container.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
// Framebuffers
|
// Framebuffers
|
||||||
@@ -291,7 +292,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path, GLboolean alpha)
|
GLuint loadTexture(GLchar const * path, GLboolean alpha)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using namespace std;
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
@@ -30,7 +31,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
GLuint loadCubemap(std::vector<const GLchar*> faces);
|
GLuint loadCubemap(std::vector<const GLchar*> faces);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
@@ -198,12 +199,12 @@ int main()
|
|||||||
|
|
||||||
// Cubemap (Skybox)
|
// Cubemap (Skybox)
|
||||||
std::vector<const GLchar*> faces;
|
std::vector<const GLchar*> faces;
|
||||||
faces.push_back("../../../resources/textures/skybox/right.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/right.jpg").c_str());
|
||||||
faces.push_back("../../../resources/textures/skybox/left.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/left.jpg").c_str());
|
||||||
faces.push_back("../../../resources/textures/skybox/top.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/top.jpg").c_str());
|
||||||
faces.push_back("../../../resources/textures/skybox/bottom.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/bottom.jpg").c_str());
|
||||||
faces.push_back("../../../resources/textures/skybox/back.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/back.jpg").c_str());
|
||||||
faces.push_back("../../../resources/textures/skybox/front.jpg");
|
faces.push_back(FileSystem::getPath("resources/textures/skybox/front.jpg").c_str());
|
||||||
GLuint skyboxTexture = loadCubemap(faces);
|
GLuint skyboxTexture = loadCubemap(faces);
|
||||||
|
|
||||||
// Draw as wireframe
|
// Draw as wireframe
|
||||||
@@ -300,7 +301,7 @@ GLuint loadCubemap(std::vector<const GLchar*> faces)
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -100,7 +101,7 @@ int main()
|
|||||||
glm::vec3 lightPos(0.0f, 0.0f, 0.0f);
|
glm::vec3 lightPos(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/wood.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str());
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
while(!glfwWindowShouldClose(window))
|
while(!glfwWindowShouldClose(window))
|
||||||
@@ -147,7 +148,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path, bool gammaCorrection);
|
GLuint loadTexture(GLchar const * path, bool gammaCorrection);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -112,8 +113,8 @@ int main()
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/wood.png", false);
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str(), false);
|
||||||
GLuint floorTextureGammaCorrected = loadTexture("../../../resources/textures/wood.png", true);
|
GLuint floorTextureGammaCorrected = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str(), true);
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
@@ -161,7 +162,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path, bool gammaCorrection)
|
GLuint loadTexture(GLchar const * path, bool gammaCorrection)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderScene(Shader &shader);
|
void RenderScene(Shader &shader);
|
||||||
void RenderCube();
|
void RenderCube();
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
@@ -114,7 +115,7 @@ int main()
|
|||||||
glm::vec3 lightPos(-2.0f, 4.0f, -1.0f);
|
glm::vec3 lightPos(-2.0f, 4.0f, -1.0f);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
woodTexture = loadTexture("../../../resources/textures/wood.png");
|
woodTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str());
|
||||||
|
|
||||||
// Configure depth map FBO
|
// Configure depth map FBO
|
||||||
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||||
@@ -345,7 +346,7 @@ void RenderCube()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderScene(Shader &shader);
|
void RenderScene(Shader &shader);
|
||||||
void RenderCube();
|
void RenderCube();
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
@@ -89,7 +90,7 @@ int main()
|
|||||||
glm::vec3 lightPos(0.0f, 0.0f, 0.0f);
|
glm::vec3 lightPos(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
woodTexture = loadTexture("../../../resources/textures/wood.png");
|
woodTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str());
|
||||||
|
|
||||||
// Configure depth map FBO
|
// Configure depth map FBO
|
||||||
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||||
@@ -300,7 +301,7 @@ void RenderCube()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||||
@@ -156,8 +156,8 @@ int main()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint cubeTexture = loadTexture("../../../resources/textures/marble.jpg");
|
GLuint cubeTexture = loadTexture(FileSystem::getPath("resources/textures/marble.jpg").c_str());
|
||||||
GLuint floorTexture = loadTexture("../../../resources/textures/metal.png");
|
GLuint floorTexture = loadTexture(FileSystem::getPath("resources/textures/metal.png").c_str());
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
@@ -213,7 +213,7 @@ int main()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -29,7 +30,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
@@ -73,8 +74,8 @@ int main()
|
|||||||
Shader shader("normal_mapping.vs", "normal_mapping.frag");
|
Shader shader("normal_mapping.vs", "normal_mapping.frag");
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint diffuseMap = loadTexture("../../../resources/textures/brickwall.jpg");
|
GLuint diffuseMap = loadTexture(FileSystem::getPath("resources/textures/brickwall.jpg").c_str());
|
||||||
GLuint normalMap = loadTexture("../../../resources/textures/brickwall_normal.jpg");
|
GLuint normalMap = loadTexture(FileSystem::getPath("resources/textures/brickwall_normal.jpg").c_str());
|
||||||
|
|
||||||
// Set texture units
|
// Set texture units
|
||||||
shader.Use();
|
shader.Use();
|
||||||
@@ -229,7 +230,7 @@ void RenderQuad()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -29,7 +30,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
@@ -76,12 +77,12 @@ int main()
|
|||||||
Shader shader("parallax_mapping.vs", "parallax_mapping.frag");
|
Shader shader("parallax_mapping.vs", "parallax_mapping.frag");
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint diffuseMap = loadTexture("../../../resources/textures/bricks2.jpg");
|
GLuint diffuseMap = loadTexture(FileSystem::getPath("resources/textures/bricks2.jpg").c_str());
|
||||||
GLuint normalMap = loadTexture("../../../resources/textures/bricks2_normal.jpg");
|
GLuint normalMap = loadTexture(FileSystem::getPath("resources/textures/bricks2_normal.jpg").c_str());
|
||||||
GLuint heightMap = loadTexture("../../../resources/textures/bricks2_disp.jpg");
|
GLuint heightMap = loadTexture(FileSystem::getPath("resources/textures/bricks2_disp.jpg").c_str());
|
||||||
//GLuint diffuseMap = loadTexture("../../../resources/textures/wood.png");
|
//GLuint diffuseMap = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str();
|
||||||
//GLuint normalMap = loadTexture("../../../resources/textures/toy_box_normal.png");
|
//GLuint normalMap = loadTexture(FileSystem::getPath("resources/textures/toy_box_normal.png").c_str());
|
||||||
//GLuint heightMap = loadTexture("../../../resources/textures/toy_box_disp.png");
|
//GLuint heightMap = loadTexture(FileSystem::getPath("resources/textures/toy_box_disp.png").c_str());
|
||||||
|
|
||||||
// Set texture units
|
// Set texture units
|
||||||
shader.Use();
|
shader.Use();
|
||||||
@@ -241,7 +242,7 @@ void RenderQuad()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
//Generate texture ID and load texture data
|
//Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderScene(Shader &shader);
|
void RenderScene(Shader &shader);
|
||||||
void RenderCube();
|
void RenderCube();
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
@@ -94,7 +95,7 @@ int main()
|
|||||||
lightColors.push_back(glm::vec3(0.0f, 0.1f, 0.0f));
|
lightColors.push_back(glm::vec3(0.0f, 0.1f, 0.0f));
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
woodTexture = loadTexture("../../../resources/textures/wood.png");
|
woodTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str());
|
||||||
|
|
||||||
// Set up floating point framebuffer to render scene to
|
// Set up floating point framebuffer to render scene to
|
||||||
GLuint hdrFBO;
|
GLuint hdrFBO;
|
||||||
@@ -288,7 +289,7 @@ void RenderCube()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -25,7 +26,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderScene(Shader &shader);
|
void RenderScene(Shader &shader);
|
||||||
void RenderCube();
|
void RenderCube();
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
@@ -98,8 +99,8 @@ int main()
|
|||||||
lightColors.push_back(glm::vec3(0.0f, 1.5f, 0.0f));
|
lightColors.push_back(glm::vec3(0.0f, 1.5f, 0.0f));
|
||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
GLuint woodTexture = loadTexture("../../../resources/textures/wood.png");
|
GLuint woodTexture = loadTexture(FileSystem::getPath("resources/textures/wood.png").c_str());
|
||||||
GLuint containerTexture = loadTexture("../../../resources/textures/container2.png");
|
GLuint containerTexture = loadTexture(FileSystem::getPath("resources/textures/container2.png").c_str());
|
||||||
|
|
||||||
// Set up floating point framebuffer to render scene to
|
// Set up floating point framebuffer to render scene to
|
||||||
GLuint hdrFBO;
|
GLuint hdrFBO;
|
||||||
@@ -386,7 +387,7 @@ void RenderCube()
|
|||||||
// This function loads a texture from file. Note: texture loading functions like these are usually
|
// This function loads a texture from file. Note: texture loading functions like these are usually
|
||||||
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
|
||||||
// For learning purposes we'll just define it as a utility function.
|
// For learning purposes we'll just define it as a utility function.
|
||||||
GLuint loadTexture(GLchar* path)
|
GLuint loadTexture(GLchar const * path)
|
||||||
{
|
{
|
||||||
// Generate texture ID and load texture data
|
// Generate texture ID and load texture data
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
// Other Libs
|
// Other Libs
|
||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -26,7 +27,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
|
||||||
void Do_Movement();
|
void Do_Movement();
|
||||||
GLuint loadTexture(GLchar* path);
|
GLuint loadTexture(GLchar const * path);
|
||||||
void RenderCube();
|
void RenderCube();
|
||||||
void RenderQuad();
|
void RenderQuad();
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ int main()
|
|||||||
glUniform1i(glGetUniformLocation(shaderLightingPass.Program, "gAlbedoSpec"), 2);
|
glUniform1i(glGetUniformLocation(shaderLightingPass.Program, "gAlbedoSpec"), 2);
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
Model cyborg("../../../resources/objects/nanosuit/nanosuit.obj");
|
Model cyborg(FileSystem::getPath("resources/objects/nanosuit/nanosuit.obj").c_str());
|
||||||
std::vector<glm::vec3> objectPositions;
|
std::vector<glm::vec3> objectPositions;
|
||||||
objectPositions.push_back(glm::vec3(-3.0, -3.0, -3.0));
|
objectPositions.push_back(glm::vec3(-3.0, -3.0, -3.0));
|
||||||
objectPositions.push_back(glm::vec3(0.0, -3.0, -3.0));
|
objectPositions.push_back(glm::vec3(0.0, -3.0, -3.0));
|
||||||
@@ -219,7 +220,7 @@ int main()
|
|||||||
// Then calculate radius of light volume/sphere
|
// Then calculate radius of light volume/sphere
|
||||||
const GLfloat lightThreshold = 5.0; // 5 / 256
|
const GLfloat lightThreshold = 5.0; // 5 / 256
|
||||||
const GLfloat maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
|
const GLfloat maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
|
||||||
GLfloat radius = (-linear + std::sqrtf(linear * linear - 4 * quadratic * (constant - (256.0 / lightThreshold) * maxBrightness))) / (2 * quadratic);
|
GLfloat radius = (-linear + std::sqrt(linear * linear - 4 * quadratic * (constant - (256.0 / lightThreshold) * maxBrightness))) / (2 * quadratic);
|
||||||
glUniform1f(glGetUniformLocation(shaderLightingPass.Program, ("lights[" + std::to_string(i) + "].Radius").c_str()), radius);
|
glUniform1f(glGetUniformLocation(shaderLightingPass.Program, ("lights[" + std::to_string(i) + "].Radius").c_str()), radius);
|
||||||
}
|
}
|
||||||
glUniform3fv(glGetUniformLocation(shaderLightingPass.Program, "viewPos"), 1, &camera.Position[0]);
|
glUniform3fv(glGetUniformLocation(shaderLightingPass.Program, "viewPos"), 1, &camera.Position[0]);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <SOIL.h>
|
#include <SOIL.h>
|
||||||
|
|
||||||
#include <random> // necessary for generation of random floats (for sample kernel and noise texture)
|
#include <random> // necessary for generation of random floats (for sample kernel and noise texture)
|
||||||
|
#include <learnopengl/filesystem.h>
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
const GLuint SCR_WIDTH = 800, SCR_HEIGHT = 600;
|
||||||
@@ -96,7 +97,7 @@ int main()
|
|||||||
glUniform1i(glGetUniformLocation(shaderSSAO.Program, "texNoise"), 2);
|
glUniform1i(glGetUniformLocation(shaderSSAO.Program, "texNoise"), 2);
|
||||||
|
|
||||||
// Objects
|
// Objects
|
||||||
Model nanosuit("../../../resources/objects/nanosuit/nanosuit.obj");
|
Model nanosuit(FileSystem::getPath("resources/objects/nanosuit/nanosuit.obj").c_str());
|
||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
glm::vec3 lightPos = glm::vec3(2.0, 4.0, -2.0);
|
glm::vec3 lightPos = glm::vec3(2.0, 4.0, -2.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user