schedules an upload from this bytebuffer to this texture during the next drawn. Set stream to true to hint to OpenGL that you mean to keep on doing this.
(ByteBuffer upload, boolean stream)
| 190 | public Texture makeBindless() { |
| 191 | bindless = true; |
| 192 | return this; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * schedules an upload from this bytebuffer to this texture during the next drawn. Set stream to true to hint to OpenGL that you mean to keep on doing this. |
| 197 | */ |
| 198 | public void upload(ByteBuffer upload, boolean stream) { |
| 199 | if (pendingUploads.get()>10) { |
| 200 | System.out.println(" too many pending uploads ("+pendingUploads.get()+"), skipping "); |
| 201 | // return; |
| 202 | // pendingUploads.set(0); |
| 203 | } |
| 204 | pendingUploads.incrementAndGet(); |
| 205 | |
| 206 | attach(new Transient(() -> { |
| 207 | pendingUploads.decrementAndGet(); |
| 208 | |
| 209 | // System.out.println(" uploading ??"); |
| 210 | |
| 211 | State s = GraphicsContext.get(this, null); |
| 212 | |
| 213 | Log.log("graphics.trace", () -> "state for texture in upload is " + s); |
| 214 | Log.log("texture.trace", () -> "upload, part 1, for texture " + this + " " + s + " " + upload.capacity()); |
| 215 | |
| 216 | if (s == null) return; |
| 217 | |
| 218 | s.x0 = 0; |
| 219 | s.x1 = specification.width; |
| 220 | s.y0 = 0; |
| 221 | s.y1 = specification.height; |
| 222 | |
| 223 | Log.log("graphics.trace", () -> "uploading "); |
| 224 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, isDoubleBuffered ? (stream ? s.pboA : s.pboB) : s.pbo); |
| 225 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 226 | // glPixelStorei(GL_UNPACK_ROW_LENGTH, specification.width); |
| 227 | s.old = GL15.glMapBuffer(GL21.GL_PIXEL_UNPACK_BUFFER, GL15.GL_WRITE_ONLY, s.old); |
| 228 | s.old.rewind(); |
| 229 | upload.rewind(); |
| 230 | upload.limit(s.old.limit()); |
| 231 | s.old.put(upload); |
| 232 | upload.clear(); |
| 233 | upload.rewind(); |
| 234 | s.old.rewind(); |
| 235 | |
| 236 | bytesUploaded += s.old.limit(); |
| 237 | GL15.glUnmapBuffer(GL21.GL_PIXEL_UNPACK_BUFFER); |
| 238 | GL15.glBindBuffer(GL21.GL_PIXEL_UNPACK_BUFFER, 0); |
| 239 | Log.log("graphics.trace", () -> "uploaded part 1"); |
| 240 | s.mod++; |
no test coverage detected