wglDeleteContext(hglrc);
}
}
+
+ bool
+ create(WglDrawable *wglDrawable) {
+ if (!hglrc) {
+ hglrc = wglCreateContext(wglDrawable->hDC);
+ if (!hglrc) {
+ std::cerr << "error: wglCreateContext failed\n";
+ exit(1);
+ return false;
+ }
+ if (shareContext) {
+ if (shareContext->create(wglDrawable)) {
+ BOOL bRet;
+ bRet = wglShareLists(shareContext->hglrc,
+ hglrc);
+ if (!bRet) {
+ std::cerr
+ << "warning: wglShareLists failed: "
+ << std::hex << GetLastError() << std::dec
+ << "\n";
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
};
WglDrawable *wglDrawable = static_cast<WglDrawable *>(drawable);
WglContext *wglContext = static_cast<WglContext *>(context);
- if (!wglContext->hglrc) {
- wglContext->hglrc = wglCreateContext(wglDrawable->hDC);
- if (!wglContext->hglrc) {
- std::cerr << "error: wglCreateContext failed\n";
- exit(1);
- return false;
- }
- if (wglContext->shareContext) {
- BOOL bRet;
- bRet = wglShareLists(wglContext->shareContext->hglrc,
- wglContext->hglrc);
- if (!bRet) {
- std::cerr << "warning: wglShareLists failed\n";
- }
- }
- }
+ wglContext->create(wglDrawable);
return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc);
}