Shader 'hello world'

Hi, I’m having bad times trying to experiment with shaders.
I’ve modified the ShaderExample and would like to setup an hello world shader, a shader that does nothing except setting the default position and colorize the fragment in one color, and from there experiment step by step

I’ve tried the code below but I only get a black screen (this is for OGL 3.0, GLES 1.5), really I don’t understand what I’ve missed… Any help greatly appreciated :sunny:

Vertex shader

#version 150

in vec4 position;
uniform mat4 modelViewProjectionMatrix;
 
void main(){
	vec4 pos = modelViewProjectionMatrix * position;
	gl_Position = pos;
}

Fragment shader

#version 150

out vec3 FragColor;

void main(){
	FragColor = vec3(1.0, 0.0, 0.0);
}

Hi there!

Fragment shaders must output, at least, one vec4. So, your frag should be something like:

#version 150

out vec4 FragColor;

void main(){
	FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

That is, RGBA.

Thanks a lot ! It works :smile: