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

Method uploadLayer

src/main/java/field/graphics/Texture.java:336–381  ·  view source on GitHub ↗
(ByteBuffer upload, boolean stream, int z)

Source from the content-addressed store, hash-verified

334 Log.log("texture.trace",
335 () -> "upload, part 1, for texture " + this + " " + s + " " + upload.capacity() + " ");
336
337 if (s == null) return;
338 s.x0 = 0;
339 s.x1 = specification.width;
340 s.y0 = 0;
341 s.y1 = specification.height;
342 s.z = z;
343 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, isDoubleBuffered ? (stream ? s.pboA : s.pboB) : s.pbo);
344 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
345 glPixelStorei(GL_UNPACK_ROW_LENGTH, specification.width);
346
347 int start = 0;
348 int end = specification.elementSize * specification.width*specification.height;
349 s.old = glMapBufferRange(GL21.GL_PIXEL_UNPACK_BUFFER, start, end - start,
350 GL30.GL_MAP_WRITE_BIT | GL30.GL_MAP_INVALIDATE_RANGE_BIT | GL30.GL_MAP_UNSYNCHRONIZED_BIT,
351 s.old);
352
353 s.old.position(0);
354 upload.clear();
355 s.old.limit(end - start);
356 upload.limit(end - start);
357
358 s.old.put(upload);
359
360 upload.clear();
361 upload.rewind();
362 s.old.clear();
363 s.old.rewind();
364
365 bytesUploaded += s.old.limit();
366
367 GL15.glUnmapBuffer(GL21.GL_PIXEL_UNPACK_BUFFER);
368 GL15.glBindBuffer(GL21.GL_PIXEL_UNPACK_BUFFER, 0);
369 Log.log("graphics.trace", () -> "uploaded part 1");
370 s.mod++;
371 }, -2)/*.setOnceOnly()*/.setAllContextsFor(this));
372 }
373
374 public int getPendingUploads() {
375 return pendingUploads.get();
376 }
377
378 protected boolean perform0() {
379
380 State s = GraphicsContext.get(this);
381
382 Log.log("graphics.trace", () -> "activating texture :" + specification.unit + " = " + s.name);
383
384 glActiveTexture(GL_TEXTURE0 + specification.unit);

Callers

nothing calls this directly

Calls 10

getMethod · 0.95
logMethod · 0.95
setAllContextsForMethod · 0.80
glPixelStoreiMethod · 0.80
positionMethod · 0.65
toStringMethod · 0.45
attachMethod · 0.45
clearMethod · 0.45
limitMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected