The code as shown hasn't done anything to set up a valid OpenGL context, so it can't use OpenGL.
How to do this varies by platform. If you don't want to dig down in your target platform's way of doing this, you can use something like GLFW to do it fairly portably, but of course that adds a dependency.