one planet is always the sun and rendering the sun dynamically now.
This commit is contained in:
parent
e1102e3231
commit
f2bdadd49f
6 changed files with 75 additions and 42 deletions
|
|
@ -60,11 +60,7 @@ namespace endofthejedi {
|
|||
// TODO: add ONE sun planet
|
||||
// TODO: add lights for explosions
|
||||
|
||||
glm::vec3 c = glm::vec3(1.0, 1.0, 0.8);
|
||||
glUniform3f(m_shader.location("lightColor"), c.x, c.y, c.z);
|
||||
|
||||
glm::vec3 p = glm::vec3(0.3f, 0.4f, 0.0f);
|
||||
glUniform3f(m_shader.location("lightPosition"), p.x, p.y, p.z);
|
||||
configureLightningInShader();
|
||||
|
||||
renderPlanets();
|
||||
renderShips();
|
||||
|
|
@ -167,13 +163,15 @@ namespace endofthejedi {
|
|||
{
|
||||
m_planetModel->bind();
|
||||
|
||||
// TODO: put material into attributes and render witd glDrawInstanced
|
||||
// too (same for missiles)
|
||||
for (const game::Planet *planet : m_state->planets) {
|
||||
glm::mat4 model = computeModelMatrix(planet);
|
||||
glUniformMatrix4fv(m_shader.location("model"), 1, GL_FALSE, glm::value_ptr(model));
|
||||
|
||||
glm::vec3 c = planet->getColor();
|
||||
glUniform3f(m_shader.location("materialColor"), c.x, c.y, c.z);
|
||||
glUniform3f(m_shader.location("color"), c.x, c.y, c.z);
|
||||
glUniform1f(m_shader.location("materialKind"), (float) planet->material);
|
||||
|
||||
m_planetModel->render();
|
||||
}
|
||||
|
|
@ -293,4 +291,19 @@ namespace endofthejedi {
|
|||
}
|
||||
glPolygonMode(GL_FRONT, GL_FILL);
|
||||
}
|
||||
|
||||
void RendererPolygon3d::configureLightningInShader()
|
||||
{
|
||||
glm::vec3 c = glm::vec3(1.0, 1.0, 0.8);
|
||||
glUniform3f(m_shader.location("lightColor"), c.x, c.y, c.z);
|
||||
|
||||
glm::vec3 p = glm::vec3(0.3f, 0.4f, 0.0f);
|
||||
for (const game::Planet *planet : m_state->planets) {
|
||||
if (planet->material == game::Planet::Material::Sun) {
|
||||
p = glm::vec3(planet->position, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
glUniform3f(m_shader.location("lightPosition"), p.x, p.y, p.z);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ namespace endofthejedi {
|
|||
|
||||
void renderTraces();
|
||||
|
||||
void configureLightningInShader();
|
||||
|
||||
private:
|
||||
// all models are also here (for easy reloading etc.)
|
||||
std::vector<PolygonModel*> m_models;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue