diff options
-rw-r--r-- | cwd/assets/altcraft/shaders/vert/face.vs | 2 | ||||
-rw-r--r-- | src/RendererSection.cpp | 28 | ||||
-rw-r--r-- | src/RendererSectionData.cpp | 4 |
3 files changed, 11 insertions, 23 deletions
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs index 424e215..e054dd8 100644 --- a/cwd/assets/altcraft/shaders/vert/face.vs +++ b/cwd/assets/altcraft/shaders/vert/face.vs @@ -1,6 +1,6 @@ #version 330 core -layout (location = 3) in vec4 position[6]; +layout (location = 3) in vec4 position[4]; layout (location = 2) in vec2 UvCoordinates; layout (location = 11) in vec4 Texture; layout (location = 12) in vec3 color; diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index 1e0a1d0..e19043d 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -9,12 +9,10 @@ const GLfloat uv_coords[] = { 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + }; const GLuint magicUniqueConstant = 88375; @@ -41,30 +39,22 @@ RendererSection::RendererSection(const RendererSectionData &data) { //Cube vertices GLuint VertAttribPos = 3; glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); - glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(VertAttribPos); glVertexAttribDivisor(VertAttribPos, 1); - glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 1); glVertexAttribDivisor(VertAttribPos + 1, 1); - glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 2); glVertexAttribDivisor(VertAttribPos + 2, 1); - glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); - glVertexAttribPointer(VertAttribPos + 4, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(4 * 4 * sizeof(GLfloat))); - glEnableVertexAttribArray(VertAttribPos + 4); - glVertexAttribDivisor(VertAttribPos + 4, 1); - - glVertexAttribPointer(VertAttribPos + 5, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(5 * 4 * sizeof(GLfloat))); - glEnableVertexAttribArray(VertAttribPos + 5); - glVertexAttribDivisor(VertAttribPos + 5, 1); - //Cube UVs GLuint UvAttribPos = 2; glBindBuffer(GL_ARRAY_BUFFER, VboUvs); @@ -146,7 +136,7 @@ void swap(RendererSection & lhs, RendererSection & rhs) { void RendererSection::Render(RenderState &renderState) { OPTICK_EVENT(); renderState.SetActiveVao(Vao); - glDrawArraysInstanced(GL_TRIANGLES, 0, 6, numOfFaces); + glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, numOfFaces); glCheckError(); } diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index cf05528..eabfee2 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -39,11 +39,9 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co } glm::mat4 transformed = transform * model.transform * face.transform; data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); - data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); data.positions.push_back(transformed * glm::vec4(0, 0, 1, 1)); data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); + data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); data.textures.push_back(face.texture); data.textureLayers.push_back(face.layer); data.textureFrames.push_back(face.frames); |