Skip to main content
added 573 characters in body
Source Link
pmw1234
  • 3.5k
  • 1
  • 8
  • 17

Your inputs and outputs still don't line up.

#version 440 core  

// Comment out the line below
// in vec4 vs_pos;    <----- No corresponding output in the vertex shader
in vec3 vs_color; 

out vec4 fs_color;


void main()
{
    fs_color=vec4(vs_color, 1.f);
}

The gl_Position output is consumed and does not need a specific input in the fragment shader. Only variable declared as "out" in the vertex shader need a corresponding "in".

The next issue is the vertices need to have colors in them. The way it is setup now all the components are consumed before even a single triangle is drawn.

The vertex buffer needs to be setup: vertex,color, vertex,color, vertex,color

where each vertex and color has 3 floating point values.

GLfloat vertices[] = {

//    vertex           color
-0.5f, -0.5f, 0.0f,  1.0f,0.0f,0.0f
 0.5f, -0.5f, 0.0f,  0.0f,1.0f,0.0f
 0.0f,  0.5f, 0.0f,  0.0f,0.0f,1.0f 
};

Something like the above. Is what you need for the vertices.

Your inputs and outputs still don't line up.

#version 440 core  

// Comment out the line below
// in vec4 vs_pos;    <----- No corresponding output in the vertex shader
in vec3 vs_color; 

out vec4 fs_color;


void main()
{
    fs_color=vec4(vs_color, 1.f);
}

The gl_Position output is consumed and does not need a specific input in the fragment shader. Only variable declared as "out" in the vertex shader need a corresponding "in".

Your inputs and outputs still don't line up.

#version 440 core  

// Comment out the line below
// in vec4 vs_pos;    <----- No corresponding output in the vertex shader
in vec3 vs_color; 

out vec4 fs_color;


void main()
{
    fs_color=vec4(vs_color, 1.f);
}

The gl_Position output is consumed and does not need a specific input in the fragment shader. Only variable declared as "out" in the vertex shader need a corresponding "in".

The next issue is the vertices need to have colors in them. The way it is setup now all the components are consumed before even a single triangle is drawn.

The vertex buffer needs to be setup: vertex,color, vertex,color, vertex,color

where each vertex and color has 3 floating point values.

GLfloat vertices[] = {

//    vertex           color
-0.5f, -0.5f, 0.0f,  1.0f,0.0f,0.0f
 0.5f, -0.5f, 0.0f,  0.0f,1.0f,0.0f
 0.0f,  0.5f, 0.0f,  0.0f,0.0f,1.0f 
};

Something like the above. Is what you need for the vertices.

Source Link
pmw1234
  • 3.5k
  • 1
  • 8
  • 17

Your inputs and outputs still don't line up.

#version 440 core  

// Comment out the line below
// in vec4 vs_pos;    <----- No corresponding output in the vertex shader
in vec3 vs_color; 

out vec4 fs_color;


void main()
{
    fs_color=vec4(vs_color, 1.f);
}

The gl_Position output is consumed and does not need a specific input in the fragment shader. Only variable declared as "out" in the vertex shader need a corresponding "in".