diff --git a/src/main/cpp/gl/texture.cpp b/src/main/cpp/gl/texture.cpp index d354277..b38b981 100644 --- a/src/main/cpp/gl/texture.cpp +++ b/src/main/cpp/gl/texture.cpp @@ -793,17 +793,18 @@ void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void* glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadBuffer(GL_COLOR_ATTACHMENT0); -// if (format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 || type == GL_UNSIGNED_INT_8_8_8_8_REV)) { -// void *read_pixels = malloc(width * height * 4); -// glReadPixels(0, 0, width, height, format, type, read_pixels); -// pixel_convert(read_pixels, &pixels, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, GL_UNSIGNED_BYTE, 0, 1); -// free(read_pixels); -// } else { -// glReadPixels(0, 0, width, height, format, type, pixels); -// } + if (pixels != NULL && format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 || type == GL_UNSIGNED_INT_8_8_8_8_REV)) { + void *read_pixels = malloc(width * height * 4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, read_pixels); + pixel_convert(read_pixels, &pixels, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, GL_UNSIGNED_BYTE, 0, 1); + free(read_pixels); + } else { + glReadPixels(0, 0, width, height, format, type, pixels); + } - glReadPixels(0, 0, width, height, format, type, pixels); +// glReadPixels(0, 0, width, height, format, type, pixels); + glPixelStorei(GL_PACK_ALIGNMENT, oldPackAlignment); glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]); glDeleteFramebuffers(1, &fbo);