toggle wireframe with F
parent
4ada24e0d5
commit
a7b4671517
|
@ -14,6 +14,7 @@
|
|||
|
||||
extr Camera theCamera;
|
||||
constexpr int chunks_volume = static_cast<int>(1.333333333333*M_PI*(RENDER_DISTANCE*RENDER_DISTANCE*RENDER_DISTANCE));
|
||||
extr bool wireframe;
|
||||
|
||||
extr uint32_t MORTON_XYZ_ENCODE[CHUNK_SIZE][CHUNK_SIZE][CHUNK_SIZE];
|
||||
extr uint32_t MORTON_XYZ_DECODE[CHUNK_VOLUME][3];
|
||||
|
|
|
@ -21,6 +21,7 @@ int frames = 0;
|
|||
|
||||
float lastBlockPick=0.0;
|
||||
bool blockpick = false;
|
||||
bool canChangeWireframe = true;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -62,6 +63,7 @@ int main()
|
|||
std::cout << "Using GPU: " << glGetString(GL_VENDOR) << " " << glGetString(GL_RENDERER) << "\n";
|
||||
|
||||
SpaceFilling::initLUT();
|
||||
wireframe = false;
|
||||
renderer::init();
|
||||
std::thread chunkmanager_thread = chunkmanager::init();
|
||||
|
||||
|
@ -140,6 +142,12 @@ void processInput(GLFWwindow *window)
|
|||
lastBlockPick=glfwGetTime();
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_F) == GLFW_PRESS && canChangeWireframe){
|
||||
wireframe = !wireframe;
|
||||
canChangeWireframe = false;
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_F) == GLFW_RELEASE) canChangeWireframe = true;
|
||||
|
||||
// Reset blockpicking if enough time has passed
|
||||
if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_RELEASE && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_RELEASE) blockpick = false;
|
||||
|
||||
|
|
|
@ -61,6 +61,9 @@ namespace renderer{
|
|||
chunkmesher::getMeshDataQueue().push(m);
|
||||
}
|
||||
|
||||
if(wireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
for(auto& c : chunks_torender){
|
||||
float dist = glm::distance(c->getPosition(), cameraChunkPos);
|
||||
if(dist <= static_cast<float>(RENDER_DISTANCE)){
|
||||
|
@ -95,7 +98,6 @@ namespace renderer{
|
|||
{
|
||||
if(c->numTriangles > 0)
|
||||
{
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // wireframe mode
|
||||
theShader->setMat4("model", model);
|
||||
theShader->setMat4("view", theCamera.getView());
|
||||
theShader->setMat4("projection", theCamera.getProjection());
|
||||
|
|
Loading…
Reference in New Issue