I’m creating an OpenGL application on windows. I can’t use GLUT, because I would like to render to more than one window. I know how to do it by using wgl, but it is very messy and I would like to know what is happening under the hood.
In first place I have to create a window with desired pixel format. Than I connect this window to the OpenGL and everything is working. How does the driver know, where to render? Where are the window data stored? I’m looking for some kind of explanation, but I can’t find anything good.
WGL is as as “under the hood” as it gets. That is the interface for creating an OpenGL context from a HWND. You aren’t allowed to get any more low-level.
The device context, the HDC, is how rendering gets done on a HWND. Note that
wglMakeCurrenttakes a HDC, which does not have to be the HDC the context was created from (it simply must use the same pixel format). So “where to render” comes from that function.This stuff is all stored internally to Windows and the Windows Installable Client Driver model for OpenGL. You are not allowed to poke at it, modify it, or even look at it. You can simply use it.