enable faceculling

Doesn't give a massive improve in performance right now, but a nice one to have and was already made from the jme3 porting
intervalmaps-array-y
emamaker 2022-12-01 23:37:57 +01:00
parent 773b7999d4
commit 69c44e3609
2 changed files with 27 additions and 24 deletions

View File

@ -263,23 +263,25 @@ void ChunkMesh::quad(glm::vec3 bottomLeft, glm::vec3 topLeft, glm::vec3 topRight
vertices.push_back(topRight.y);
vertices.push_back(topRight.z);
if (backFace)
{
indices.push_back(vIndex + 2);
indices.push_back(vIndex);
indices.push_back(vIndex + 1);
indices.push_back(vIndex + 1);
indices.push_back(vIndex + 3);
indices.push_back(vIndex + 2);
}
else
{
indices.push_back(vIndex + 2);
indices.push_back(vIndex + 3);
indices.push_back(vIndex + 1);
indices.push_back(vIndex + 1);
indices.push_back(vIndex);
indices.push_back(vIndex + 2);
}
vIndex += 4;
// }
// else
// {
// indices.push_back(i + 2);
// indices.push_back(i + 3);
// indices.push_back(i + 1);
// indices.push_back(i + 1);
// indices.push_back(i);
// indices.push_back(i + 2);
// }
// ugly switch case
GLfloat r, g, b;

View File

@ -50,6 +50,7 @@ int main()
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwSetCursorPosCallback(window, mouse_callback);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); //GL_BACK GL_CCW by default
SpaceFilling::initLUT();
chunkmanager::init();
@ -62,12 +63,12 @@ int main()
lastFrame = currentFrame;
// FPS Counter
// frames++;
// if(currentFrame - lastFPSFrame >= 1.0f){
// std::cout << "FPS: " << frames << std::endl;
// frames = 0;
// lastFPSFrame = currentFrame;
// }
frames++;
if(currentFrame - lastFPSFrame >= 1.0f){
std::cout << "FPS: " << frames << " Frametime: " << deltaTime << std::endl;
frames = 0;
lastFPSFrame = currentFrame;
}
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);