Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created May 18, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDanisch/e3630a6909ffad1a06b3a571ef3588cb to your computer and use it in GitHub Desktop.
Save SimonDanisch/e3630a6909ffad1a06b3a571ef3588cb to your computer and use it in GitHub Desktop.
#version 330
// dependant type declarations
// Julia name: Uniforms
struct Uniforms{
mat4 model;
int max_primtives;
float maxlength;
float thickness;
float pattern_length;
};
// Julia name: Canvas
struct Canvas{
vec2 resolution;
mat4 projection;
mat4 view;
mat4 projectionview;
};
// Julia name: LineVertex{2}
struct LineVertex_2{
vec4 color;
float thickness;
vec2 position;
};
// Julia name: Vert2Geom
struct Vert2Geom{
vec4 position;
vec4 color;
float thickness;
};
// dependant function declarations
float get_thickness(LineVertex_2 x, Uniforms uniforms)
{
return x.thickness;
}
vec4 get_color(LineVertex_2 x, Uniforms uniforms)
{
return x.color;
}
vec2 get_position(LineVertex_2 x)
{
return x.position;
}
vec4 to_vec4(vec2 v)
{
return vec4(v.x, v.y, 0.0, 1.0);
}
// vertex input:
layout (location = 0) in vec4 vertex_color;
layout (location = 1) in float vertex_thickness;
layout (location = 2) in vec2 vertex_position;
// uniform inputs:
layout (std140) uniform _gensymed_UniformArg1{
Canvas canvas;
};
layout (std140) uniform _gensymed_UniformArg2{
Uniforms uniforms;
};
out Vert2Geom geom_in;
// vertex main function:
void main()
{
LineVertex_2 vertex;
vertex = LineVertex_2(vertex_color, vertex_thickness, vertex_position);
Vert2Geom geomout;
vec4 pos;
mat4 pm;
pm = canvas.projectionview * uniforms.model;
pos = pm * to_vec4(get_position(vertex));
geomout = Vert2Geom(pos, get_color(vertex, uniforms), get_thickness(vertex, uniforms));
geom_in = geomout;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment