MCPcopy Index your code
hub / github.com/benfry/processing4 / setTexture

Method setTexture

core/src/processing/opengl/PShader.java:1324–1368  ·  view source on GitHub ↗
(Texture tex)

Source from the content-addressed store, hash-verified

1322 }
1323
1324 protected void setTexture(Texture tex) {
1325 texture = tex;
1326
1327 float scaleu = 1;
1328 float scalev = 1;
1329 float dispu = 0;
1330 float dispv = 0;
1331
1332 if (tex != null) {
1333 if (tex.invertedX()) {
1334 scaleu = -1;
1335 dispu = 1;
1336 }
1337
1338 if (tex.invertedY()) {
1339 scalev = -1;
1340 dispv = 1;
1341 }
1342
1343 scaleu *= tex.maxTexcoordU();
1344 dispu *= tex.maxTexcoordU();
1345 scalev *= tex.maxTexcoordV();
1346 dispv *= tex.maxTexcoordV();
1347
1348 setUniformValue(texOffsetLoc, 1.0f / tex.width, 1.0f / tex.height);
1349
1350 if (-1 < textureLoc) {
1351 texUnit = -1 < ppixelsUnit ? ppixelsUnit + 1 : getLastTexUnit() + 1;
1352 setUniformValue(textureLoc, texUnit);
1353 pgl.activeTexture(PGL.TEXTURE0 + texUnit);
1354 tex.bind();
1355 }
1356 }
1357
1358 if (-1 < texMatrixLoc) {
1359 if (tcmat == null) {
1360 tcmat = new float[16];
1361 }
1362 tcmat[0] = scaleu; tcmat[4] = 0; tcmat[ 8] = 0; tcmat[12] = dispu;
1363 tcmat[1] = 0; tcmat[5] = scalev; tcmat[ 9] = 0; tcmat[13] = dispv;
1364 tcmat[2] = 0; tcmat[6] = 0; tcmat[10] = 0; tcmat[14] = 0;
1365 tcmat[3] = 0; tcmat[7] = 0; tcmat[11] = 0; tcmat[15] = 0;
1366 setUniformMatrix(texMatrixLoc, tcmat);
1367 }
1368 }
1369
1370
1371 protected boolean supportsTexturing() {

Callers 3

flushPolysMethod · 0.95
flushSortedPolysMethod · 0.95
renderPolysMethod · 0.95

Calls 9

setUniformValueMethod · 0.95
getLastTexUnitMethod · 0.95
setUniformMatrixMethod · 0.95
invertedXMethod · 0.80
invertedYMethod · 0.80
maxTexcoordUMethod · 0.80
maxTexcoordVMethod · 0.80
activeTextureMethod · 0.80
bindMethod · 0.45

Tested by

no test coverage detected