Great.
Now create an empty project with no link to SFML, and try this code:
#include <windows.h>
#include <GL/gl.h>
#include <cassert>
class Context
{
public :
Context(Context* shared = NULL) :
myWindow (NULL),
myDeviceContext(NULL),
myContext (NULL)
{
myWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
assert(myWindow != NULL);
ShowWindow(myWindow, SW_HIDE);
myDeviceContext = GetDC(myWindow);
assert(myDeviceContext != NULL);
CreateContext(shared);
assert(myContext != NULL);
MakeCurrent();
}
~Context()
{
if (wglGetCurrentContext() == myContext)
wglMakeCurrent(NULL, NULL);
wglDeleteContext(myContext);
ReleaseDC(myWindow, myDeviceContext);
DestroyWindow(myWindow);
}
private :
void MakeCurrent()
{
if (wglGetCurrentContext() != myContext)
wglMakeCurrent(myDeviceContext, myContext);
}
void CreateContext(Context* shared)
{
PIXELFORMATDESCRIPTOR descriptor;
ZeroMemory(&descriptor, sizeof(descriptor));
descriptor.nSize = sizeof(descriptor);
descriptor.nVersion = 1;
descriptor.iLayerType = PFD_MAIN_PLANE;
descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
descriptor.iPixelType = PFD_TYPE_RGBA;
descriptor.cColorBits = 32;
descriptor.cDepthBits = 24;
descriptor.cStencilBits = 8;
int format = ChoosePixelFormat(myDeviceContext, &descriptor);
assert(format != 0);
PIXELFORMATDESCRIPTOR desc;
desc.nSize = sizeof(desc);
desc.nVersion = 1;
int ok = SetPixelFormat(myDeviceContext, format, &desc);
assert(ok != 0);
myContext = wglCreateContext(myDeviceContext);
assert(myContext != NULL);
HGLRC sharedContext = shared ? shared->myContext : NULL;
if (sharedContext)
{
ok = wglShareLists(sharedContext, myContext);
assert(ok != 0);
}
}
HWND myWindow;
HDC myDeviceContext;
HGLRC myContext;
};
Context c1;
Context c2(&c1);
int main()
{
Context c3(&c1);
return 0;
}