Global light
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <types/vertex.h>
|
||||
#include <types/texture.h>
|
||||
#include <types/entity/entity.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
|
||||
// TODO: Move data to Entity / or rename to DataModelEntry
|
||||
struct ByteArray
|
||||
@@ -38,9 +39,13 @@ public:
|
||||
};
|
||||
|
||||
class World : public DataModel {
|
||||
private:
|
||||
LinearAlgebra::Vector4 globalLight= {0,0,0,0};
|
||||
public:
|
||||
std::string name;
|
||||
World() : DataModel() {}
|
||||
void setAmbientLight(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
||||
LinearAlgebra::Vector4 getAmbientLight();
|
||||
std::string name;
|
||||
std::vector<VertexArray> geometryList;
|
||||
std::vector<Texture> textureList;
|
||||
};
|
||||
|
@@ -47,7 +47,7 @@ void Engine::initGL()
|
||||
//glEnable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
//glEnable(GL_LIGHT0);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
//glDepthRange(-0.5f,0.5f);
|
||||
|
@@ -27,6 +27,7 @@ void Render::pre_render() {
|
||||
skybox->draw = true;
|
||||
skybox->angle = {0,0,0};
|
||||
skybox->SetParent(engine->world);
|
||||
engine->world->setAmbientLight(0.6, 0.6, 0.6, 1);
|
||||
}
|
||||
//std::cout << engine->frameCount << std::endl;
|
||||
engine->window->pollEvents();
|
||||
|
@@ -114,4 +114,14 @@ Entity *Entity::GetFamilyTreeRoot() const {
|
||||
if (parent->GetParent() == nullptr)
|
||||
return parent;
|
||||
return parent->GetFamilyTreeRoot();
|
||||
}
|
||||
}
|
||||
|
||||
void World::setAmbientLight(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
|
||||
GLfloat ambient[4] = {red, green, blue, alpha};
|
||||
globalLight.x = red; globalLight.y = green; globalLight.z = blue; globalLight.w = alpha;
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
|
||||
}
|
||||
|
||||
LinearAlgebra::Vector4 World::getAmbientLight() {
|
||||
return globalLight;
|
||||
}
|
||||
|
Reference in New Issue
Block a user