toggle wireframe with F

pull/5/head
EmaMaker 2023-07-18 20:03:59 +02:00
parent 4ada24e0d5
commit a7b4671517
3 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,7 @@
extr Camera theCamera; extr Camera theCamera;
constexpr int chunks_volume = static_cast<int>(1.333333333333*M_PI*(RENDER_DISTANCE*RENDER_DISTANCE*RENDER_DISTANCE)); 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_ENCODE[CHUNK_SIZE][CHUNK_SIZE][CHUNK_SIZE];
extr uint32_t MORTON_XYZ_DECODE[CHUNK_VOLUME][3]; extr uint32_t MORTON_XYZ_DECODE[CHUNK_VOLUME][3];

View File

@ -21,6 +21,7 @@ int frames = 0;
float lastBlockPick=0.0; float lastBlockPick=0.0;
bool blockpick = false; bool blockpick = false;
bool canChangeWireframe = true;
int main() int main()
{ {
@ -62,6 +63,7 @@ int main()
std::cout << "Using GPU: " << glGetString(GL_VENDOR) << " " << glGetString(GL_RENDERER) << "\n"; std::cout << "Using GPU: " << glGetString(GL_VENDOR) << " " << glGetString(GL_RENDERER) << "\n";
SpaceFilling::initLUT(); SpaceFilling::initLUT();
wireframe = false;
renderer::init(); renderer::init();
std::thread chunkmanager_thread = chunkmanager::init(); std::thread chunkmanager_thread = chunkmanager::init();
@ -140,6 +142,12 @@ void processInput(GLFWwindow *window)
lastBlockPick=glfwGetTime(); 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 // 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; if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_RELEASE && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_RELEASE) blockpick = false;

View File

@ -61,6 +61,9 @@ namespace renderer{
chunkmesher::getMeshDataQueue().push(m); 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){ for(auto& c : chunks_torender){
float dist = glm::distance(c->getPosition(), cameraChunkPos); float dist = glm::distance(c->getPosition(), cameraChunkPos);
if(dist <= static_cast<float>(RENDER_DISTANCE)){ if(dist <= static_cast<float>(RENDER_DISTANCE)){
@ -95,7 +98,6 @@ namespace renderer{
{ {
if(c->numTriangles > 0) if(c->numTriangles > 0)
{ {
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // wireframe mode
theShader->setMat4("model", model); theShader->setMat4("model", model);
theShader->setMat4("view", theCamera.getView()); theShader->setMat4("view", theCamera.getView());
theShader->setMat4("projection", theCamera.getProjection()); theShader->setMat4("projection", theCamera.getProjection());