diff --git a/includes/learnopengl/filesystem.h b/includes/learnopengl/filesystem.h index 5dc189c..8ea1c1c 100644 --- a/includes/learnopengl/filesystem.h +++ b/includes/learnopengl/filesystem.h @@ -2,6 +2,7 @@ #define FILESYSTEM_H #include +#include #include "root_directory.h" // This is a configuration file generated by CMake. class FileSystem diff --git a/includes/learnopengl/model.h b/includes/learnopengl/model.h index 838da48..cc12c84 100644 --- a/includes/learnopengl/model.h +++ b/includes/learnopengl/model.h @@ -141,29 +141,26 @@ private: indices.push_back(face.mIndices[j]); } // process materials - if(mesh->mMaterialIndex >= 0) - { - aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex]; - // we assume a convention for sampler names in the shaders. Each diffuse texture should be named - // as 'texture_diffuseN' where N is a sequential number ranging from 1 to MAX_SAMPLER_NUMBER. - // Same applies to other texture as the following list summarizes: - // diffuse: texture_diffuseN - // specular: texture_specularN - // normal: texture_normalN + aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex]; + // we assume a convention for sampler names in the shaders. Each diffuse texture should be named + // as 'texture_diffuseN' where N is a sequential number ranging from 1 to MAX_SAMPLER_NUMBER. + // Same applies to other texture as the following list summarizes: + // diffuse: texture_diffuseN + // specular: texture_specularN + // normal: texture_normalN - // 1. diffuse maps - vector diffuseMaps = loadMaterialTextures(material, aiTextureType_DIFFUSE, "texture_diffuse"); - textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end()); - // 2. specular maps - vector specularMaps = loadMaterialTextures(material, aiTextureType_SPECULAR, "texture_specular"); - textures.insert(textures.end(), specularMaps.begin(), specularMaps.end()); - // 3. normal maps - std::vector normalMaps = loadMaterialTextures(material, aiTextureType_HEIGHT, "texture_normal"); - textures.insert(textures.end(), normalMaps.begin(), normalMaps.end()); - // 4. height maps - std::vector heightMaps = loadMaterialTextures(material, aiTextureType_AMBIENT, "texture_height"); - textures.insert(textures.end(), heightMaps.begin(), heightMaps.end()); - } + // 1. diffuse maps + vector diffuseMaps = loadMaterialTextures(material, aiTextureType_DIFFUSE, "texture_diffuse"); + textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end()); + // 2. specular maps + vector specularMaps = loadMaterialTextures(material, aiTextureType_SPECULAR, "texture_specular"); + textures.insert(textures.end(), specularMaps.begin(), specularMaps.end()); + // 3. normal maps + std::vector normalMaps = loadMaterialTextures(material, aiTextureType_HEIGHT, "texture_normal"); + textures.insert(textures.end(), normalMaps.begin(), normalMaps.end()); + // 4. height maps + std::vector heightMaps = loadMaterialTextures(material, aiTextureType_AMBIENT, "texture_height"); + textures.insert(textures.end(), heightMaps.begin(), heightMaps.end()); // return a mesh object created from the extracted mesh data return Mesh(vertices, indices, textures); @@ -243,4 +240,4 @@ unsigned int TextureFromFile(const char *path, const string &directory, bool gam return textureID; } -#endif \ No newline at end of file +#endif diff --git a/src/1.getting_started/1.1.hello_window/hello_window.cpp b/src/1.getting_started/1.1.hello_window/hello_window.cpp index d37668e..db708c9 100644 --- a/src/1.getting_started/1.1.hello_window/hello_window.cpp +++ b/src/1.getting_started/1.1.hello_window/hello_window.cpp @@ -75,4 +75,4 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // make sure the viewport matches the new window dimensions; note that width and // height will be significantly larger than specified on retina displays. glViewport(0, 0, width, height); -} \ No newline at end of file +} diff --git a/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp b/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp index ea4e33d..3f799c7 100644 --- a/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp +++ b/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp @@ -2,6 +2,7 @@ #include #include +#include void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow *window); @@ -182,4 +183,4 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // make sure the viewport matches the new window dimensions; note that width and // height will be significantly larger than specified on retina displays. glViewport(0, 0, width, height); -} \ No newline at end of file +} diff --git a/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp b/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp index 99b77bd..b554227 100644 --- a/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp +++ b/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp @@ -22,7 +22,7 @@ unsigned int loadTexture(const char *path, bool gammaCorrection); // settings const unsigned int SCR_WIDTH = 1280; const unsigned int SCR_HEIGHT = 720; -bool gamma = false; +bool gammaEnabled = false; bool gammaKeyPressed = false; // camera @@ -160,14 +160,14 @@ int main() glUniform3fv(glGetUniformLocation(shader.ID, "lightPositions"), 4, &lightPositions[0][0]); glUniform3fv(glGetUniformLocation(shader.ID, "lightColors"), 4, &lightColors[0][0]); shader.setVec3("viewPos", camera.Position); - shader.setInt("gamma", gamma); + shader.setInt("gamma", gammaEnabled); // floor glBindVertexArray(planeVAO); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, gamma ? floorTextureGammaCorrected : floorTexture); + glBindTexture(GL_TEXTURE_2D, gammaEnabled ? floorTextureGammaCorrected : floorTexture); glDrawArrays(GL_TRIANGLES, 0, 6); - std::cout << (gamma ? "Gamma enabled" : "Gamma disabled") << std::endl; + std::cout << (gammaEnabled ? "Gamma enabled" : "Gamma disabled") << std::endl; // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) // ------------------------------------------------------------------------------- @@ -202,7 +202,7 @@ void processInput(GLFWwindow *window) if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS && !gammaKeyPressed) { - gamma = !gamma; + gammaEnabled = !gammaEnabled; gammaKeyPressed = true; } if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_RELEASE) @@ -293,4 +293,4 @@ unsigned int loadTexture(char const * path, bool gammaCorrection) } return textureID; -} \ No newline at end of file +}