this operates asynchronously if we are not currently inside the draw loop (that is, if there is no valid context for our thread). only one debug download can be pending at a time. You can pass in null to this routine and you'll get a correctly sized ByteByffer back that you can reuse for subsequent
(ByteBuffer to)
| 673 | if (to == null || !to.isDirect() || to.limit() < sz) { |
| 674 | ato = ByteBuffer.allocateDirect(sz); |
| 675 | } else ato = to; |
| 676 | |
| 677 | CompletableFuture<ByteBuffer> c = new CompletableFuture<ByteBuffer>() { |
| 678 | @Override |
| 679 | public ByteBuffer get() throws InterruptedException, ExecutionException { |
| 680 | if (!isDone()) return ato; |
| 681 | return super.get(); |
| 682 | } |
| 683 | }; |
| 684 | Runnable r = () -> { |
| 685 | int[] a = {0}; |
| 686 | a[0] = glGetInteger(GL_FRAMEBUFFER_BINDING); |
| 687 | glBindFramebuffer(GL_FRAMEBUFFER, getOpenGLFrameBufferNameInCurrentContext()); |
| 688 | glReadPixels(0, 0, specification.width, specification.height, GL11.GL_RGB, GL_UNSIGNED_BYTE, ato); |
| 689 | glBindFramebuffer(GL_FRAMEBUFFER, a[0]); |
| 690 | c.complete(ato); |
| 691 | }; |
| 692 | |
| 693 | if (GraphicsContext.getContext() == null) { |
| 694 | postDrawQueue.set(r); |
| 695 | } else { |
| 696 | r.run(); |
| 697 | } |
| 698 | |
| 699 | return c; |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * this operates asynchronously if we are not currently inside the draw loop (that is, if there is no valid context for our thread). only one debug download can be pending at a time. You can |
| 704 | * pass in null to this routine and you'll get a correctly sized ByteBuffer back that you can reuse for subsequent calls. Regardless of the original format of the FBO this always returns |
| 705 | * something that's RGBA / float,. |
| 706 | */ |
| 707 | public Future<FloatBuffer> asyncDebugDownloadRGBAFloat(FloatBuffer to) { |
| 708 | FloatBuffer ato; |
| 709 |
no test coverage detected