Does UE4 use directx or opengl?

Do you mean the Editor? If not, modern game engines use all off them GL, GLES, GLES2, DirectX9, DirectX11…etc. Also editor probably configurable.