diff --git a/LearnOpenGL/OpenGLWrapper.cpp b/LearnOpenGL/OpenGLWrapper.cpp index f44f78bd9938d02ba9e70f87fc64bef2f78d2b27..6744fa65b75c28ea18ac52aba435f0685de0ebe9 100644 --- a/LearnOpenGL/OpenGLWrapper.cpp +++ b/LearnOpenGL/OpenGLWrapper.cpp @@ -154,7 +154,7 @@ void RenderObject::render(Camera &camera) set_uniform_value(prog, "material.shininess", glm::fvec1{ 64.0f }); - glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)_SCR_WIDTH / (float)_SCR_HEIGHT, 0.1f, 100.0f); + glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)_SCR_WIDTH / (float)_SCR_HEIGHT, 0.1f, 500.0f); glm::mat4 view = camera.GetViewMatrix(); set_uniform_value(prog, "projection", projection); set_uniform_value(prog, "view", view); diff --git a/LearnOpenGL/ResourceLoader.cpp b/LearnOpenGL/ResourceLoader.cpp index 9c5fea4bd3e6394ef14b21b4d4a926416212a9f5..8a3dc450cb9257891cc769f5337b849bf54dfa98 100644 --- a/LearnOpenGL/ResourceLoader.cpp +++ b/LearnOpenGL/ResourceLoader.cpp @@ -60,6 +60,11 @@ bool openObj(const std::string fileName, std::vector<glm::vec3> &vertices, std:: line.erase(0, charPos + 1); } + if (line[0] == ' ') + { + line.erase(0, 1); + } + if (strcmp(op, "v") == false) { glm::vec3 pos = { 0,0,0 }; @@ -101,19 +106,6 @@ bool openObj(const std::string fileName, std::vector<glm::vec3> &vertices, std:: sscanf_s(line.substr(0, charPos).c_str(), "%d%*[-//]%d", &vIndex, &vnIndex); line.erase(0, charPos + 1); } - - if (vIndex >= 1) - { - faceVertexIndicies.push_back(vIndex - 1); - } - if (uvIndex >= 1) - { - faceVertexTexCoordIndicies.push_back(uvIndex - 1); - } - if (vnIndex >= 1) - { - faceVertexNormalIndicies.push_back(vnIndex - 1); - } } if (line.size() > 0) @@ -214,31 +206,30 @@ bool openObj(const std::string fileName, std::vector<glm::vec3> &vertices, std:: log_warn(infoLog, fileName + " : " + "faceVertexNormalIndices.size() : " + std::to_string(faceVertexNormalIndicies.size())); } } - } - ifs.close(); - - return true; -} + ifs.close(); -Image *load_Image(std::string fileName, int *width, int *height, int *nrChannels) -{ - fileName = "../Images/" + fileName; - stbi_set_flip_vertically_on_load(true); + return true; + } - unsigned char *data = stbi_load(fileName.c_str(), width, height, nrChannels, 0); - if (data == NULL) + Image *load_Image(std::string fileName, int *width, int *height, int *nrChannels) { - std::cout << "Failed to load texture : " + fileName << std::endl; - } + fileName = "../Images/" + fileName; + stbi_set_flip_vertically_on_load(true); - Image *img = new Image(*width, *height, *nrChannels, data); + unsigned char *data = stbi_load(fileName.c_str(), width, height, nrChannels, 0); + if (data == NULL) + { + std::cout << "Failed to load texture : " + fileName << std::endl; + } - return img; -} + Image *img = new Image(*width, *height, *nrChannels, data); -void free_image(Image *img) -{ - stbi_image_free(img->getData()); - free(img); -} \ No newline at end of file + return img; + } + + void free_image(Image *img) + { + stbi_image_free(img->getData()); + free(img); + } \ No newline at end of file