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

Method upload

src/main/java/field/graphics/Texture.java:192–237  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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++;

Callers 15

reloadFromMethod · 0.95
make_byte3Method · 0.45
make_float3Method · 0.45
make_byte1Method · 0.45
make_byte3_bufferMethod · 0.45
make_byte1_bufferMethod · 0.45
TextureLoaderMethod · 0.45
reloadMethod · 0.45
TextureLoaderMethod · 0.45
reloadMethod · 0.45
toTextureWhenReadyMethod · 0.45

Calls 15

getMethod · 0.95
logMethod · 0.95
checkErrorMethod · 0.95
setAllContextsForMethod · 0.80
glPixelStoreiMethod · 0.80
glBindTextureMethod · 0.80
glTexSubImage1DMethod · 0.80
glTexSubImage2DMethod · 0.80
getMethod · 0.65
positionMethod · 0.65
printlnMethod · 0.45
attachMethod · 0.45

Tested by

no test coverage detected