<jittershader name="gm.test.jxs">
	<description>Simple geometry shader test</description>
	<param name="scale" type="float" default="1." />
	<param name="c1" type="vec4" default="1.0 0.0 0.0 1.0" />
	<param name="c2" type="vec4" default="0.0 0.0 1.0 1.0" />
	<language name="glsl" version="1.2">
		<bind param="scale" program="gp" />
		<bind param="c1" program="gp" />
		<bind param="c2" program="gp" />
		<program name="vp" type="vertex">
<![CDATA[

#version 120

varying vec4 P;
varying vec3 N;

void main(void)
{
	//get the vertices into eye space
	P = gl_ModelViewMatrix*gl_Vertex;
	
	//just send the things as they are
	gl_Position = gl_Vertex;
	gl_FrontColor = gl_Color;
	
	//get normals into eye space
	N = gl_NormalMatrix*gl_Normal;
}

]]>		
		</program>
		<program name="gp" vertices_out="6" input_type="triangles" output_type="line_strip" type="geometry">
<![CDATA[

#version 120
#extension GL_EXT_geometry_shader4 : enable

uniform float scale;
uniform vec4 c1;
uniform vec4 c2;

varying in vec4 P[3];
varying in vec3 N[3];


vec4 add_normal(vec4 p, vec3 n)
{
	vec4 t = p;
	t.xyz += n.xyz*scale;
	return t;
}


void main(void)
{
//--------------------------------------------------------------------------
	gl_FrontColor = c1;
	gl_Position = gl_ProjectionMatrix*P[0];
	EmitVertex();
	
	gl_FrontColor = c2;
	gl_Position = gl_ProjectionMatrix*add_normal(P[0], N[0]);
	EmitVertex();	
		EndPrimitive();
//--------------------------------------------------------------------------
	gl_FrontColor = c1;
	gl_Position = gl_ProjectionMatrix*P[1];
	EmitVertex();
	
	gl_FrontColor = c2;
	gl_Position = gl_ProjectionMatrix*add_normal(P[1], N[1]);
	EmitVertex();	
		EndPrimitive();
//--------------------------------------------------------------------------		
	gl_FrontColor = c1;
	gl_Position = gl_ProjectionMatrix*P[2];
	EmitVertex();
	
	gl_FrontColor = c2;
	gl_Position = gl_ProjectionMatrix*add_normal(P[2], N[2]);
	EmitVertex();	
		EndPrimitive();
//--------------------------------------------------------------------------
}


]]>
		</program>
		<program name="fp" type="fragment">
<![CDATA[

#version 120


void main (void)
{
	gl_FragColor = gl_Color;
}


]]>		
		</program>		
	</language>
</jittershader>
