Black screen on nVidia graphics


I have a problem rendering fullscreen quad on nVidia GPU (GT650M), though it works fine on Intel HD 4000. For some reason the screen is black when I try it on nVidia. (should be all red)
I think the problem isn’t in VBO/VAO creation since other geometry renders fine. (using different shaders)

I put screenshot of apitrace in the attachments since I think it better shows all the opengl calls (easier to find the missing one?). I commented out a lot of the code (rendering of other geomertry) to make it as short as possible.
Edit: seems the screenshot gets downscalled so here’s a link i.imgur (dot) com/us0ShqI.png
I can also paste more the code if needed.
I’m using OpenGL 3.2 Core.
I’ve been trying to fix this for a week now, so any help would be greatly appreciated.

Thank you.

The VAO/VBO are initialized like this:

vertices = { { -1.0f, -1.0f, 0.0f }, { 1.0f, -1.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { -1.0f, 1.0f, 0.0f } };
indices = { 0, 1, 2, 2, 3, 0 };

glGenVertexArrays(1, &vao);

glGenBuffers(1, &vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vector3f),, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

glGenBuffers(1, &elementVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementVBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short),, GL_STATIC_DRAW);

Render like this:

glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, nullptr);

And here is the shader code:

#version 330 core

layout(location = 0) in vec3 vertexPosition;

out vec2 UV;

void main()
    UV = (vertexPosition.xy + vec2(1, 1)) / 2.0;
    gl_Position = vec4(vertexPosition, 1);

#version 330 core
in vec2 UV;
out vec3 color;
uniform sampler2D tex;
void main()
    //color = texture(tex, UV).xyz;
    color = vec3(1.0, 0.0, 0.0);

It was the shader output being vec3 instead of vec4.