MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / asyncDebugDownloadRGB8

Method asyncDebugDownloadRGB8

src/main/java/field/graphics/FBO.java:675–706  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

generateMarkdownMethod · 0.95

Calls 8

getContextMethod · 0.95
glGetIntegerMethod · 0.80
glReadPixelsMethod · 0.80
setMethod · 0.65
limitMethod · 0.45
completeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected