let get_tex_byindex ind =
        let rec f map =
                match map with [] -> failwith "no texture with this index."
                | x::xs ->
                        let (mtex, mind) = x in
                        if mind = ind then mtex else f xs
        in f (!tex_index_map)