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

Method setup

src/main/java/field/graphics/Texture.java:419–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

417 if (isDoubleBuffered) s.pboB = glGenBuffers();
418 s.pbo = s.pboA;
419
420
421 glActiveTexture(GL_TEXTURE0 + specification.unit);
422 glBindTexture(specification.target, s.name);
423 GraphicsContext.checkError(() -> "setting up texture, bound " + specification);
424
425
426 if (!specification.highQuality) {
427 glTexParameteri(specification.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
428 glTexParameteri(specification.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
429 glTexParameteri(specification.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
430 glTexParameteri(specification.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
431 } else {
432 glTexParameteri(specification.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
433 glTexParameteri(specification.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
434 glTexParameteri(specification.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
435 glTexParameteri(specification.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
436
437 }
438
439 GraphicsContext.checkError(() -> "setting up texture, params " + specification);
440
441 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
442 glPixelStorei(GL_UNPACK_ROW_LENGTH, specification.width);
443
444 GraphicsContext.checkError(() -> "setting up texture, pixel store " + specification);
445
446 if (specification.target == GL_TEXTURE_1D) {
447 ARBTextureStorage.glTexStorage1D(specification.target,
448 specification.highQuality ? (int) (Math.floor(Math.log(
449 Math.max(specification.width, specification.height)) / Math.log(
450 2)) + 1) : 1,
451 specification.internalFormat, specification.width);
452 } else if (specification.target == GL_TEXTURE_3D) {
453 ARBTextureStorage.glTexStorage3D(specification.target,
454 specification.highQuality ? (int) (Math.floor(Math.log(
455 Math.max(specification.width, specification.height)) / Math.log(
456 2)) + 1) : 1,
457 specification.internalFormat, specification.width, specification.height,
458 specification.depth);
459 }else if (specification.target == GL_TEXTURE_2D_ARRAY) {
460 ARBTextureStorage.glTexStorage3D(specification.target,
461 specification.highQuality ? (int) (Math.floor(Math.log(
462 Math.max(specification.width, specification.height)) / Math.log(
463 2)) + 1) : 1,
464 specification.internalFormat, specification.width, specification.height,
465 specification.depth);
466 } else {
467 ARBTextureStorage.glTexStorage2D(specification.target,
468 specification.highQuality ? (int) (Math.floor(Math.log(
469 Math.max(specification.width, specification.height)) / Math.log(
470 2)) + 1) : 1,
471 specification.internalFormat, specification.width, specification.height);
472 }
473 GraphicsContext.checkError(() -> "setting up texture, storage " + specification);
474
475
476 if (specification.compressed) {

Callers 1

forceUploadNowMethod · 0.95

Calls 9

checkErrorMethod · 0.95
glGenTexturesMethod · 0.80
glBindTextureMethod · 0.80
glTexParameteriMethod · 0.80
glPixelStoreiMethod · 0.80
logMethod · 0.80
glTexSubImage1DMethod · 0.80
glTexSubImage2DMethod · 0.80
maxMethod · 0.45

Tested by

no test coverage detected