gamnit :: Simple2dProgram :: _animation_coord
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: _animation_fps
Frame per second of the animationgamnit :: Simple2dProgram :: _animation_loops
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: _animation_n_frames
Number of frames in the animationgamnit :: Simple2dProgram :: _animation_start
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: _animation_tex_coord
Texture coordinates of the first framegamnit :: Simple2dProgram :: _animation_tex_diff
Coordinate difference between each framegamnit :: Simple2dProgram :: _animation_texture
Texture of all the frames of the animationgamnit :: Simple2dProgram :: _rotation_row0
Rotation matrix, row 0gamnit :: Simple2dProgram :: _rotation_row1
Rotation matrix, row 1gamnit :: Simple2dProgram :: _rotation_row2
Rotation matrix, row 2gamnit :: Simple2dProgram :: _rotation_row3
Rotation matrix, row 3gamnit :: Simple2dProgram :: _tex_coord
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: _translation
Translation applied to each vertexgamnit :: Simple2dProgram :: _use_texture
Should this program use the texturetexture
?
gamnit :: Simple2dProgram :: animation_coord
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: animation_coord=
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: animation_fps
Frame per second of the animationgamnit :: Simple2dProgram :: animation_fps=
Frame per second of the animationgamnit :: Simple2dProgram :: animation_loops
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: animation_loops=
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: animation_n_frames
Number of frames in the animationgamnit :: Simple2dProgram :: animation_n_frames=
Number of frames in the animationgamnit :: Simple2dProgram :: animation_start
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: animation_start=
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: animation_tex_coord
Texture coordinates of the first framegamnit :: Simple2dProgram :: animation_tex_coord=
Texture coordinates of the first framegamnit :: Simple2dProgram :: animation_tex_diff
Coordinate difference between each framegamnit :: Simple2dProgram :: animation_tex_diff=
Coordinate difference between each framegamnit :: Simple2dProgram :: animation_texture
Texture of all the frames of the animationgamnit :: Simple2dProgram :: animation_texture=
Texture of all the frames of the animationgamnit :: Simple2dProgram :: defaultinit
gamnit :: Simple2dProgram :: rotation_row0
Rotation matrix, row 0gamnit :: Simple2dProgram :: rotation_row0=
Rotation matrix, row 0gamnit :: Simple2dProgram :: rotation_row1
Rotation matrix, row 1gamnit :: Simple2dProgram :: rotation_row1=
Rotation matrix, row 1gamnit :: Simple2dProgram :: rotation_row2
Rotation matrix, row 2gamnit :: Simple2dProgram :: rotation_row2=
Rotation matrix, row 2gamnit :: Simple2dProgram :: rotation_row3
Rotation matrix, row 3gamnit :: Simple2dProgram :: rotation_row3=
Rotation matrix, row 3gamnit :: Simple2dProgram :: tex_coord
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: tex_coord=
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: texture=
Visible texture unitgamnit :: Simple2dProgram :: translation
Translation applied to each vertexgamnit :: Simple2dProgram :: translation=
Translation applied to each vertexgamnit :: Simple2dProgram :: use_texture
Should this program use the texturetexture
?
gamnit :: Simple2dProgram :: use_texture=
Should this program use the texturetexture
?
gamnit $ Simple2dProgram :: SELF
Type of this instance, automatically specialized in every classgamnit $ Simple2dProgram :: fragment_shader_source
Source code of the fragment shadergamnit $ Simple2dProgram :: vertex_shader_source
Source code of the vertex shadergamnit :: Simple2dProgram :: _animation_coord
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: _animation_fps
Frame per second of the animationgamnit :: Simple2dProgram :: _animation_loops
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: _animation_n_frames
Number of frames in the animationgamnit :: Simple2dProgram :: _animation_start
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: _animation_tex_coord
Texture coordinates of the first framegamnit :: Simple2dProgram :: _animation_tex_diff
Coordinate difference between each framegamnit :: Simple2dProgram :: _animation_texture
Texture of all the frames of the animationgamnit :: GamnitProgram :: _attributes
Attributes of this program organized by namegamnit :: GamnitProgram :: _error
Last error raised bycompile_and_link
gamnit :: GamnitProgram :: _gl_program
Index to the OpenGL ES program, set bycompile_and_link
gamnit :: Simple2dProgram :: _rotation_row0
Rotation matrix, row 0gamnit :: Simple2dProgram :: _rotation_row1
Rotation matrix, row 1gamnit :: Simple2dProgram :: _rotation_row2
Rotation matrix, row 2gamnit :: Simple2dProgram :: _rotation_row3
Rotation matrix, row 3gamnit :: Simple2dProgram :: _tex_coord
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: _translation
Translation applied to each vertexgamnit :: GamnitProgram :: _uniforms
Uniforms of this program organized by namegamnit :: Simple2dProgram :: _use_texture
Should this program use the texturetexture
?
gamnit :: Simple2dProgram :: animation_coord
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: animation_coord=
Coordinates of each frame (mush be shared by all frames)gamnit :: Simple2dProgram :: animation_fps
Frame per second of the animationgamnit :: Simple2dProgram :: animation_fps=
Frame per second of the animationgamnit :: Simple2dProgram :: animation_loops
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: animation_loops=
Number of loops of the animation, -1 for infinitegamnit :: Simple2dProgram :: animation_n_frames
Number of frames in the animationgamnit :: Simple2dProgram :: animation_n_frames=
Number of frames in the animationgamnit :: Simple2dProgram :: animation_start
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: animation_start=
Animation start time, in seconds and in reference todt
gamnit :: Simple2dProgram :: animation_tex_coord
Texture coordinates of the first framegamnit :: Simple2dProgram :: animation_tex_coord=
Texture coordinates of the first framegamnit :: Simple2dProgram :: animation_tex_diff
Coordinate difference between each framegamnit :: Simple2dProgram :: animation_tex_diff=
Coordinate difference between each framegamnit :: Simple2dProgram :: animation_texture
Texture of all the frames of the animationgamnit :: Simple2dProgram :: animation_texture=
Texture of all the frames of the animationgamnit :: GamnitProgram :: attributes
Attributes of this program organized by namegamnit :: GamnitProgram :: attributes=
Attributes of this program organized by namecore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
gamnit :: GamnitProgram :: compile_and_link
Compile the shaders, and this program, then link and report any errorscore :: Object :: defaultinit
gamnit :: GamnitProgram :: defaultinit
gamnit :: Simple2dProgram :: defaultinit
gamnit :: GamnitProgram :: deleted=
Has this program been deleted?gamnit :: GamnitProgram :: diagnose
Diagnose possible problems with the shaders of the programgamnit :: GamnitProgram :: error=
Last error raised bycompile_and_link
gamnit :: GamnitProgram :: fragment_shader
Fragment shader to attach to this programgamnit :: GamnitProgramFromSource :: fragment_shader_source
Source code of the fragment shadergamnit :: GamnitProgram :: gl_program
Index to the OpenGL ES program, set bycompile_and_link
gamnit :: GamnitProgram :: gl_program=
Index to the OpenGL ES program, set bycompile_and_link
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: Simple2dProgram :: rotation_row0
Rotation matrix, row 0gamnit :: Simple2dProgram :: rotation_row0=
Rotation matrix, row 0gamnit :: Simple2dProgram :: rotation_row1
Rotation matrix, row 1gamnit :: Simple2dProgram :: rotation_row1=
Rotation matrix, row 1gamnit :: Simple2dProgram :: rotation_row2
Rotation matrix, row 2gamnit :: Simple2dProgram :: rotation_row2=
Rotation matrix, row 2gamnit :: Simple2dProgram :: rotation_row3
Rotation matrix, row 3gamnit :: Simple2dProgram :: rotation_row3=
Rotation matrix, row 3gamnit :: Simple2dProgram :: tex_coord
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: tex_coord=
Coordinates on the textures, per vertexgamnit :: Simple2dProgram :: texture=
Visible texture unitgamnit :: Simple2dProgram :: translation
Translation applied to each vertexgamnit :: Simple2dProgram :: translation=
Translation applied to each vertexgamnit :: GamnitProgram :: uniforms
Uniforms of this program organized by namegamnit :: GamnitProgram :: uniforms=
Uniforms of this program organized by namegamnit :: Simple2dProgram :: use_texture
Should this program use the texturetexture
?
gamnit :: Simple2dProgram :: use_texture=
Should this program use the texturetexture
?
gamnit :: GamnitProgram :: vertex_shader
Vertex shader to attach to this programgamnit :: GamnitProgramFromSource :: vertex_shader_source
Source code of the vertex shadergamnit :: GamnitProgramFromSource
Gamnit graphical program from the shaders source code
# 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