From f5f08ce6698cda316a6bc437118d81397966a026 Mon Sep 17 00:00:00 2001 From: Fries Date: Sun, 31 Mar 2024 20:07:46 -0700 Subject: [PATCH] GL shader vertex color variable. --- src/main.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 0e1fdd7..039ef8a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -11,9 +11,11 @@ const char* vertexShaderCode = R"( // Set the GLSL version to 3.3 and use the OpenGL core profile #version 330 core layout (location = 0) in vec3 aPos; +out vec4 vertexColor; void main() { - gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); + gl_Position = vec4(aPos, 1.0); + vertexColor = vec4(0.5, 0.0, 0.0, 1.0); } )"; @@ -21,9 +23,10 @@ const char* fragmentShaderCode = R"( // Set the GLSL version to 3.3 and use the OpenGL core profile #version 330 core out vec4 FragColor; +in vec4 vertexColor; void main() { - FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f); + FragColor = vertexColor; } )";