diff options
author | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-10-06 03:12:48 -0400 |
---|---|---|
committer | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-10-06 03:12:48 -0400 |
commit | 1a909087ddfdfe3b947c65b07287a08a40f119ce (patch) | |
tree | 64df54d9634731b6fc1a60e8ec6d42afab5b608a /src/render.cpp | |
parent | a62d96ad0521b064e6ef61a6f80888e27966502b (diff) |
World is now saved as image files instead of generations
Diffstat (limited to 'src/render.cpp')
-rw-r--r-- | src/render.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/render.cpp b/src/render.cpp index cc7ecb1..cdd31f8 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -219,24 +219,25 @@ void RenderSystem::update([[maybe_unused]] entityx::EntityManager& entities, }); glUniform1i(f, 0); - // If we were given a world VBO render it - if (worldVBO) { + for (auto& w : worldRenders) { + auto& layer = w.second; + glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, worldTexture); + glBindTexture(GL_TEXTURE_2D, layer.tex); glUniform1i(q, 0); glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, worldNormal); + glBindTexture(GL_TEXTURE_2D, layer.normal); glUniform1i(n, 1); - glBindBuffer(GL_ARRAY_BUFFER, worldVBO); + glBindBuffer(GL_ARRAY_BUFFER, w.first); glVertexAttribPointer(a, 3, GL_FLOAT, GL_FALSE, 6*sizeof(float), 0); glVertexAttribPointer(t, 2, GL_FLOAT, GL_FALSE, 6*sizeof(float), (void*)(3*sizeof(float))); glVertexAttribPointer(r, 1, GL_FLOAT, GL_FALSE, 6*sizeof(float), (void*)(5*sizeof(float))); - glDrawArrays(GL_TRIANGLES, 0, worldVertex); + glDrawArrays(GL_TRIANGLES, 0, layer.vertex); } glDisableVertexAttribArray(a); @@ -408,10 +409,12 @@ void RenderSystem::receive(const NewRenderEvent &nre) void RenderSystem::receive(const WorldMeshUpdateEvent &wmu) { - worldVBO = wmu.worldVBO; - worldVertex = wmu.numVertex; - worldTexture = wmu.worldTexture; - worldNormal = wmu.worldNormal; + worldRenders.insert_or_assign( + wmu.worldVBO, + WorldRenderData(wmu.worldTexture, + wmu.worldNormal, + wmu.numVertex) + ); } void RenderSystem::receive(const entityx::ComponentAddedEvent<Player> &cae) |