make gen_texture/del_texture threadsafe

Use stack allocated instead of static variables