Best place to initialize GLFW?

Hey there, I recently got into OpenGL, and I started trying out some stuff with it, alongside GLFW and GLEW.

While looking at most exmaples on this (and other) websites, I notice they all show initialization of GLFW right in the main function. This is obviously for demonstration purposes and not a good idea to do on an actual project, so I was wondering where would it be best to do this initialization?

PS: In my application I have a seprate Window class and I am doing my initialization there, but that kinda couples my Window class with GLFW initialization, which I also want to avoid.

What do you guys think, where it might be the best way to initGLFW() ?

There’s nothing wrong with initialising GLFW in your main function - indeed it’s generally good practice to initialise required functionality early, though if you have a lot of functionality to initialise you may want to do so in a separate function.

You’ll probably want to init logging first if you have that, and any functionality you need to report to the user an error in performing an init (for example with something like the cross platform dialogue Boxer ).