How can I hook into OpenGL initialization on Windows?

I want hook all OpenGL games/applications. I want load my library only if application actually use OpenGL. Something like Direct3DCreate9 for Direct3D 9 or CreateDXGIFactory for Direct3D 10/11.

I thought this function wglDescribePixelFormat, but some app's/games not use it.

• So in short you only want to use GL when DirectX isn't available? – The Communist Duck Jul 5 '11 at 16:06
• 2 The Communist Duck, no I want hook GL and DirectX. I know when application start using Direct3D, but I don't know when it start using OpenGl. – KindDragon Jul 7 '11 at 15:00

wglCreateContex is what creates an OpenGL context on Windows, but it isn't the only way anymore. There is also wglCreateContextAttribARB, which is an extension function (and thus paradoxically means that you need to have created an OpenGL context already). This is used to create OpenGL 3.2+ core contexts.
I am not sure about it, but wglCreateContext seems to be the first one. PIXELFORMATDESCRIPTOR is a structure.