It will use either the uniform
value or the data at array_pointer
if
and only if array_enabled
.
gamnit :: Attribute :: array_enabled=
Set whether to use the data atarray_pointer
over uniform
.
gamnit :: Attribute :: defaultinit
gamnit :: Attribute :: array_enabled=
Set whether to use the data atarray_pointer
over uniform
.
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
gamnit :: Attribute :: defaultinit
gamnit :: ShaderVariable :: defaultinit
gamnit :: ShaderVariable :: is_active
Isself
an active uniform or attribute in the program
?
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.
gamnit :: ShaderVariable :: location=
Location ofself
in the compiled program
gamnit :: ShaderVariable :: name=
Name ofself
in the program
source
core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: ShaderVariable :: program=
TheGamnitProgram
to which self
belongs
gamnit :: ShaderVariable :: size
Number of elements in this array (1 for scalars and more for vectors)gamnit :: ShaderVariable :: size=
Number of elements in this array (1 for scalars and more for vectors)Attribute
that does not exist or that has been optimized out
# Shader attribute
#
# It will use either the `uniform` value or the data at `array_pointer` if
# and only if `array_enabled`.
class Attribute
super ShaderVariable
private var array_enabled_cache = false
# Is the array attribute enabled?
fun array_enabled: Bool do return array_enabled_cache
# Set whether to use the data at `array_pointer` over `uniform`.
fun array_enabled=(value: Bool)
do
if not is_active then return
glUseProgram program
self.array_enabled_cache = value
if value then
glEnableVertexAttribArray location
else glDisableVertexAttribArray location
end
# Define the `array` of vertex data
fun array(array: Array[Float], data_per_vertex: Int)
do
# TODO move this and native_float_array to a subclass specific to float
if not is_active then return
var native = native_float_array
if native == null or array.length > native.length then
if native != null then native.finalize
native = new GLfloatArray.from(array)
self.native_float_array = native
else
native.fill_from(array)
end
glVertexAttribPointer(location, data_per_vertex, gl_FLOAT, false, 0, native.native_array)
end
private var native_float_array: nullable GLfloatArray = null
end
lib/gamnit/programs.nit:62,1--107,3