31 lines
1.0 KiB
C++
31 lines
1.0 KiB
C++
#include "glm.hpp"
|
|
#include "ext.hpp"
|
|
#include "./Spaceship.h"
|
|
|
|
#pragma once
|
|
class Sun
|
|
{
|
|
public:
|
|
glm::vec3 sunPos = glm::vec3(0, 2, 0);
|
|
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
|
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5;
|
|
GLuint program;
|
|
Core::RenderContext sphereContext;
|
|
|
|
Sun(GLuint program, Core::RenderContext sphereContext) {
|
|
this->program = program;
|
|
this->sphereContext = sphereContext;
|
|
}
|
|
|
|
Sun(){}
|
|
|
|
void draw() {
|
|
glUseProgram(program);
|
|
glm::mat4 viewProjectionMatrix = Core::createPerspectiveMatrix() * Spaceship::getInstance().createCameraMatrix();
|
|
glm::mat4 transformation = viewProjectionMatrix * glm::translate(sunPos) * glm::scale(glm::vec3(0.1));
|
|
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
|
glUniform3f(glGetUniformLocation(program, "color"), sunColor.x / 2, sunColor.y / 2, sunColor.z / 2);
|
|
glUniform1f(glGetUniformLocation(program, "exposition"), 1.f);
|
|
Core::DrawContext(sphereContext);
|
|
}
|
|
}; |