| 1639 | // See notes |
| 1640 | |
| 1641 | Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx) |
| 1642 | { |
| 1643 | Bool retval = False; const char *renderer = "Unknown"; |
| 1644 | faker::VirtualWin *vw; VGLFBConfig config = 0; |
| 1645 | |
| 1646 | if(faker::deadYet || faker::getFakerLevel() > 0) |
| 1647 | return _glXMakeCurrent(dpy, drawable, ctx); |
| 1648 | |
| 1649 | TRY(); |
| 1650 | |
| 1651 | // Find the FB config that was previously hashed to this context when it was |
| 1652 | // created. |
| 1653 | if(ctx) config = CTXHASH.findConfig(ctx); |
| 1654 | if(faker::isDisplayExcluded(dpy)) |
| 1655 | { |
| 1656 | faker::setGLXExcludeCurrent(true); |
| 1657 | faker::setOGLExcludeCurrent(true); |
| 1658 | return _glXMakeCurrent(dpy, drawable, ctx); |
| 1659 | } |
| 1660 | faker::setGLXExcludeCurrent(false); |
| 1661 | faker::setOGLExcludeCurrent(false); |
| 1662 | |
| 1663 | ///////////////////////////////////////////////////////////////////////////// |
| 1664 | OPENTRACE(glXMakeCurrent); PRARGD(dpy); PRARGX(drawable); PRARGX(ctx); |
| 1665 | STARTTRACE(); |
| 1666 | ///////////////////////////////////////////////////////////////////////////// |
| 1667 | |
| 1668 | DISABLE_FAKER(); |
| 1669 | |
| 1670 | // glXMakeCurrent() implies a glFinish() on the previous context, which is |
| 1671 | // why we read back the front buffer here if it is dirty. |
| 1672 | GLXDrawable curdraw = backend::getCurrentDrawable(); |
| 1673 | if(backend::getCurrentContext() && curdraw |
| 1674 | && (vw = WINHASH.find(NULL, curdraw)) != NULL) |
| 1675 | { |
| 1676 | faker::VirtualWin *newvw; |
| 1677 | if(drawable == 0 || !(newvw = WINHASH.find(dpy, drawable)) |
| 1678 | || newvw->getGLXDrawable() != curdraw) |
| 1679 | { |
| 1680 | if(DrawingToFront() || vw->dirty) |
| 1681 | vw->readback(GL_FRONT, false, fconfig.sync); |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | // If the drawable isn't a window, we pass it through unmodified, else we |
| 1686 | // map it to an off-screen drawable. |
| 1687 | int direct = CTXHASH.isDirect(ctx); |
| 1688 | if(dpy && drawable && ctx) |
| 1689 | { |
| 1690 | if(!config) |
| 1691 | { |
| 1692 | vglout.PRINTLN("[VGL] WARNING: glXMakeCurrent() called with a previously-destroyed context."); |
| 1693 | goto done; |
| 1694 | } |
| 1695 | try |
| 1696 | { |
| 1697 | vw = WINHASH.initVW(dpy, drawable, config); |
| 1698 | if(vw) |