#include "World.hpp"
#include "WorldCollision.hpp"
-#include "../graphics/BlockLighting.hpp"
-#include "../graphics/DirectionalLighting.hpp"
+#include "../graphics/Viewport.hpp"
#include <iostream>
#include <limits>
{ // white block
BlockType type(true, { 1.0f, 1.0f, 1.0f }, &blockShape);
+ type.label = "White Block";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // white slab
BlockType type(true, { 1.0f, 1.0f, 1.0f }, &slabShape);
+ type.label = "White Slab";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // white stair
BlockType type(true, { 1.0f, 1.0f, 1.0f }, &stairShape);
+ type.label = "White Stair";
type.block_light = true;
type.collision = true;
type.collide_block = true;
{ // red block
BlockType type(true, { 1.0f, 0.0f, 0.0f }, &blockShape);
+ type.label = "Red Block";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // red slab
BlockType type(true, { 1.0f, 0.0f, 0.0f }, &slabShape);
+ type.label = "Red Slab";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // red stair
BlockType type(true, { 1.0f, 0.0f, 0.0f }, &stairShape);
+ type.label = "Red Stair";
type.block_light = true;
type.collision = true;
type.collide_block = true;
{ // green block
BlockType type(true, { 0.0f, 1.0f, 0.0f }, &blockShape);
+ type.label = "Green Block";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // green slab
BlockType type(true, { 0.0f, 1.0f, 0.0f }, &slabShape);
+ type.label = "Green Slab";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // green stair
BlockType type(true, { 0.0f, 1.0f, 0.0f }, &stairShape);
+ type.label = "Green Stair";
type.block_light = true;
type.collision = true;
type.collide_block = true;
{ // blue block
BlockType type(true, { 0.0f, 0.0f, 1.0f }, &blockShape);
+ type.label = "Blue Block";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // blue slab
BlockType type(true, { 0.0f, 0.0f, 1.0f }, &slabShape);
+ type.label = "Blue Slab";
type.block_light = true;
type.collision = true;
type.collide_block = true;
}
{ // blue stair
BlockType type(true, { 0.0f, 0.0f, 1.0f }, &stairShape);
+ type.label = "Blue Stair";
type.block_light = true;
type.collision = true;
type.collide_block = true;
{ // glowing yellow block
BlockType type(true, { 1.0f, 1.0f, 0.0f }, &blockShape);
+ type.label = "Light";
type.luminosity = 15;
type.block_light = true;
type.collision = true;
}
-void World::Render(BlockLighting &chunk_prog, DirectionalLighting &entity_prog) {
- chunk_prog.Activate();
+void World::Render(Viewport &viewport) {
+ viewport.WorldPosition(player->Transform(player->ChunkCoords()));
+
+ BlockLighting &chunk_prog = viewport.ChunkProgram();
chunk_prog.SetFogDensity(fog_density);
- chunk_prog.SetView(glm::inverse(player->Transform(player->ChunkCoords())));
for (Chunk &chunk : chunks.Loaded()) {
glm::mat4 m(chunk.Transform(player->ChunkCoords()));
}
}
- entity_prog.Activate();
+ DirectionalLighting &entity_prog = viewport.EntityProgram();
entity_prog.SetLightDirection(light_direction);
entity_prog.SetFogDensity(fog_density);
- entity_prog.SetView(glm::inverse(player->Transform(player->ChunkCoords())));
for (Entity &entity : entities) {
if (entity.HasShape()) {