| 750 | |
| 751 | |
| 752 | Bool makeCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, |
| 753 | GLXContext ctx) |
| 754 | { |
| 755 | if(fconfig.egl) |
| 756 | { |
| 757 | try |
| 758 | { |
| 759 | if(!_eglBindAPI(EGL_OPENGL_API)) |
| 760 | THROW("Could not enable OpenGL API"); |
| 761 | EGLBoolean ret = (Bool)_eglMakeCurrent(EDPY, EGL_NO_SURFACE, |
| 762 | EGL_NO_SURFACE, (EGLContext)ctx); |
| 763 | if(!ret) THROW_EGL("eglMakeCurrent()"); |
| 764 | setCurrentContextEGL(ctx); |
| 765 | setCurrentDrawableEGL(draw); |
| 766 | setCurrentReadDrawableEGL(read); |
| 767 | if(!ctx) |
| 768 | { |
| 769 | _eglReleaseThread(); |
| 770 | return True; |
| 771 | } |
| 772 | |
| 773 | FakePbuffer *drawpb = NULL, *readpb = NULL; |
| 774 | drawpb = PBHASHEGL.find(draw); |
| 775 | readpb = (read == draw ? drawpb : PBHASHEGL.find(read)); |
| 776 | GLint drawFBO = -1, readFBO = -1; |
| 777 | _glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFBO); |
| 778 | _glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFBO); |
| 779 | |
| 780 | if(drawpb) |
| 781 | drawpb->createBuffer(false, true, |
| 782 | (CTXHASHEGL.getDrawFBO(ctx) == 0 || drawFBO == 0), |
| 783 | (CTXHASHEGL.getReadFBO(ctx) == 0 || readFBO == 0)); |
| 784 | if(readpb && readpb != drawpb) |
| 785 | readpb->createBuffer(false, true, |
| 786 | (CTXHASHEGL.getDrawFBO(ctx) == 0 || drawFBO == 0), |
| 787 | (CTXHASHEGL.getReadFBO(ctx) == 0 || readFBO == 0)); |
| 788 | |
| 789 | bool boundNewDrawFBO = false, boundNewReadFBO = false; |
| 790 | if(drawpb && (CTXHASHEGL.getDrawFBO(ctx) == 0 || drawFBO == 0)) |
| 791 | { |
| 792 | _glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawpb->getFBO()); |
| 793 | boundNewDrawFBO = true; |
| 794 | } |
| 795 | if(readpb && (CTXHASHEGL.getReadFBO(ctx) == 0 || readFBO == 0)) |
| 796 | { |
| 797 | _glBindFramebuffer(GL_READ_FRAMEBUFFER, readpb->getFBO()); |
| 798 | boundNewReadFBO = true; |
| 799 | } |
| 800 | |
| 801 | VGLFBConfig config = CTXHASHEGL.findConfig(ctx); |
| 802 | if(drawpb) |
| 803 | { |
| 804 | if(drawFBO == 0 && config) |
| 805 | { |
| 806 | drawpb->setDrawBuffer(config->attr.doubleBuffer ? |
| 807 | GL_BACK : GL_FRONT, false); |
| 808 | _glViewport(0, 0, drawpb->getWidth(), drawpb->getHeight()); |
| 809 | } |
no test coverage detected