redef fun draw_selection_texture(actor, model)
do
var program = app.selection_program
var mesh = model.mesh
# One of the textures used, if any
var sample_used_texture = null
var texture = diffuse_texture
if texture != null then
glActiveTexture gl_TEXTURE1
glBindTexture(gl_TEXTURE_2D, texture.gl_texture)
program.use_map_diffuse.uniform true
program.map_diffuse.uniform 1
sample_used_texture = texture
else
program.use_map_diffuse.uniform false
end
# If using a texture, set `texture_coords`
program.tex_coord.array_enabled = sample_used_texture != null
if sample_used_texture != null then
if sample_used_texture isa RootTexture then
# Coordinates are directly valid
program.tex_coord.array(mesh.texture_coords, 2)
else
# Correlate texture coordinates from the subtexture sand the mesh.
# This is slow, but should be cached on the GPU.
var xa = sample_used_texture.offset_left
var xd = sample_used_texture.offset_right - xa
var ya = sample_used_texture.offset_top
var yd = sample_used_texture.offset_bottom - ya
var tex_coords = new Array[Float].with_capacity(mesh.texture_coords.length)
for i in [0..mesh.texture_coords.length/2[ do
tex_coords[i*2] = xa + xd * mesh.texture_coords[i*2]
tex_coords[i*2+1] = ya + yd * mesh.texture_coords[i*2+1]
end
program.tex_coord.array(tex_coords, 2)
end
end
end
lib/gamnit/depth/selection.nit:192,2--233,4