summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-06-28 13:25:32 +0200
committerLaG1924 <lag1924@gmail.com>2021-06-28 13:25:32 +0200
commitf324c49d896eae159b7499ad6467f03dbcc900ca (patch)
tree6b4565293c2c43edd6484aaf38ea33a66fc91adc /src
parentMoved block face model matrix transformation to CPU (diff)
downloadAltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar.gz
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar.bz2
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar.lz
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar.xz
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.tar.zst
AltCraft-f324c49d896eae159b7499ad6467f03dbcc900ca.zip
Diffstat (limited to 'src')
-rw-r--r--src/RendererSection.cpp28
-rw-r--r--src/RendererSectionData.cpp4
2 files changed, 10 insertions, 22 deletions
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);