(Box inside, Dict.Prop property)
| 52 | |
| 53 | int boundCount = 0; |
| 54 | |
| 55 | @Override |
| 56 | public String generateMarkdown(Box inside, Dict.Prop property) { |
| 57 | Future<ByteBuffer> m = asyncDebugDownloadRGB8(null); |
| 58 | |
| 59 | // repaint main window, just in case we're there |
| 60 | RunLoop.main.once(() -> { |
| 61 | Drawing.dirty(inside); |
| 62 | }); |
| 63 | |
| 64 | String pre |
| 65 | = "Framebuffer object has dimensions <b>" + specification.width + "</b>x<b>" + specification.height + "</b> and is bound to texture unit <b>" + specification.unit + "</b" + |
| 66 | "><br>"; |
| 67 | if (specification.multisample) pre += "Multisampling is turned on; "; |
| 68 | if (specification.depth) |
| 69 | pre += "There is a depth render-buffer associated with this framebuffer; "; |
| 70 | if (specification.internalFormat == GL_RGBA32F) |
| 71 | pre += "This is a floating-point resolution buffer; "; |
| 72 | if (specification.layers != 1) |
| 73 | pre += "This is a multi-layer (<b>" + specification.layers + "</b> layers) buffer; "; |
| 74 | pre += "It has drawn its internalScene <b>" + warnIfZero( |
| 75 | drawCount) + "</b> time" + (drawCount == 1 ? "" : "s") + (drawCount == 0 ? "</b>(are you sure .draw() is being called)" : "") + " and it has been bound as a texture <b>" + warnIfZero( |
| 76 | boundCount) + "</b> time" + (boundCount == 1 ? "" : "s") + "<br>"; |
| 77 | |
| 78 | int tries = 0; |
| 79 | while (!m.isDone()) { |
| 80 | try { |
| 81 | Thread.sleep(100 * tries); |
| 82 | } catch (InterruptedException e) { |
| 83 | e.printStackTrace(); |
| 84 | } |
| 85 | if (++tries > 5) |
| 86 | return pre + "<b>Image data for FBO is not available (FBO must be actively repainting)<b>"; |
| 87 | } |
| 88 | |
| 89 | try { |
| 90 | |
| 91 | File tmp = File.createTempFile("field", ".jpg"); |
| 92 | new FastJPEG().compress(tmp.getAbsolutePath(), m.get(), specification.width, specification.height); |
| 93 | byte[] bytes = Files.readAllBytes(tmp.toPath()); |
| 94 | java.util.Base64.Encoder e = java.util.Base64.getEncoder(); |
| 95 | String v = e.encodeToString(bytes); |
| 96 | |
| 97 | String uri = "data:image/jpg;base64," + v; |
| 98 | String d = "<b>Snapshot of contents —<br><img style='max-width:300px' src='" + uri + "'/></b>"; |
| 99 | |
| 100 | return pre + d; |
| 101 | |
| 102 | } catch (InterruptedException e) { |
| 103 | e.printStackTrace(); |
| 104 | } catch (ExecutionException e) { |
| 105 | e.printStackTrace(); |
| 106 | } catch (IOException e) { |
| 107 | e.printStackTrace(); |
| 108 | } |
| 109 | |
| 110 | return "<b>Image data for FBO is not available (there was an error fetching it)<b>"; |
| 111 |
nothing calls this directly
no test coverage detected