| 855 | // take that opportunity to resize the off-screen drawable. |
| 856 | |
| 857 | void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 858 | { |
| 859 | if(faker::getOGLExcludeCurrent()) |
| 860 | { |
| 861 | _glViewport(x, y, width, height); return; |
| 862 | } |
| 863 | |
| 864 | TRY(); |
| 865 | |
| 866 | if(faker::getEGLXContextCurrent()) |
| 867 | { |
| 868 | /////////////////////////////////////////////////////////////////////////// |
| 869 | OPENTRACE(glViewport); PRARGI(x); PRARGI(y); PRARGI(width); |
| 870 | PRARGI(height); STARTTRACE(); |
| 871 | /////////////////////////////////////////////////////////////////////////// |
| 872 | |
| 873 | EGLContext ctx = _eglGetCurrentContext(); |
| 874 | EGLSurface draw = _eglGetCurrentSurface(EGL_DRAW); |
| 875 | EGLSurface read = _eglGetCurrentSurface(EGL_READ); |
| 876 | faker::EGLXDisplay *eglxdpy = faker::getCurrentEGLXDisplay(); |
| 877 | EGLSurface newRead = 0, newDraw = 0; |
| 878 | |
| 879 | if(eglxdpy && (draw || read) && ctx) |
| 880 | { |
| 881 | newRead = read, newDraw = draw; |
| 882 | faker::EGLXVirtualWin *drawEGLXVW = |
| 883 | EGLXWINHASH.findInternal(eglxdpy, draw); |
| 884 | faker::EGLXVirtualWin *readEGLXVW = |
| 885 | EGLXWINHASH.findInternal(eglxdpy, read); |
| 886 | if(drawEGLXVW) drawEGLXVW->checkResize(); |
| 887 | if(readEGLXVW && readEGLXVW != drawEGLXVW) readEGLXVW->checkResize(); |
| 888 | if(drawEGLXVW) newDraw = (EGLSurface)drawEGLXVW->updateGLXDrawable(); |
| 889 | if(readEGLXVW) newRead = (EGLSurface)readEGLXVW->updateGLXDrawable(); |
| 890 | if(newRead != read || newDraw != draw) |
| 891 | { |
| 892 | _eglMakeCurrent(eglxdpy->edpy, 0, 0, 0); |
| 893 | if(!_eglMakeCurrent(eglxdpy->edpy, newDraw, newRead, ctx)) |
| 894 | THROW_EGL("eglMakeCurrent()"); |
| 895 | if(drawEGLXVW) { drawEGLXVW->clear(); drawEGLXVW->cleanup(); } |
| 896 | if(readEGLXVW) readEGLXVW->cleanup(); |
| 897 | } |
| 898 | } |
| 899 | _glViewport(x, y, width, height); |
| 900 | |
| 901 | /////////////////////////////////////////////////////////////////////////// |
| 902 | STOPTRACE(); |
| 903 | if(draw != newDraw) { PRARGX(draw); PRARGX(newDraw); } |
| 904 | if(read != newRead) { PRARGX(read); PRARGX(newRead); } |
| 905 | CLOSETRACE(); |
| 906 | /////////////////////////////////////////////////////////////////////////// |
| 907 | } |
| 908 | else |
| 909 | { |
| 910 | /////////////////////////////////////////////////////////////////////////// |
| 911 | OPENTRACE(glViewport); PRARGI(x); PRARGI(y); PRARGI(width); |
| 912 | PRARGI(height); STARTTRACE(); |
| 913 | /////////////////////////////////////////////////////////////////////////// |
| 914 | |