summaryrefslogtreecommitdiffstats
path: root/src/RendererWorld.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-09-23 17:55:08 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:32 +0100
commit437cf879808fb68a79e7f8325615737f86f434be (patch)
treedb9dcb8c02606dc8bfc7478e058291b6cec076cf /src/RendererWorld.cpp
parent2017-09-20 (diff)
downloadAltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar.gz
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar.bz2
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar.lz
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar.xz
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.tar.zst
AltCraft-437cf879808fb68a79e7f8325615737f86f434be.zip
Diffstat (limited to 'src/RendererWorld.cpp')
-rw-r--r--src/RendererWorld.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index f13011e..62fb243 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -87,8 +87,8 @@ void RendererWorld::UpdateAllSections(VectorF playerPos)
}
RendererWorld::RendererWorld(std::shared_ptr<GameState> ptr):gs(ptr) {
- MaxRenderingDistance = 1;
- numOfWorkers = std::thread::hardware_concurrency() - 2;
+ MaxRenderingDistance = 2;
+ numOfWorkers = 2;
PrepareRender();
@@ -218,7 +218,6 @@ void RendererWorld::Render(RenderState & renderState) {
GLint projectionLoc = glGetUniformLocation(blockShader->Program, "projection");
GLint viewLoc = glGetUniformLocation(blockShader->Program, "view");
GLint windowSizeLoc = glGetUniformLocation(blockShader->Program, "windowSize");
- GLint modelLoc = glGetUniformLocation(blockShader->Program, "model");
glm::mat4 projection = glm::perspective(45.0f, (float)renderState.WindowWidth / (float)renderState.WindowHeight, 0.1f, 10000000.0f);
glm::mat4 view = gs->GetViewMatrix();
glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));
@@ -226,13 +225,8 @@ void RendererWorld::Render(RenderState & renderState) {
glUniform2f(windowSizeLoc, renderState.WindowWidth, renderState.WindowHeight);
glCheckError();
- glBindVertexArray(RendererSection::GetVao());
-
- size_t faces = 0;
-
sectionsMutex.lock();
- for (auto& section : sections) {
- faces += section.second.numOfFaces;
+ for (auto& section : sections) {
sectionsMutex.unlock();
std::vector<Vector> sectionCorners = {
Vector(0, 0, 0),
@@ -263,13 +257,10 @@ void RendererWorld::Render(RenderState & renderState) {
sectionsMutex.lock();
continue;
}
-
- //glDrawArraysInstanced(GL_TRIANGLES, section.second.offset, 6, section.second.numOfFaces);
+ section.second.Render(renderState);
sectionsMutex.lock();
}
sectionsMutex.unlock();
- glBindVertexArray(RendererSection::GetVao());
- glDrawArraysInstanced(GL_TRIANGLES, 0, 6, faces);
glCheckError();
glLineWidth(3.0);
@@ -280,7 +271,7 @@ void RendererWorld::Render(RenderState & renderState) {
glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
glCheckError();
- modelLoc = glGetUniformLocation(entityShader->Program, "model");
+ GLint modelLoc = glGetUniformLocation(entityShader->Program, "model");
GLint colorLoc = glGetUniformLocation(entityShader->Program, "color");
for (auto& it : entities) {
it.modelLoc = modelLoc;