Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tylerreisinger/ddd56ba4f8b601eef1c87917a596b16e to your computer and use it in GitHub Desktop.
Save tylerreisinger/ddd56ba4f8b601eef1c87917a596b16e to your computer and use it in GitHub Desktop.
OGL shaders
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