diff options
author | LaG1924 <lag1924@gmail.com> | 2021-06-28 18:31:26 +0200 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-06-28 18:31:26 +0200 |
commit | 08337925fe048d2e8b746bbc82493f4c2b8603d6 (patch) | |
tree | dbedfb5aae51c59423fbc590b2c2f322f9362a79 /src | |
parent | Implemented vertex data iterleaving (diff) | |
download | AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar.gz AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar.bz2 AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar.lz AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar.xz AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.tar.zst AltCraft-08337925fe048d2e8b746bbc82493f4c2b8603d6.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/RendererSection.cpp | 13 | ||||
-rw-r--r-- | src/RendererSectionData.cpp | 2 | ||||
-rw-r--r-- | src/RendererSectionData.hpp | 5 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index 397a660..cc58676 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -21,19 +21,19 @@ RendererSection::RendererSection(const RendererSectionData &data) { { //Cube vertices GLuint VertAttribPos = 0; - glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[0])); + glVertexAttribPointer(VertAttribPos, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[0])); glEnableVertexAttribArray(VertAttribPos); glVertexAttribDivisor(VertAttribPos, 1); - glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[1])); + glVertexAttribPointer(VertAttribPos + 1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[1])); glEnableVertexAttribArray(VertAttribPos + 1); glVertexAttribDivisor(VertAttribPos + 1, 1); - glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[2])); + glVertexAttribPointer(VertAttribPos + 2, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[2])); glEnableVertexAttribArray(VertAttribPos + 2); glVertexAttribDivisor(VertAttribPos + 2, 1); - glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[3])); + glVertexAttribPointer(VertAttribPos + 3, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[3])); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); glCheckError(); @@ -64,7 +64,7 @@ RendererSection::RendererSection(const RendererSectionData &data) { //Animation GLuint animationAttribPos = 9; - glVertexAttribPointer(animationAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, animations)); + glVertexAttribPointer(animationAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, animations)); glEnableVertexAttribArray(animationAttribPos); glVertexAttribDivisor(animationAttribPos, 1); @@ -74,9 +74,6 @@ RendererSection::RendererSection(const RendererSectionData &data) { glEnableVertexAttribArray(colorAttribPos); glVertexAttribDivisor(colorAttribPos, 1); - size_t m = sizeof(VertexData); - size_t d = offsetof(VertexData, lights); - //Light GLuint lightAttribPos = 11; glVertexAttribPointer(lightAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, lights)); diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index e74590a..2588fd6 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -62,7 +62,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames); vertexData.uvLayers = face.layer; - vertexData.animations = glm::vec2(face.texture.w / face.frames, face.frames); + vertexData.animations = face.frames; vertexData.colors = face.color; vertexData.lights = lightness; } diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp index e2fd190..edd2992 100644 --- a/src/RendererSectionData.hpp +++ b/src/RendererSectionData.hpp @@ -31,12 +31,13 @@ struct SectionsData { }; struct VertexData { - glm::vec4 positions[4]; + glm::vec3 positions[4]; glm::vec2 uvs[4]; float uvLayers; - glm::vec2 animations; + float animations; glm::vec3 colors; glm::vec2 lights; + uint8_t padding[20]; }; struct RendererSectionData { |