From 3b605521fb4c0aabf50ba23b0de66ab2af3f39cd Mon Sep 17 00:00:00 2001 From: Joey de Vries Date: Tue, 16 Jan 2018 08:50:57 +0100 Subject: [PATCH] Fix geometry shader normal homogenous coordinate, and use std::string instead of aString for model loading. --- includes/learnopengl/mesh.h | 2 +- includes/learnopengl/model.h | 4 ++-- .../9.3.geometry_shader_normals/9.3.normal_visualization.vs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/learnopengl/mesh.h b/includes/learnopengl/mesh.h index 4d2aea7..9c88605 100644 --- a/includes/learnopengl/mesh.h +++ b/includes/learnopengl/mesh.h @@ -33,7 +33,7 @@ struct Vertex { struct Texture { unsigned int id; string type; - aiString path; + string path; }; class Mesh { diff --git a/includes/learnopengl/model.h b/includes/learnopengl/model.h index cc12c84..fab1151 100644 --- a/includes/learnopengl/model.h +++ b/includes/learnopengl/model.h @@ -179,7 +179,7 @@ private: bool skip = false; for(unsigned int j = 0; j < textures_loaded.size(); j++) { - if(std::strcmp(textures_loaded[j].path.C_Str(), str.C_Str()) == 0) + if(std::strcmp(textures_loaded[j].path.data(), str.C_Str()) == 0) { textures.push_back(textures_loaded[j]); skip = true; // a texture with the same filepath has already been loaded, continue to next one. (optimization) @@ -191,7 +191,7 @@ private: Texture texture; texture.id = TextureFromFile(str.C_Str(), this->directory); texture.type = typeName; - texture.path = str; + texture.path = str.C_Str(); textures.push_back(texture); textures_loaded.push_back(texture); // store it as texture loaded for entire model, to ensure we won't unnecesery load duplicate textures. } diff --git a/src/4.advanced_opengl/9.3.geometry_shader_normals/9.3.normal_visualization.vs b/src/4.advanced_opengl/9.3.geometry_shader_normals/9.3.normal_visualization.vs index 435399b..5cf6e44 100644 --- a/src/4.advanced_opengl/9.3.geometry_shader_normals/9.3.normal_visualization.vs +++ b/src/4.advanced_opengl/9.3.geometry_shader_normals/9.3.normal_visualization.vs @@ -13,6 +13,6 @@ uniform mat4 model; void main() { mat3 normalMatrix = mat3(transpose(inverse(view * model))); - vs_out.normal = vec3(projection * vec4(normalMatrix * aNormal, 1.0)); + vs_out.normal = vec3(projection * vec4(normalMatrix * aNormal, 0.0)); gl_Position = projection * view * model * vec4(aPos, 1.0); } \ No newline at end of file