Property definitions

gamnit $ SelectionProgram :: defaultinit
# Program to draw selection values
class SelectionProgram
	super GamnitProgramFromSource

	redef var vertex_shader_source = """
		// Vertex coordinates
		attribute vec4 coord;

		// Vertex translation
		uniform vec4 translation;

		// Vertex scaling
		uniform float scale;

		// Vertex coordinates on textures
		attribute vec2 tex_coord;

		// Model view projection matrix
		uniform mat4 mvp;

		// Model rotation
		uniform mat4 rotation;

		// Output for the fragment shader
		varying vec2 v_tex_coord;

		void main()
		{
			v_tex_coord = vec2(tex_coord.x, 1.0 - tex_coord.y);

			gl_Position = (vec4(coord.xyz * scale, 1.0) * rotation + translation) * mvp;
		}
		""" @ glsl_vertex_shader

	#
	redef var fragment_shader_source = """
		precision highp float;

		varying vec2 v_tex_coord;

		// Map used as reference for opacity
		uniform sampler2D map_diffuse;

		// Should `map_diffuse` be used?
		uniform bool use_map_diffuse;

		// Color ID
		uniform vec4 color;

		void main()
		{
			gl_FragColor = vec4(color.rgb, 1.0);

			if (use_map_diffuse && texture2D(map_diffuse, v_tex_coord).a < 0.1) {
				gl_FragColor.a = 0.0;
			}
		}
		""" @ glsl_fragment_shader

	# Vertices coordinates
	var coord = attributes["coord"].as(AttributeVec4) is lazy

	# Should this program use the texture `map_diffuse`?
	var use_map_diffuse = uniforms["use_map_diffuse"].as(UniformBool) is lazy

	# Diffuse texture unit
	var map_diffuse = uniforms["map_diffuse"].as(UniformSampler2D) is lazy

	# Coordinates on the textures, per vertex
	var tex_coord = attributes["tex_coord"].as(AttributeVec2) is lazy

	# Translation applied to each vertex
	var translation = uniforms["translation"].as(UniformVec4) is lazy

	# Rotation matrix
	var rotation = uniforms["rotation"].as(UniformMat4) is lazy

	# Scaling per vertex
	var scale = uniforms["scale"].as(UniformFloat) is lazy

	# Model view projection matrix
	var mvp = uniforms["mvp"].as(UniformMat4) is lazy

	# ID as a color
	var color_id = uniforms["color"].as(UniformVec4) is lazy
end
lib/gamnit/depth/selection.nit:236,1--321,3