Last active
August 29, 2015 13:57
-
-
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+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** ======= 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