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 portingintervalmaps-array-y
parent
773b7999d4
commit
69c44e3609
|
@ -99,7 +99,7 @@ void ChunkMesh::mesh()
|
||||||
{
|
{
|
||||||
for (x[u] = 0; x[u] < CHUNK_SIZE; x[u]++)
|
for (x[u] = 0; x[u] < CHUNK_SIZE; x[u]++)
|
||||||
{
|
{
|
||||||
Block b1 = (x[dim] >= 0) ? blocks[HILBERT_XYZ_ENCODE[x[0]][x[1]][x[2]]]: Block::NULLBLK;
|
Block b1 = (x[dim] >= 0) ? blocks[HILBERT_XYZ_ENCODE[x[0]][x[1]][x[2]]] : Block::NULLBLK;
|
||||||
Block b2 = (x[dim] < CHUNK_SIZE - 1)
|
Block b2 = (x[dim] < CHUNK_SIZE - 1)
|
||||||
? blocks[HILBERT_XYZ_ENCODE[x[0] + q[0]][x[1] + q[1]][x[2] + q[2]]]
|
? blocks[HILBERT_XYZ_ENCODE[x[0] + q[0]][x[1] + q[1]][x[2] + q[2]]]
|
||||||
: Block::NULLBLK;
|
: Block::NULLBLK;
|
||||||
|
@ -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.y);
|
||||||
vertices.push_back(topRight.z);
|
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 + 2);
|
||||||
indices.push_back(vIndex + 3);
|
indices.push_back(vIndex + 3);
|
||||||
indices.push_back(vIndex + 1);
|
indices.push_back(vIndex + 1);
|
||||||
indices.push_back(vIndex + 1);
|
indices.push_back(vIndex + 1);
|
||||||
indices.push_back(vIndex);
|
indices.push_back(vIndex);
|
||||||
indices.push_back(vIndex + 2);
|
indices.push_back(vIndex + 2);
|
||||||
|
}
|
||||||
vIndex += 4;
|
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
|
// ugly switch case
|
||||||
GLfloat r, g, b;
|
GLfloat r, g, b;
|
||||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -50,6 +50,7 @@ int main()
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
glfwSetCursorPosCallback(window, mouse_callback);
|
glfwSetCursorPosCallback(window, mouse_callback);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_CULL_FACE); //GL_BACK GL_CCW by default
|
||||||
|
|
||||||
SpaceFilling::initLUT();
|
SpaceFilling::initLUT();
|
||||||
chunkmanager::init();
|
chunkmanager::init();
|
||||||
|
@ -62,12 +63,12 @@ int main()
|
||||||
lastFrame = currentFrame;
|
lastFrame = currentFrame;
|
||||||
|
|
||||||
// FPS Counter
|
// FPS Counter
|
||||||
// frames++;
|
frames++;
|
||||||
// if(currentFrame - lastFPSFrame >= 1.0f){
|
if(currentFrame - lastFPSFrame >= 1.0f){
|
||||||
// std::cout << "FPS: " << frames << std::endl;
|
std::cout << "FPS: " << frames << " Frametime: " << deltaTime << std::endl;
|
||||||
// frames = 0;
|
frames = 0;
|
||||||
// lastFPSFrame = currentFrame;
|
lastFPSFrame = currentFrame;
|
||||||
// }
|
}
|
||||||
|
|
||||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
Loading…
Reference in New Issue