#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 gPos;
out vec2 gBoundingBox;
void main()
{
  vec4 pas = gl_in[0].gl_Position;
  vec4 pbs = gl_in[1].gl_Position;
  vec4 pcs = gl_in[2].gl_Position;
  vec4 pa = theMat * pas;
  vec4 pb = theMat * pbs;
  vec4 pc = theMat * pcs;
  gBoundingBox = vec2 (-1,1);
  gl_Position = pb; 
  gPos = pbs;
  EmitVertex();
  gBoundingBox = vec2 (1,1);
  gl_Position = pa;
  gPos = pas;
  EmitVertex();
  gBoundingBox = vec2 (-1,-1);
  gl_Position = pc;
  gPos = pcs;
  EmitVertex();
  gBoundingBox = vec2 (1,-1);
  gl_Position = pa + pc - pb;
  gPos = pas + pcs - pbs;
  EmitVertex();
  EndPrimitive();
}
