diff --git a/src/Application.cpp b/src/Application.cpp index 98d0c45..a7e26ef 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -262,11 +262,11 @@ void Application::run() pl->tick(m_camera, deltaTime); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); pl->draw(m_camera, &chunkShader); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); // END TEST CODE diff --git a/src/Shader.cpp b/src/Shader.cpp index 5bca275..613db19 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -294,38 +294,27 @@ void Shader::setUniform(const std::string& name, int val) void Shader::use() { - if (!m_valid) + // Bind the shader + start(); + + // Bind the buffers needed + glBindVertexArray(vao); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); + + // Enable all attributes + for (auto it(m_attributes.begin()); it != m_attributes.end(); ++it) { - m_valid = true; - - // Bind the shader - start(); - - // Bind the buffers needed - glBindVertexArray(vao); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); - - // Enable all attributes - for (auto it(m_attributes.begin()); it != m_attributes.end(); ++it) - { - GLuint location = getAttribLocation(it->first); - glEnableVertexAttribArray(location); - glVertexAttribPointer( - location, - it->second.size, - it->second.type, - it->second.normalized, - it->second.stride * sizeof(GLfloat), - (void*)(it->second.offset * sizeof(GLfloat)) - ); - } - } else { - start(); - - glBindVertexArray(vao); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); + GLuint location = getAttribLocation(it->first); + glEnableVertexAttribArray(location); + glVertexAttribPointer( + location, + it->second.size, + it->second.type, + it->second.normalized, + it->second.stride * sizeof(GLfloat), + (void*)(it->second.offset * sizeof(GLfloat)) + ); } } diff --git a/src/planet/PlanetFace.cpp b/src/planet/PlanetFace.cpp index fc44d1e..391cff5 100644 --- a/src/planet/PlanetFace.cpp +++ b/src/planet/PlanetFace.cpp @@ -68,7 +68,7 @@ ChunkManager::ChunkManager(PlanetFace* face, GLuint chunkCount) : m_face(face) { for (int z = 0; z < (int)chunkCount; z++) { - m_chunks.push_back(new Chunk(m_face->getPlanet(), m_face, x, y, z)); + m_chunks.push_back(new Chunk(m_face->getPlanet(), m_face, x * CHUNK_SIZE, y * CHUNK_SIZE, z * CHUNK_SIZE)); } } }