X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FWorld.cpp;h=97dcc0848a40a7936179ee7e4171aac8c29f1fd1;hb=a1f911f8257f614f874c201fede5d5206f5b7e80;hp=d51520ef5b2828c1d22902e1e00902bccb504884;hpb=955fbb45dedb570520fc45d2ce69f420bed2ad08;p=blank.git diff --git a/src/world/World.cpp b/src/world/World.cpp index d51520e..97dcc08 100644 --- a/src/world/World.cpp +++ b/src/world/World.cpp @@ -1,8 +1,7 @@ #include "World.hpp" #include "WorldCollision.hpp" -#include "../graphics/BlockLighting.hpp" -#include "../graphics/DirectionalLighting.hpp" +#include "../graphics/Viewport.hpp" #include #include @@ -29,6 +28,7 @@ World::World(const Config &config) { // 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; @@ -37,6 +37,7 @@ World::World(const Config &config) } { // 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; @@ -45,6 +46,7 @@ World::World(const Config &config) } { // 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; @@ -54,6 +56,7 @@ World::World(const Config &config) { // 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; @@ -62,6 +65,7 @@ World::World(const Config &config) } { // 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; @@ -70,6 +74,7 @@ World::World(const Config &config) } { // 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; @@ -79,6 +84,7 @@ World::World(const Config &config) { // 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; @@ -87,6 +93,7 @@ World::World(const Config &config) } { // 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; @@ -95,6 +102,7 @@ World::World(const Config &config) } { // 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; @@ -104,6 +112,7 @@ World::World(const Config &config) { // 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; @@ -112,6 +121,7 @@ World::World(const Config &config) } { // 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; @@ -120,6 +130,7 @@ World::World(const Config &config) } { // 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; @@ -129,6 +140,7 @@ World::World(const Config &config) { // 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; @@ -282,10 +294,11 @@ void World::Resolve(Entity &e, std::vector &col) { } -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())); @@ -296,10 +309,9 @@ void World::Render(BlockLighting &chunk_prog, DirectionalLighting &entity_prog) } } - 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()) {