It can render the chunks now, but it definitely can ue more optimizations
This commit is contained in:
parent
47fe269c76
commit
84721968ae
|
@ -262,11 +262,11 @@ void Application::run()
|
||||||
|
|
||||||
pl->tick(m_camera, deltaTime);
|
pl->tick(m_camera, deltaTime);
|
||||||
|
|
||||||
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||||
|
|
||||||
pl->draw(m_camera, &chunkShader);
|
pl->draw(m_camera, &chunkShader);
|
||||||
|
|
||||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
//glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||||
|
|
||||||
|
|
||||||
// END TEST CODE
|
// END TEST CODE
|
||||||
|
|
|
@ -294,38 +294,27 @@ void Shader::setUniform(const std::string& name, int val)
|
||||||
|
|
||||||
void Shader::use()
|
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;
|
GLuint location = getAttribLocation(it->first);
|
||||||
|
glEnableVertexAttribArray(location);
|
||||||
// Bind the shader
|
glVertexAttribPointer(
|
||||||
start();
|
location,
|
||||||
|
it->second.size,
|
||||||
// Bind the buffers needed
|
it->second.type,
|
||||||
glBindVertexArray(vao);
|
it->second.normalized,
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
it->second.stride * sizeof(GLfloat),
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
|
(void*)(it->second.offset * sizeof(GLfloat))
|
||||||
|
);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ ChunkManager::ChunkManager(PlanetFace* face, GLuint chunkCount) : m_face(face)
|
||||||
{
|
{
|
||||||
for (int z = 0; z < (int)chunkCount; z++)
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue