From 59355c8540551b17a099bb84b4ac24356f065a39 Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 18 May 2021 13:32:45 +0100 Subject: [PATCH] Removed additional froat from colour data as it will become a 2d pos on texture soon --- src/fragment.glsl | 4 ++-- src/main.cpp | 19 ++++++++++--------- src/vertex.glsl | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/fragment.glsl b/src/fragment.glsl index 21a3658..8643b0b 100644 --- a/src/fragment.glsl +++ b/src/fragment.glsl @@ -1,9 +1,9 @@ #version 330 core out vec4 FragColor; -in vec3 ourColor; +in vec2 ourColor; void main() { - FragColor = vec4(ourColor, 1.0); + FragColor = vec4(ourColor,0.5, 1.0); } diff --git a/src/main.cpp b/src/main.cpp index 7769b39..8629d2c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,8 @@ #include #include #include -#include +// Not used yet +//#include // File reader #include #include @@ -67,10 +68,10 @@ int main(int argc, char **argv) { ShaderLoader shader("src/vertex.glsl", "src/fragment.glsl"); float vertices[] = { - // positions // colors - 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom right - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // bottom left - 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f // top + // positions // texture Co-ords + 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, // bottom right + -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, // bottom left + 0.0f, 0.5f, 0.0f, 0.5f, 1.0f // top }; unsigned int VBO, VAO; @@ -84,11 +85,11 @@ int main(int argc, char **argv) { glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); // position attribute - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void *)0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)0); glEnableVertexAttribArray(0); - // color attribute - glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), - (void *)(3 * sizeof(float))); + // texture attribute + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), + (void *)(2 * sizeof(float))); glEnableVertexAttribArray(1); // You can unbind the VAO afterwards so other VAO calls won't accidentally diff --git a/src/vertex.glsl b/src/vertex.glsl index e30da3d..f69d4ce 100644 --- a/src/vertex.glsl +++ b/src/vertex.glsl @@ -1,8 +1,8 @@ #version 330 core layout (location = 0) in vec3 aPos; -layout (location = 1) in vec3 aColor; +layout (location = 1) in vec2 aColor; -out vec3 ourColor; +out vec2 ourColor; void main() {