gamnit :: Attribute :: defaultinit
# 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