OGL and DirectX (Direct3D) are just hardware wrapper libraries. OGL also has extensions that can access the same stuff DX11 does. Code wise they look similar with some minor differences (column vs row matrices, different function names, and I think their shaders are done differently... I have only coded OpenGL).

Most engines are built so the low level stuff (setting up the shaders and sending the verts to the GPU side) is decoupled from the general high level stuff (the game code), so that porting between platforms is easier.