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

Method draw

src/main/java/field/graphics/FBO.java:431–554  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

429 try (Util.ExceptionlessAutoClosable st = GraphicsContext.getContext().stateTracker.save()) {
430
431 State s = GraphicsContext.get(this, this::setup);
432
433 GraphicsContext.checkError(() -> "prior to fbo");
434 GraphicsContext.getContext().stateTracker.fbo.set(specification.multisample ? s.multisample : s.name);
435
436 currentFBO.set(this);
437
438 int[] v = {(int) viewport.x, (int) viewport.y, (int) viewport.w, (int) viewport.h};
439
440 GraphicsContext.checkError(() -> "prior to scissor");
441 GraphicsContext.getContext().stateTracker.scissor.set(v);
442
443 GraphicsContext.checkError(() -> "prior to viewport");
444 GraphicsContext.getContext().stateTracker.viewport.set(v);
445
446 if (sbsStereoViewport) {
447 GraphicsContext.getContext().stateTracker.viewport.set(v);
448 GL41.glViewportIndexedf(1, viewport.x, viewport.y, viewport.w / 2, viewport.h);
449 GL41.glViewportIndexedf(2, viewport.x + viewport.w / 2, viewport.y, viewport.w / 2, viewport.h);
450 GL41.glScissorIndexed(0, (int) viewport.x, (int) viewport.y, (int) viewport.w, (int) viewport.h);
451 GL41.glScissorIndexed(1, (int) viewport.x, (int) viewport.y, (int) viewport.w / 2, (int) viewport.h);
452 GL41.glScissorIndexed(2, (int) viewport.x + (int) viewport.w / 2, (int) viewport.y, (int) viewport.w / 2, (int) viewport.h);
453 glEnablei(GL_SCISSOR_TEST, 1);
454 glEnablei(GL_SCISSOR_TEST, 2);
455 }
456
457
458 GraphicsContext.checkError(() -> "prior to debug red");
459 int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
460 if (status != GL_FRAMEBUFFER_COMPLETE)
461 throw new IllegalArgumentException(" bad status, " + status + " on " + s.name);
462
463// else System.out.println(" FBO "+s.name+" is confirmed complete in draw method");
464
465 if (specification.internalFormat == GL21.GL_SRGB8_ALPHA8) {
466 glEnable(GL_FRAMEBUFFER_SRGB);
467 }
468
469 if (specification.overrideTextureID != -1) {
470 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, specification.overrideTextureID, 0);
471 }
472
473 if (specification.multisample) {
474 glEnable(GL_MULTISAMPLE);
475 }
476
477 if (specification.num == 1)
478 glDrawBuffer(GL_COLOR_ATTACHMENT0);
479 else {
480// int[] bufs = new int[specification.num];
481 var bufs = ByteBuffer.allocateDirect(4 * specification.num).order(ByteOrder.nativeOrder()).asIntBuffer();
482 for (int i = 0; i < bufs.capacity(); i++)
483 bufs.put(i, GL_COLOR_ATTACHMENT0 + i);
484
485 bufs.rewind();
486
487 GL20.glDrawBuffers(bufs);
488 }

Callers

nothing calls this directly

Calls 13

checkErrorMethod · 0.95
getContextMethod · 0.95
getMethod · 0.95
glEnableMethod · 0.80
glDrawBufferMethod · 0.80
updateAllMethod · 0.80
glReadBufferMethod · 0.80
glDisableMethod · 0.80
setMethod · 0.65
saveMethod · 0.45
orderMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected