void Context::draw(HDC hdc) { HGLRC oldctx = owglGetCurrentContext(); HDC oldhdc = owglGetCurrentDC(); owglMakeCurrent(hdc, ctx); doDraw(hdc); owglMakeCurrent(oldhdc, oldctx); }
Context::Context(HDC hdc) { timeT = clock(); frameCount = 0; texture = ~0; ctx = owglCreateContext(hdc); HGLRC oldctx = owglGetCurrentContext(); HDC oldhdc = owglGetCurrentDC(); owglMakeCurrent(hdc, ctx); initContext(); owglMakeCurrent(oldhdc, oldctx); }
static void doSwap(HDC hdc) { HGLRC oldctx = owglGetCurrentContext(); HDC oldhdc = owglGetCurrentDC(); Context *c = contexts[hdc]; if (!c) { ods("OpenGL: New context for device %p", hdc); c = new Context(hdc); contexts[hdc] = c; } else { ods("OpenGL: Reusing old context"); owglMakeCurrent(hdc, c->ctx); } c->draw(hdc); owglMakeCurrent(oldhdc, oldctx); }