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); }
Context::Context(HDC hdc) { timeT = clock(); frameCount = 0; ctx = owglCreateContext(hdc); owglMakeCurrent(hdc, ctx); // Here we go. From the top. Where is glResetState? oglDisable(GL_ALPHA_TEST); oglDisable(GL_AUTO_NORMAL); oglEnable(GL_BLEND); // Skip clip planes, there are thousands of them. oglDisable(GL_COLOR_LOGIC_OP); oglDisable(GL_COLOR_MATERIAL); oglDisable(GL_COLOR_TABLE); oglDisable(GL_CONVOLUTION_1D); oglDisable(GL_CONVOLUTION_2D); oglDisable(GL_CULL_FACE); oglDisable(GL_DEPTH_TEST); oglDisable(GL_DITHER); oglDisable(GL_FOG); oglDisable(GL_HISTOGRAM); oglDisable(GL_INDEX_LOGIC_OP); oglDisable(GL_LIGHTING); // Skip line smmooth // Skip map oglDisable(GL_MINMAX); // Skip polygon offset oglDisable(GL_SEPARABLE_2D); oglDisable(GL_SCISSOR_TEST); oglDisable(GL_STENCIL_TEST); oglEnable(GL_TEXTURE_2D); oglDisable(GL_TEXTURE_GEN_Q); oglDisable(GL_TEXTURE_GEN_R); oglDisable(GL_TEXTURE_GEN_S); oglDisable(GL_TEXTURE_GEN_T); oglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); texture = ~0; }