| 1763 | |
| 1764 | |
| 1765 | Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, |
| 1766 | GLXContext ctx) |
| 1767 | { |
| 1768 | Bool retval = False; const char *renderer = "Unknown"; |
| 1769 | faker::VirtualWin *vw; VGLFBConfig config = 0; |
| 1770 | |
| 1771 | if(faker::deadYet || faker::getFakerLevel() > 0) |
| 1772 | return _glXMakeContextCurrent(dpy, draw, read, ctx); |
| 1773 | |
| 1774 | TRY(); |
| 1775 | |
| 1776 | if(ctx) config = CTXHASH.findConfig(ctx); |
| 1777 | if(faker::isDisplayExcluded(dpy)) |
| 1778 | { |
| 1779 | faker::setGLXExcludeCurrent(true); |
| 1780 | faker::setOGLExcludeCurrent(true); |
| 1781 | return _glXMakeContextCurrent(dpy, draw, read, ctx); |
| 1782 | } |
| 1783 | faker::setGLXExcludeCurrent(false); |
| 1784 | faker::setOGLExcludeCurrent(false); |
| 1785 | |
| 1786 | ///////////////////////////////////////////////////////////////////////////// |
| 1787 | OPENTRACE(glXMakeContextCurrent); PRARGD(dpy); PRARGX(draw); PRARGX(read); |
| 1788 | PRARGX(ctx); STARTTRACE(); |
| 1789 | ///////////////////////////////////////////////////////////////////////////// |
| 1790 | |
| 1791 | DISABLE_FAKER(); |
| 1792 | |
| 1793 | // glXMakeContextCurrent() implies a glFinish() on the previous context, |
| 1794 | // which is why we read back the front buffer here if it is dirty. |
| 1795 | GLXDrawable curdraw = backend::getCurrentDrawable(); |
| 1796 | if(backend::getCurrentContext() && curdraw |
| 1797 | && (vw = WINHASH.find(NULL, curdraw)) != NULL) |
| 1798 | { |
| 1799 | faker::VirtualWin *newvw; |
| 1800 | if(draw == 0 || !(newvw = WINHASH.find(dpy, draw)) |
| 1801 | || newvw->getGLXDrawable() != curdraw) |
| 1802 | { |
| 1803 | if(DrawingToFront() || vw->dirty) |
| 1804 | vw->readback(GL_FRONT, false, fconfig.sync); |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | // If the drawable isn't a window, we pass it through unmodified, else we |
| 1809 | // map it to an off-screen drawable. |
| 1810 | faker::VirtualWin *drawVW, *readVW; |
| 1811 | int direct = CTXHASH.isDirect(ctx); |
| 1812 | if(dpy && (draw || read) && ctx) |
| 1813 | { |
| 1814 | if(!config) |
| 1815 | { |
| 1816 | vglout.PRINTLN("[VGL] WARNING: glXMakeContextCurrent() called with a previously-destroyed context"); |
| 1817 | goto done; |
| 1818 | } |
| 1819 | try |
| 1820 | { |
| 1821 | bool differentReadDrawable = (read && read != draw); |
| 1822 | |