Removed additional froat from colour data as it will become a 2d pos on texture soon
This commit is contained in:
parent
9cac126141
commit
59355c8540
3 changed files with 14 additions and 13 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
19
src/main.cpp
19
src/main.cpp
|
|
@ -5,7 +5,8 @@
|
|||
#include <GL/gl.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#include <glm/glm.hpp>
|
||||
// Not used yet
|
||||
//#include <glm/glm.hpp>
|
||||
// File reader
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue