make gen_texture/del_texture thread safe

Use stack allocated variables instead of static ones