i think i broke it further

This commit is contained in:
Benjamin Kyd
2019-02-24 18:51:11 +00:00
parent d4876bbba5
commit 14b0b9a155
7 changed files with 114 additions and 20 deletions

View File

@@ -6,17 +6,19 @@ Mesh::Mesh() {
Mesh::Mesh(std::string objPath) {
Logger logger;
objl::Loader loader;
bool canLoad = loader.LoadFile(objPath);
//objl::Loader loader;
//bool canLoad = loader.LoadFile(objPath);
if (!canLoad) {
logger << LOGGER_ERROR << "Cannot load obj '" << objPath << "'" << LOGGER_ENDL;
return;
}
//if (!canLoad) {
// logger << LOGGER_ERROR << "Cannot load obj '" << objPath << "'" << LOGGER_ENDL;
// return;
//}
LoadOBJ(logger, objPath, vertices, normals, indices);
logger << LOGGER_INFO << "Loaded: " << objPath << LOGGER_ENDL;
loadFromObj(loader.LoadedMeshes[0]);
//loadFromObj(loader.LoadedMeshes[0]);
}
Mesh::Mesh(objl::Mesh objMesh) {
@@ -28,10 +30,10 @@ void Mesh::loadFromObj(objl::Mesh objMesh) {
UintToGLuint(objMesh.Indices, indices);
name = objMesh.MeshName;
Logger logger;
for (int i = 0; i < 100; i++) {
logger << LOGGER_DEBUG << normals[i].x << " " << normals[i].y << " " << normals[i].z << LOGGER_ENDL;
}
//Logger logger;
//for (int i = 0; i < 100; i++) {
// logger << LOGGER_DEBUG << normals[i].x << " " << normals[i].y << " " << normals[i].z << LOGGER_ENDL;
//}
}
void Mesh::setup() {
@@ -48,13 +50,13 @@ void Mesh::setup() {
std::vector<glm::vec3> toGpu;
toGpu.insert(toGpu.end(), vertices.begin(), vertices.end());
toGpu.insert(toGpu.end(), normals.begin(), normals.end());
toGpu.insert(toGpu.end(), texCoords.begin(), texCoords.end());
//toGpu.insert(toGpu.end(), texCoords.begin(), texCoords.end());
glBufferData(GL_ARRAY_BUFFER, toGpu.size() * sizeof(glm::vec3),
&toGpu[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLuint),
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLushort),
&indices[0], GL_STATIC_DRAW);
// Positions
@@ -68,9 +70,9 @@ void Mesh::setup() {
(const void*)(vertices.size() * sizeof(glm::vec3)));
// TexCoords
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0,
(const void*)((vertices.size() + texCoords.size()) * sizeof(glm::vec3)));
//glEnableVertexAttribArray(2);
//glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0,
// (const void*)((vertices.size() + texCoords.size()) * sizeof(glm::vec3)));
logger << LOGGER_INFO << "Mesh " << name << " setup" << LOGGER_ENDL;