Skip to content

Instantly share code, notes, and snippets.

@tylerreisinger
Created May 10, 2019 08:48
Show Gist options
  • Save tylerreisinger/6185f289bd9f4340646f98b73b0425ef to your computer and use it in GitHub Desktop.
Save tylerreisinger/6185f289bd9f4340646f98b73b0425ef to your computer and use it in GitHub Desktop.
OGL Shader Working
static const char* vertex_shader_src =
R"(
#version 440
layout(location = 0) uniform mat4 proj;
layout(location = 0) in vec2 position;
layout(location = 1) in vec2 uv;
layout(location = 2) in vec4 color;
layout(location = 0) 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 440
layout(binding = 0) uniform sampler2D tex;
layout(location = 0) 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