Created
May 9, 2019 22:38
-
-
Save tylerreisinger/ddd56ba4f8b601eef1c87917a596b16e to your computer and use it in GitHub Desktop.
OGL shaders
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
static const char* vertex_shader_src = | |
R"( | |
#version 430 | |
uniform mat4 proj; | |
in vec2 position; | |
in vec2 uv; | |
in vec4 color; | |
out VertexData { | |
vec2 uv; | |
vec4 color; | |
} out_data; | |
void main() { | |
out_data.uv = uv; | |
out_data.color = color; | |
gl_Position = proj * vec4(position, 0.0, 1.0); | |
} | |
)"; | |
static const char* fragment_shader_src = | |
R"( | |
#version 430 | |
uniform sampler2D tex; | |
in VertexData { | |
vec2 uv; | |
vec4 color; | |
} vertex_data; | |
out vec4 color; | |
void main() { | |
color = vertex_data.color * texture(tex, vertex_data.uv); | |
} | |
)"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment