Graphic program to display simple models with a texture, translation, rotation and scale

Introduced properties

private var _animation_coord: AttributeVec2

gamnit :: Simple2dProgram :: _animation_coord

Coordinates of each frame (mush be shared by all frames)
private var _animation_fps: AttributeFloat

gamnit :: Simple2dProgram :: _animation_fps

Frame per second of the animation
private var _animation_loops: AttributeFloat

gamnit :: Simple2dProgram :: _animation_loops

Number of loops of the animation, -1 for infinite
private var _animation_n_frames: AttributeFloat

gamnit :: Simple2dProgram :: _animation_n_frames

Number of frames in the animation
private var _animation_start: AttributeFloat

gamnit :: Simple2dProgram :: _animation_start

Animation start time, in seconds and in reference to dt
private var _animation_tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: _animation_tex_coord

Texture coordinates of the first frame
private var _animation_tex_diff: AttributeVec2

gamnit :: Simple2dProgram :: _animation_tex_diff

Coordinate difference between each frame
private var _animation_texture: UniformSampler2D

gamnit :: Simple2dProgram :: _animation_texture

Texture of all the frames of the animation
private var _color: AttributeVec4

gamnit :: Simple2dProgram :: _color

Color tint per vertex
private var _coord: AttributeVec4

gamnit :: Simple2dProgram :: _coord

Vertices coordinates
private var _mvp: UniformMat4

gamnit :: Simple2dProgram :: _mvp

Model view projection matrix
private var _rotation_row0: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row0

Rotation matrix, row 0
private var _rotation_row1: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row1

Rotation matrix, row 1
private var _rotation_row2: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row2

Rotation matrix, row 2
private var _rotation_row3: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row3

Rotation matrix, row 3
private var _scale: AttributeFloat

gamnit :: Simple2dProgram :: _scale

Scaling per vertex
private var _tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: _tex_coord

Coordinates on the textures, per vertex
private var _texture: UniformSampler2D

gamnit :: Simple2dProgram :: _texture

Visible texture unit
private var _time: UniformFloat

gamnit :: Simple2dProgram :: _time

World time, in seconds
private var _translation: AttributeVec4

gamnit :: Simple2dProgram :: _translation

Translation applied to each vertex
private var _use_texture: UniformBool

gamnit :: Simple2dProgram :: _use_texture

Should this program use the texture texture?
private fun animation_coord: AttributeVec2

gamnit :: Simple2dProgram :: animation_coord

Coordinates of each frame (mush be shared by all frames)
private fun animation_coord=(animation_coord: AttributeVec2)

gamnit :: Simple2dProgram :: animation_coord=

Coordinates of each frame (mush be shared by all frames)
private fun animation_fps: AttributeFloat

gamnit :: Simple2dProgram :: animation_fps

Frame per second of the animation
private fun animation_fps=(animation_fps: AttributeFloat)

gamnit :: Simple2dProgram :: animation_fps=

Frame per second of the animation
private fun animation_loops: AttributeFloat

gamnit :: Simple2dProgram :: animation_loops

Number of loops of the animation, -1 for infinite
private fun animation_loops=(animation_loops: AttributeFloat)

gamnit :: Simple2dProgram :: animation_loops=

Number of loops of the animation, -1 for infinite
private fun animation_n_frames: AttributeFloat

gamnit :: Simple2dProgram :: animation_n_frames

Number of frames in the animation
private fun animation_n_frames=(animation_n_frames: AttributeFloat)

gamnit :: Simple2dProgram :: animation_n_frames=

Number of frames in the animation
private fun animation_start: AttributeFloat

gamnit :: Simple2dProgram :: animation_start

Animation start time, in seconds and in reference to dt
private fun animation_start=(animation_start: AttributeFloat)

gamnit :: Simple2dProgram :: animation_start=

Animation start time, in seconds and in reference to dt
private fun animation_tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: animation_tex_coord

Texture coordinates of the first frame
private fun animation_tex_coord=(animation_tex_coord: AttributeVec2)

gamnit :: Simple2dProgram :: animation_tex_coord=

Texture coordinates of the first frame
private fun animation_tex_diff: AttributeVec2

gamnit :: Simple2dProgram :: animation_tex_diff

Coordinate difference between each frame
private fun animation_tex_diff=(animation_tex_diff: AttributeVec2)

gamnit :: Simple2dProgram :: animation_tex_diff=

Coordinate difference between each frame
private fun animation_texture: UniformSampler2D

gamnit :: Simple2dProgram :: animation_texture

Texture of all the frames of the animation
private fun animation_texture=(animation_texture: UniformSampler2D)

gamnit :: Simple2dProgram :: animation_texture=

Texture of all the frames of the animation
private fun color: AttributeVec4

gamnit :: Simple2dProgram :: color

Color tint per vertex
private fun color=(color: AttributeVec4)

gamnit :: Simple2dProgram :: color=

Color tint per vertex
private fun coord: AttributeVec4

gamnit :: Simple2dProgram :: coord

Vertices coordinates
private fun coord=(coord: AttributeVec4)

gamnit :: Simple2dProgram :: coord=

Vertices coordinates
protected fun fragment_shader_source=(fragment_shader_source: Text)

gamnit :: Simple2dProgram :: fragment_shader_source=

private fun mvp: UniformMat4

gamnit :: Simple2dProgram :: mvp

Model view projection matrix
private fun mvp=(mvp: UniformMat4)

gamnit :: Simple2dProgram :: mvp=

Model view projection matrix
private fun rotation_row0: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row0

Rotation matrix, row 0
private fun rotation_row0=(rotation_row0: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row0=

Rotation matrix, row 0
private fun rotation_row1: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row1

Rotation matrix, row 1
private fun rotation_row1=(rotation_row1: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row1=

Rotation matrix, row 1
private fun rotation_row2: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row2

Rotation matrix, row 2
private fun rotation_row2=(rotation_row2: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row2=

Rotation matrix, row 2
private fun rotation_row3: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row3

Rotation matrix, row 3
private fun rotation_row3=(rotation_row3: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row3=

Rotation matrix, row 3
private fun scale: AttributeFloat

gamnit :: Simple2dProgram :: scale

Scaling per vertex
private fun scale=(scale: AttributeFloat)

gamnit :: Simple2dProgram :: scale=

Scaling per vertex
private fun tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: tex_coord

Coordinates on the textures, per vertex
private fun tex_coord=(tex_coord: AttributeVec2)

gamnit :: Simple2dProgram :: tex_coord=

Coordinates on the textures, per vertex
private fun texture: UniformSampler2D

gamnit :: Simple2dProgram :: texture

Visible texture unit
private fun texture=(texture: UniformSampler2D)

gamnit :: Simple2dProgram :: texture=

Visible texture unit
private fun time: UniformFloat

gamnit :: Simple2dProgram :: time

World time, in seconds
private fun time=(time: UniformFloat)

gamnit :: Simple2dProgram :: time=

World time, in seconds
private fun translation: AttributeVec4

gamnit :: Simple2dProgram :: translation

Translation applied to each vertex
private fun translation=(translation: AttributeVec4)

gamnit :: Simple2dProgram :: translation=

Translation applied to each vertex
private fun use_texture: UniformBool

gamnit :: Simple2dProgram :: use_texture

Should this program use the texture texture?
private fun use_texture=(use_texture: UniformBool)

gamnit :: Simple2dProgram :: use_texture=

Should this program use the texture texture?
protected fun vertex_shader_source=(vertex_shader_source: Text)

gamnit :: Simple2dProgram :: vertex_shader_source=

Redefined properties

redef type SELF: Simple2dProgram

gamnit $ Simple2dProgram :: SELF

Type of this instance, automatically specialized in every class
redef fun fragment_shader_source: Text

gamnit $ Simple2dProgram :: fragment_shader_source

Source code of the fragment shader
redef fun vertex_shader_source: Text

gamnit $ Simple2dProgram :: vertex_shader_source

Source code of the vertex shader

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _animation_coord: AttributeVec2

gamnit :: Simple2dProgram :: _animation_coord

Coordinates of each frame (mush be shared by all frames)
private var _animation_fps: AttributeFloat

gamnit :: Simple2dProgram :: _animation_fps

Frame per second of the animation
private var _animation_loops: AttributeFloat

gamnit :: Simple2dProgram :: _animation_loops

Number of loops of the animation, -1 for infinite
private var _animation_n_frames: AttributeFloat

gamnit :: Simple2dProgram :: _animation_n_frames

Number of frames in the animation
private var _animation_start: AttributeFloat

gamnit :: Simple2dProgram :: _animation_start

Animation start time, in seconds and in reference to dt
private var _animation_tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: _animation_tex_coord

Texture coordinates of the first frame
private var _animation_tex_diff: AttributeVec2

gamnit :: Simple2dProgram :: _animation_tex_diff

Coordinate difference between each frame
private var _animation_texture: UniformSampler2D

gamnit :: Simple2dProgram :: _animation_texture

Texture of all the frames of the animation
private var _attributes: AttributeMap

gamnit :: GamnitProgram :: _attributes

Attributes of this program organized by name
private var _color: AttributeVec4

gamnit :: Simple2dProgram :: _color

Color tint per vertex
private var _coord: AttributeVec4

gamnit :: Simple2dProgram :: _coord

Vertices coordinates
private var _deleted: Bool

gamnit :: GamnitProgram :: _deleted

Has this program been deleted?
private var _error: nullable Error

gamnit :: GamnitProgram :: _error

Last error raised by compile_and_link
private var _gl_program: nullable GLProgram

gamnit :: GamnitProgram :: _gl_program

Index to the OpenGL ES program, set by compile_and_link
private var _mvp: UniformMat4

gamnit :: Simple2dProgram :: _mvp

Model view projection matrix
private var _rotation_row0: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row0

Rotation matrix, row 0
private var _rotation_row1: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row1

Rotation matrix, row 1
private var _rotation_row2: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row2

Rotation matrix, row 2
private var _rotation_row3: AttributeVec4

gamnit :: Simple2dProgram :: _rotation_row3

Rotation matrix, row 3
private var _scale: AttributeFloat

gamnit :: Simple2dProgram :: _scale

Scaling per vertex
private var _tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: _tex_coord

Coordinates on the textures, per vertex
private var _texture: UniformSampler2D

gamnit :: Simple2dProgram :: _texture

Visible texture unit
private var _time: UniformFloat

gamnit :: Simple2dProgram :: _time

World time, in seconds
private var _translation: AttributeVec4

gamnit :: Simple2dProgram :: _translation

Translation applied to each vertex
private var _uniforms: UniformMap

gamnit :: GamnitProgram :: _uniforms

Uniforms of this program organized by name
private var _use_texture: UniformBool

gamnit :: Simple2dProgram :: _use_texture

Should this program use the texture texture?
private fun animation_coord: AttributeVec2

gamnit :: Simple2dProgram :: animation_coord

Coordinates of each frame (mush be shared by all frames)
private fun animation_coord=(animation_coord: AttributeVec2)

gamnit :: Simple2dProgram :: animation_coord=

Coordinates of each frame (mush be shared by all frames)
private fun animation_fps: AttributeFloat

gamnit :: Simple2dProgram :: animation_fps

Frame per second of the animation
private fun animation_fps=(animation_fps: AttributeFloat)

gamnit :: Simple2dProgram :: animation_fps=

Frame per second of the animation
private fun animation_loops: AttributeFloat

gamnit :: Simple2dProgram :: animation_loops

Number of loops of the animation, -1 for infinite
private fun animation_loops=(animation_loops: AttributeFloat)

gamnit :: Simple2dProgram :: animation_loops=

Number of loops of the animation, -1 for infinite
private fun animation_n_frames: AttributeFloat

gamnit :: Simple2dProgram :: animation_n_frames

Number of frames in the animation
private fun animation_n_frames=(animation_n_frames: AttributeFloat)

gamnit :: Simple2dProgram :: animation_n_frames=

Number of frames in the animation
private fun animation_start: AttributeFloat

gamnit :: Simple2dProgram :: animation_start

Animation start time, in seconds and in reference to dt
private fun animation_start=(animation_start: AttributeFloat)

gamnit :: Simple2dProgram :: animation_start=

Animation start time, in seconds and in reference to dt
private fun animation_tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: animation_tex_coord

Texture coordinates of the first frame
private fun animation_tex_coord=(animation_tex_coord: AttributeVec2)

gamnit :: Simple2dProgram :: animation_tex_coord=

Texture coordinates of the first frame
private fun animation_tex_diff: AttributeVec2

gamnit :: Simple2dProgram :: animation_tex_diff

Coordinate difference between each frame
private fun animation_tex_diff=(animation_tex_diff: AttributeVec2)

gamnit :: Simple2dProgram :: animation_tex_diff=

Coordinate difference between each frame
private fun animation_texture: UniformSampler2D

gamnit :: Simple2dProgram :: animation_texture

Texture of all the frames of the animation
private fun animation_texture=(animation_texture: UniformSampler2D)

gamnit :: Simple2dProgram :: animation_texture=

Texture of all the frames of the animation
fun attributes: AttributeMap

gamnit :: GamnitProgram :: attributes

Attributes of this program organized by name
protected fun attributes=(attributes: AttributeMap)

gamnit :: GamnitProgram :: attributes=

Attributes of this program organized by name
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
private fun color: AttributeVec4

gamnit :: Simple2dProgram :: color

Color tint per vertex
private fun color=(color: AttributeVec4)

gamnit :: Simple2dProgram :: color=

Color tint per vertex
private fun coord: AttributeVec4

gamnit :: Simple2dProgram :: coord

Vertices coordinates
private fun coord=(coord: AttributeVec4)

gamnit :: Simple2dProgram :: coord=

Vertices coordinates
fun delete

gamnit :: GamnitProgram :: delete

Delete this program if it has not already been deleted
fun deleted: Bool

gamnit :: GamnitProgram :: deleted

Has this program been deleted?
protected fun deleted=(deleted: Bool)

gamnit :: GamnitProgram :: deleted=

Has this program been deleted?
fun diagnose

gamnit :: GamnitProgram :: diagnose

Diagnose possible problems with the shaders of the program
fun error: nullable Error

gamnit :: GamnitProgram :: error

Last error raised by compile_and_link
protected fun error=(error: nullable Error)

gamnit :: GamnitProgram :: error=

Last error raised by compile_and_link
abstract fun fragment_shader: FragmentShader

gamnit :: GamnitProgram :: fragment_shader

Fragment shader to attach to this program
abstract fun fragment_shader_source: Text

gamnit :: GamnitProgramFromSource :: fragment_shader_source

Source code of the fragment shader
protected fun fragment_shader_source=(fragment_shader_source: Text)

gamnit :: Simple2dProgram :: fragment_shader_source=

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
private fun gl_program: nullable GLProgram

gamnit :: GamnitProgram :: gl_program

Index to the OpenGL ES program, set by compile_and_link
private fun gl_program=(gl_program: nullable GLProgram)

gamnit :: GamnitProgram :: gl_program=

Index to the OpenGL ES program, set by compile_and_link
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
private fun mvp: UniformMat4

gamnit :: Simple2dProgram :: mvp

Model view projection matrix
private fun mvp=(mvp: UniformMat4)

gamnit :: Simple2dProgram :: mvp=

Model view projection matrix
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
private fun rotation_row0: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row0

Rotation matrix, row 0
private fun rotation_row0=(rotation_row0: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row0=

Rotation matrix, row 0
private fun rotation_row1: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row1

Rotation matrix, row 1
private fun rotation_row1=(rotation_row1: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row1=

Rotation matrix, row 1
private fun rotation_row2: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row2

Rotation matrix, row 2
private fun rotation_row2=(rotation_row2: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row2=

Rotation matrix, row 2
private fun rotation_row3: AttributeVec4

gamnit :: Simple2dProgram :: rotation_row3

Rotation matrix, row 3
private fun rotation_row3=(rotation_row3: AttributeVec4)

gamnit :: Simple2dProgram :: rotation_row3=

Rotation matrix, row 3
private fun scale: AttributeFloat

gamnit :: Simple2dProgram :: scale

Scaling per vertex
private fun scale=(scale: AttributeFloat)

gamnit :: Simple2dProgram :: scale=

Scaling per vertex
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
private fun tex_coord: AttributeVec2

gamnit :: Simple2dProgram :: tex_coord

Coordinates on the textures, per vertex
private fun tex_coord=(tex_coord: AttributeVec2)

gamnit :: Simple2dProgram :: tex_coord=

Coordinates on the textures, per vertex
private fun texture: UniformSampler2D

gamnit :: Simple2dProgram :: texture

Visible texture unit
private fun texture=(texture: UniformSampler2D)

gamnit :: Simple2dProgram :: texture=

Visible texture unit
private fun time: UniformFloat

gamnit :: Simple2dProgram :: time

World time, in seconds
private fun time=(time: UniformFloat)

gamnit :: Simple2dProgram :: time=

World time, in seconds
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
private fun translation: AttributeVec4

gamnit :: Simple2dProgram :: translation

Translation applied to each vertex
private fun translation=(translation: AttributeVec4)

gamnit :: Simple2dProgram :: translation=

Translation applied to each vertex
fun uniforms: UniformMap

gamnit :: GamnitProgram :: uniforms

Uniforms of this program organized by name
protected fun uniforms=(uniforms: UniformMap)

gamnit :: GamnitProgram :: uniforms=

Uniforms of this program organized by name
fun use

gamnit :: GamnitProgram :: use

Notify the GPU to use this program
private fun use_texture: UniformBool

gamnit :: Simple2dProgram :: use_texture

Should this program use the texture texture?
private fun use_texture=(use_texture: UniformBool)

gamnit :: Simple2dProgram :: use_texture=

Should this program use the texture texture?
abstract fun vertex_shader: VertexShader

gamnit :: GamnitProgram :: vertex_shader

Vertex shader to attach to this program
abstract fun vertex_shader_source: Text

gamnit :: GamnitProgramFromSource :: vertex_shader_source

Source code of the vertex shader
protected fun vertex_shader_source=(vertex_shader_source: Text)

gamnit :: Simple2dProgram :: vertex_shader_source=

package_diagram gamnit::flat_core::Simple2dProgram Simple2dProgram gamnit::GamnitProgramFromSource GamnitProgramFromSource gamnit::flat_core::Simple2dProgram->gamnit::GamnitProgramFromSource gamnit::GamnitProgram GamnitProgram gamnit::GamnitProgramFromSource->gamnit::GamnitProgram ...gamnit::GamnitProgram ... ...gamnit::GamnitProgram->gamnit::GamnitProgram

Ancestors

abstract class GamnitProgram

gamnit :: GamnitProgram

Gamnit graphical program
interface Object

core :: Object

The root of the class hierarchy.

Parents

class GamnitProgramFromSource

gamnit :: GamnitProgramFromSource

Gamnit graphical program from the shaders source code

Class definitions

gamnit $ Simple2dProgram
# Graphic program to display simple models with a texture, translation, rotation and scale
private class Simple2dProgram
	super GamnitProgramFromSource

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

		// Vertex color tint
		attribute vec4 color;

		// Vertex translation
		attribute vec4 translation;

		// Vertex scaling
		attribute float scale;

		// Vertex coordinates on textures
		attribute vec2 tex_coord;

		// Model view projection matrix
		uniform mat4 mvp;

		// Current world time, in seconds
		uniform float time;

		// Rotation matrix
		attribute vec4 rotation_row0;
		attribute vec4 rotation_row1;
		attribute vec4 rotation_row2;
		attribute vec4 rotation_row3;

		// Animation speed, frames per seconds
		attribute float a_fps;

		// Number of frames in the animation
		attribute float a_n_frames;

		// World coordinate of the animation (for aspect ratio)
		attribute vec2 a_coord;

		// Animation texture coordinates of the first frame
		attribute vec2 a_tex_coord;

		// Animation texture coordinates difference between frames
		attribute vec2 a_tex_diff;

		// Animation start time, in reference to `time`
		attribute float a_start;

		// Number of loops to play of the animation
		attribute float a_loops;

		mat4 rotation()
		{
			return mat4(rotation_row0, rotation_row1, rotation_row2, rotation_row3);
		}

		// Output to the fragment shader
		varying vec4 v_color;
		varying vec2 v_coord;

		// Is there an active animation?
		varying float v_animated;

		void main()
		{
			vec3 c; // coords

			float end = a_start + a_loops/a_fps*a_n_frames;
			if (a_fps != 0.0 && (a_loops == -1.0 || time < end)) {
				// in animation
				float frame = mod(floor((time-a_start)*a_fps), a_n_frames);
				v_coord = a_tex_coord + a_tex_diff*frame;
				c = vec3(a_coord, coord.z);
				v_animated = 1.0;
			} else {
				// static
				v_coord = tex_coord;
				c = coord.xyz;
				v_animated = 0.0;
			}

			gl_Position = (vec4(c * scale, 1.0) * rotation() + translation)* mvp;
			v_color = vec4(color.rgb*color.a, color.a);
		}
		""" @ glsl_vertex_shader

	redef var fragment_shader_source = """
		precision mediump float;

		// Does this object use a texture?
		uniform bool use_texture;

		// Texture to apply on this object
		uniform sampler2D texture0;

		// Texture to apply on this object
		uniform sampler2D animation;

		// Input from the vertex shader
		varying vec4 v_color;
		varying vec2 v_coord;
		varying float v_animated;

		void main()
		{
			if (v_animated > 0.5) {
				gl_FragColor = v_color * texture2D(animation, v_coord);
				if (gl_FragColor.a <= 0.01) discard;
			} else if (use_texture) {
				gl_FragColor = v_color * texture2D(texture0, v_coord);
				if (gl_FragColor.a <= 0.01) discard;
			} else {
				gl_FragColor = v_color;
			}
		}
		""" @ glsl_fragment_shader

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

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

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

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

	# Color tint per vertex
	var color = attributes["color"].as(AttributeVec4) is lazy

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

	# Rotation matrix, row 0
	var rotation_row0 = attributes["rotation_row0"].as(AttributeVec4) is lazy

	# Rotation matrix, row 1
	var rotation_row1 = attributes["rotation_row1"].as(AttributeVec4) is lazy

	# Rotation matrix, row 2
	var rotation_row2 = attributes["rotation_row2"].as(AttributeVec4) is lazy

	# Rotation matrix, row 3
	var rotation_row3 = attributes["rotation_row3"].as(AttributeVec4) is lazy

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

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

	# World time, in seconds
	var time = uniforms["time"].as(UniformFloat) is lazy

	# ---
	# Animations

	# Texture of all the frames of the animation
	var animation_texture = uniforms["animation"].as(UniformSampler2D) is lazy

	# Frame per second of the animation
	var animation_fps = attributes["a_fps"].as(AttributeFloat) is lazy

	# Number of frames in the animation
	var animation_n_frames = attributes["a_n_frames"].as(AttributeFloat) is lazy

	# Coordinates of each frame (mush be shared by all frames)
	var animation_coord = attributes["a_coord"].as(AttributeVec2) is lazy

	# Texture coordinates of the first frame
	var animation_tex_coord = attributes["a_tex_coord"].as(AttributeVec2) is lazy

	# Coordinate difference between each frame
	var animation_tex_diff = attributes["a_tex_diff"].as(AttributeVec2) is lazy

	# Animation start time, in seconds and in reference to `dt`
	var animation_start = attributes["a_start"].as(AttributeFloat) is lazy

	# Number of loops of the animation, -1 for infinite
	var animation_loops = attributes["a_loops"].as(AttributeFloat) is lazy
end
lib/gamnit/flat/flat_core.nit:634,1--818,3