From 26935473a3504948ecbe72d24510f08b0acf5739 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 6 Nov 2023 00:48:03 +0300 Subject: [PATCH] Water render fix, minor refactor, README.md update --- README.md | 1 + src/coders/png.cpp | 33 --------------------------------- src/graphics/BlocksRenderer.cpp | 2 +- src/voxel_engine.cpp | 3 ++- 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index aaec2135d..e73dce74f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ - **LMB** - remove block - **RMB** - place block - **F** - toggle flight mode +- **N** - noclip mode - **Esc** - exit #### Build with CMake diff --git a/src/coders/png.cpp b/src/coders/png.cpp index 3506ac016..17a52b5ce 100644 --- a/src/coders/png.cpp +++ b/src/coders/png.cpp @@ -97,9 +97,6 @@ int _png_load(const char* file, int* width, int* height){ return 0; } // configure second post-processing framebuffer - unsigned int framebuffer; - glGenFramebuffers(1, &framebuffer); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); @@ -112,37 +109,7 @@ int _png_load(const char* file, int* width, int* height){ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 3); glGenerateMipmap(GL_TEXTURE_2D); - // glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); // we only need a color buffer - glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - unsigned int framebufferms; - glGenFramebuffers(1, &framebufferms); - glBindFramebuffer(GL_FRAMEBUFFER, framebufferms); - // create a multisampled color attachment texture - glGenTextures(1, &texturems); - glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texturems); - glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 16, GL_RGBA, t_width, t_height, GL_TRUE); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, texturems, 0); - glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 3); - // glGenerateMipmap(GL_TEXTURE_2D_MULTISAMPLE); - - - glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferms); - glBlitFramebuffer(0, 0, t_width, t_height, 0, 0, t_width, t_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - - - png_destroy_read_struct( &png_ptr, &info_ptr, &end_info ); free( image_data ); diff --git a/src/graphics/BlocksRenderer.cpp b/src/graphics/BlocksRenderer.cpp index d6c06a7a0..190560023 100644 --- a/src/graphics/BlocksRenderer.cpp +++ b/src/graphics/BlocksRenderer.cpp @@ -252,7 +252,7 @@ bool BlocksRenderer::isOpen(int x, int y, int z, ubyte group) const { if (id == BLOCK_VOID) return false; const Block& block = *Block::blocks[id]; - if (block.drawGroup != group) { + if (block.drawGroup != group && block.lightPassing) { return true; } return !id; diff --git a/src/voxel_engine.cpp b/src/voxel_engine.cpp index 1d4bbbca9..324d36b14 100644 --- a/src/voxel_engine.cpp +++ b/src/voxel_engine.cpp @@ -47,6 +47,7 @@ class initialize_error : public std::runtime_error { struct EngineSettings { int displayWidth; int displayHeight; + /* Anti-aliasing samples */ int displaySamples; const char* title; /* Max milliseconds that engine uses for chunks loading only */ @@ -177,7 +178,7 @@ Engine::~Engine() { int main() { setup_definitions(); try { - Engine engine(EngineSettings{ 1280, 720, 1, "VoxelEngine-Cpp v13", 10 }); + Engine engine(EngineSettings{ 1280, 720, 1, "VoxelEngine-Cpp v13", 15 }); engine.mainloop(); } catch (const initialize_error& err) {