Skip to content

Instantly share code, notes, and snippets.

@rikusalminen
Created August 26, 2015 15:23
Show Gist options
  • Save rikusalminen/87a012e6a687f0550d27 to your computer and use it in GitHub Desktop.
Save rikusalminen/87a012e6a687f0550d27 to your computer and use it in GitHub Desktop.
Wireframe cube in GLSL (usage: glDrawArrays(0, 24))
#version 420
uniform mat4 projection_matrix;
uniform mat4 model_matrix;
void main() {
vec4 pos = vec4(0.0, 0.0, 0.0, 1.0);
int axis = gl_VertexID >> 3;
pos[(axis+0)%3] = (gl_VertexID & 1) >> 0;
pos[(axis+1)%3] = (gl_VertexID & 2) >> 1;
pos[(axis+2)%3] = (gl_VertexID & 4) >> 2;
gl_Position = projection_matrix * model_matrix *
(vec4(-1.0) + 2.0*pos);
}
@sich01
Copy link

sich01 commented Feb 8, 2016

Thanks for showing a very interesting approach. However, when I slightly modified the shader using" varying vec4 pos" and applied it to an example in www.openglsuperbible.com (linesmooth) only a quad is shown. Could you provide a complete source code example or explain the logic of your shader code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment