Removed additional froat from colour data as it will become a 2d pos on texture soon

This commit is contained in:
Warwick 2021-05-18 13:32:45 +01:00
parent 9cac126141
commit 59355c8540
3 changed files with 14 additions and 13 deletions

View file

@ -1,9 +1,9 @@
#version 330 core #version 330 core
out vec4 FragColor; out vec4 FragColor;
in vec3 ourColor; in vec2 ourColor;
void main() void main()
{ {
FragColor = vec4(ourColor, 1.0); FragColor = vec4(ourColor,0.5, 1.0);
} }

View file

@ -5,7 +5,8 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h> #include <SDL2/SDL_opengl.h>
#include <glm/glm.hpp> // Not used yet
//#include <glm/glm.hpp>
// File reader // File reader
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -67,10 +68,10 @@ int main(int argc, char **argv) {
ShaderLoader shader("src/vertex.glsl", "src/fragment.glsl"); ShaderLoader shader("src/vertex.glsl", "src/fragment.glsl");
float vertices[] = { float vertices[] = {
// positions // colors // positions // texture Co-ords
0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom right 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, // bottom right
-0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // bottom left -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, // bottom left
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f // top 0.0f, 0.5f, 0.0f, 0.5f, 1.0f // top
}; };
unsigned int VBO, VAO; unsigned int VBO, VAO;
@ -84,11 +85,11 @@ int main(int argc, char **argv) {
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// position attribute // 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); glEnableVertexAttribArray(0);
// color attribute // texture attribute
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
(void *)(3 * sizeof(float))); (void *)(2 * sizeof(float)));
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
// You can unbind the VAO afterwards so other VAO calls won't accidentally // You can unbind the VAO afterwards so other VAO calls won't accidentally

View file

@ -1,8 +1,8 @@
#version 330 core #version 330 core
layout (location = 0) in vec3 aPos; 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() void main()
{ {