| 2611 | } |
| 2612 | |
| 2613 | void Viewer::captureUIScreenShot( std::function<void( const Image& )> callback, |
| 2614 | const Vector2i& pos /*= Vector2i()*/, const Vector2i& sizeP /*= Vector2i() */ ) |
| 2615 | { |
| 2616 | CommandLoop::appendCommand( [callback, pos, sizeP, this] () |
| 2617 | { |
| 2618 | Vector2i size = sizeP; |
| 2619 | if ( !size.x ) |
| 2620 | size.x = framebufferSize.x - pos.x; |
| 2621 | else |
| 2622 | size.x = std::min( framebufferSize.x - pos.x, size.x ); |
| 2623 | |
| 2624 | if ( !size.y ) |
| 2625 | size.y = framebufferSize.y - pos.y; |
| 2626 | else |
| 2627 | size.y = std::min( framebufferSize.y - pos.y, size.y ); |
| 2628 | |
| 2629 | Image image; |
| 2630 | image.resolution = size; |
| 2631 | image.pixels.resize( size.x * size.x ); |
| 2632 | |
| 2633 | if ( glInitialized_ ) |
| 2634 | { |
| 2635 | GL_EXEC( glReadPixels( pos.x, pos.y, size.x, size.y, GL_RGBA, GL_UNSIGNED_BYTE, ( void* ) ( image.pixels.data() ) ) ); |
| 2636 | |
| 2637 | callback( image ); |
| 2638 | } |
| 2639 | } ); |
| 2640 | } |
| 2641 | |
| 2642 | bool Viewer::isAlphaSortAvailable() const |
| 2643 | { |
no test coverage detected