Skip to content

Instantly share code, notes, and snippets.

@sortofsleepy
Last active August 29, 2015 13:57
Show Gist options
  • Save sortofsleepy/9821640 to your computer and use it in GitHub Desktop.
Save sortofsleepy/9821640 to your computer and use it in GitHub Desktop.
A bare minimum set of shaders necessary to get something rendering in OpenGL 3.2+
/** ======= VERTEX SHADER ==============*/
#version 150
in vec4 position;
in vec2 texcoord;
uniform mat4 modelViewProjectionMatrix;
void main(){
//get our current vertex position so we can modify it
vec4 pos = modelViewProjectionMatrix * position;
//finally set the pos to be that actual position rendered
gl_Position = pos;
}
/** ======= FRAGMENT SHADER ==============*/
#version 150
uniform vec4 globalColor;
out vec4 fragColor;
void main(){
//this is the fragment shader
//this is where the pixel level drawing happens
//gl_FragCoord gives us the x and y of the current pixel its drawing
//we grab the x and y and store them in an int
float xVal = gl_FragCoord.x;
float yVal = gl_FragCoord.y;
fragColor = globalColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment