From d01e8e9c62e28fba49083abc2d58c393b9d33462 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:45:51 -0500 Subject: [PATCH] Nerfage pour version Debug/MSVC --- SQCSim2021/SQCSim2021.vcxproj | 8 ++-- SQCSim2021/define.h | 14 ++++++- SQCSim2021/engine.cpp | 34 +++++++++------ SQCSim2021/media/chunks/16325_16384.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16364_16379.chunk | 1 + SQCSim2021/media/chunks/16369_16385.chunk | 1 + SQCSim2021/media/chunks/16371_16383.chunk | 1 + SQCSim2021/media/chunks/16378_16383.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16381_16247.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16397_16373.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16398_16392.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16400_16392.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/chunks/16505_16212.chunk | Bin 0 -> 32768 bytes SQCSim2021/media/textures/metal.png | Bin 477191 -> 378801 bytes SQCSim2021/media/textures/metal1.png | Bin 371024 -> 192324 bytes SQCSim2021/media/textures/metal2.png | Bin 520531 -> 540952 bytes SQCSim2021/media/textures/metal3.png | Bin 534756 -> 427104 bytes SQCSim2021/media/textures/metal4.png | Bin 547900 -> 433295 bytes SQCSim2021/skybox.cpp | 2 + SQCSim2021/world.cpp | 49 ++++++++++++++-------- 20 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 SQCSim2021/media/chunks/16325_16384.chunk create mode 100644 SQCSim2021/media/chunks/16364_16379.chunk create mode 100644 SQCSim2021/media/chunks/16369_16385.chunk create mode 100644 SQCSim2021/media/chunks/16371_16383.chunk create mode 100644 SQCSim2021/media/chunks/16378_16383.chunk create mode 100644 SQCSim2021/media/chunks/16381_16247.chunk create mode 100644 SQCSim2021/media/chunks/16397_16373.chunk create mode 100644 SQCSim2021/media/chunks/16398_16392.chunk create mode 100644 SQCSim2021/media/chunks/16400_16392.chunk create mode 100644 SQCSim2021/media/chunks/16505_16212.chunk diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj index b5b30e5..70fb842 100644 --- a/SQCSim2021/SQCSim2021.vcxproj +++ b/SQCSim2021/SQCSim2021.vcxproj @@ -70,27 +70,27 @@ Application true Unicode - ClangCL + v142 Application true Unicode - ClangCL + v142 Application false true Unicode - ClangCL + v142 Application false true Unicode - ClangCL + v142 diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h index 1bd66b8..a8c36c1 100644 --- a/SQCSim2021/define.h +++ b/SQCSim2021/define.h @@ -15,7 +15,18 @@ #define CHUNK_SIZE_X 16 #define CHUNK_SIZE_Y 128 #define CHUNK_SIZE_Z 16 +#define MAX_SELECTION_DISTANCE 5 +#ifdef _DEBUG +#define WORLD_SIZE_X 32 +#define WORLD_SIZE_Y 32 + +#define FRAMES_RENDER_CHUNKS 4 +#define FRAMES_UPDATE_CHUNKS 4 +#define FRAMES_DELETE_CHUNKS 4 + +#define VIEW_DISTANCE 128 +#else #define WORLD_SIZE_X 128 #define WORLD_SIZE_Y 128 @@ -24,7 +35,8 @@ #define FRAMES_DELETE_CHUNKS 2 #define VIEW_DISTANCE 512 -#define MAX_SELECTION_DISTANCE 5 +#endif + typedef uint8_t BlockType; enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST }; diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 431897a..5d71628 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -15,24 +15,26 @@ void Engine::Init() { abort(); } - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glDisable(GL_FRAMEBUFFER_SRGB); + glClearColor(0.f, 0.f, 0.f, 1.f); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(45.0f, (float)Width() / (float)Height(), 0.0001f, 1000.0f); + gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE); glEnable(GL_DEPTH_TEST); + glEnable(GL_STENCIL_TEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glShadeModel(GL_SMOOTH); - glEnable(GL_LINE_SMOOTH); + + glEnable(GL_POINT_SMOOTH); glEnable(GL_CULL_FACE); - glDisable(GL_FRAMEBUFFER_SRGB); - glEnable(GL_BLEND); - glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); // , GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_SUBTRACT);// , GL_FUNC_ADD); // Objet de skybox avec sa propre texture et son propre shader! - m_skybox.Init(0.00013f); + m_skybox.Init(0.2f); // Objet de musique! //m_audio.ToggleMusicState(); @@ -54,7 +56,7 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); - TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal1.png"); + TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); if (!m_textureAtlas.Generate(512, false)) { std::cout << " Unable to generate texture atlas ..." << std::endl; @@ -89,6 +91,7 @@ void Engine::DrawHud(float elapsedTime) { // Setter le blend function , tout ce qui sera noir sera transparent glColor4f(1.f, 1.f, 1.f, 1.f); glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendEquation(GL_FUNC_ADD); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -135,7 +138,8 @@ void Engine::DrawHud(float elapsedTime) { glTexCoord2f(0, 1); glVertex2i(0, crossSize); glEnd(); - glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); // , GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_SUBTRACT);// , GL_FUNC_ADD); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -174,7 +178,7 @@ void Engine::Render(float elapsedTime) { Transformation all; Transformation skybox; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Transformations initiales glMatrixMode(GL_MODELVIEW); @@ -188,19 +192,23 @@ void Engine::Render(float elapsedTime) { m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation // (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!). - if (m_isSkybox) m_skybox.Render(skybox); - if (m_mouseL) m_world.ChangeBlockAtCursor(BTYPE_DIRT, m_player, m_block); else if (m_mouseR) m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player, m_block); - + glStencilFunc(GL_EQUAL, 1, 0x00); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); m_world.Update(m_renderCount, m_badHitCount, m_player, all, m_shader01, m_textureAtlas, m_perlin, m_blockinfo); + glStencilFunc(GL_GREATER, 1, 0xFF); + if (m_isSkybox) m_skybox.Render(skybox); + if (m_wireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDisable(GL_STENCIL_TEST); DrawHud(elapsedTime); + glEnable(GL_STENCIL_TEST); if (m_wireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); diff --git a/SQCSim2021/media/chunks/16325_16384.chunk b/SQCSim2021/media/chunks/16325_16384.chunk new file mode 100644 index 0000000000000000000000000000000000000000..0137b36f97070d77e1d76800574ffc774ae8034f GIT binary patch literal 32768 zcmeIv0Zzj(3KGzSXU1L0t5&UAV7cs0RjXF5FkL{ z-v})65Kz`0ZCrg>mJh@NwR7 zT3Z^iA4>V`Q~Pu4@2!u~w)@sXyGSW~kV`{cJRgXh3q7aWp0}p2=W*cZZ>#p_*ZC|F>xA|&A%$qA?{#>ypK!Cu%7r4cf73RE@{kQg{ z?ue(H3Vnah>HM0t;(bSs1LxeU z$IobAZ@2ar&-r|<49U^^z2A1(KGXJ=zRrb
0t;(bSs1LxeU z$IobAZ@2ar&-r|<49U^^z2A1(KGXJ=zRrb