| 1027 | |
| 1028 | |
| 1029 | void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, |
| 1030 | GLenum type, void *data) |
| 1031 | { |
| 1032 | if(fconfig.egl) |
| 1033 | { |
| 1034 | bool fallthrough = true; |
| 1035 | VGLFBConfig config = CTXHASHEGL.findConfig(_eglGetCurrentContext()); |
| 1036 | FakePbuffer *readpb = getCurrentFakePbuffer(EGL_READ); |
| 1037 | |
| 1038 | if(config && config->attr.samples > 1 && readpb) |
| 1039 | { |
| 1040 | GLuint fbo = 0, rbo = 0; |
| 1041 | _glGenFramebuffers(1, &fbo); |
| 1042 | if(fbo) |
| 1043 | { |
| 1044 | BufferState bs(BS_DRAWFBO | BS_READFBO | BS_DRAWBUFS | BS_READBUF); |
| 1045 | _glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); |
| 1046 | |
| 1047 | _glGenRenderbuffers(1, &rbo); |
| 1048 | if(rbo) |
| 1049 | { |
| 1050 | BufferState bsRBO(BS_RBO); |
| 1051 | _glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 1052 | |
| 1053 | GLenum internalFormat = GL_RGB8; |
| 1054 | if(config->attr.redSize > 8) internalFormat = GL_RGB10_A2; |
| 1055 | else if(config->attr.alphaSize) internalFormat = GL_RGBA8; |
| 1056 | _glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, |
| 1057 | readpb->getWidth(), readpb->getHeight()); |
| 1058 | _glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 1059 | GL_RENDERBUFFER, rbo); |
| 1060 | |
| 1061 | GLenum status = _glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); |
| 1062 | if(status == GL_FRAMEBUFFER_COMPLETE) |
| 1063 | { |
| 1064 | _glBlitFramebuffer(0, 0, readpb->getWidth(), readpb->getHeight(), |
| 1065 | 0, 0, readpb->getWidth(), readpb->getHeight(), |
| 1066 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1067 | _glBindFramebuffer(GL_DRAW_FRAMEBUFFER, bs.getOldReadFBO()); |
| 1068 | _glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); |
| 1069 | _glReadPixels(x, y, width, height, format, type, data); |
| 1070 | fallthrough = false; |
| 1071 | } |
| 1072 | _glDeleteRenderbuffers(1, &rbo); |
| 1073 | } |
| 1074 | _glDeleteFramebuffers(1, &fbo); |
| 1075 | } |
| 1076 | } |
| 1077 | if(!fallthrough) return; |
| 1078 | } |
| 1079 | _glReadPixels(x, y, width, height, format, type, data); |
| 1080 | } |
| 1081 | |
| 1082 | |
| 1083 | void swapBuffers(Display *dpy, GLXDrawable drawable) |
no test coverage detected