MCPcopy Index your code
hub / github.com/processing/processing / drawTexture2D

Method drawTexture2D

core/src/processing/opengl/PGL.java:1321–1415  ·  view source on GitHub ↗
(int id, int texW, int texH,
                               int viewX, int viewY, int viewW, int viewH, int viewF,
                               int texX0, int texY0, int texX1, int texY1,
                               int scrX0, int scrY0, int scrX1, int scrY1)

Source from the content-addressed store, hash-verified

1319
1320
1321 protected void drawTexture2D(int id, int texW, int texH,
1322 int viewX, int viewY, int viewW, int viewH, int viewF,
1323 int texX0, int texY0, int texX1, int texY1,
1324 int scrX0, int scrY0, int scrX1, int scrY1) {
1325 PGL ppgl = initTex2DShader();
1326
1327 if (0 < ppgl.tex2DShaderProgram) {
1328 // The texture overwrites anything drawn earlier.
1329 boolean depthTest = getDepthTest();
1330 disable(DEPTH_TEST);
1331
1332 // When drawing the texture we don't write to the
1333 // depth mask, so the texture remains in the background
1334 // and can be occluded by anything drawn later, even if
1335 // if it is behind it.
1336 boolean depthMask = getDepthWriteMask();
1337 depthMask(false);
1338
1339 // Making sure that the viewport matches the provided screen dimensions
1340 viewBuffer.rewind();
1341 getIntegerv(VIEWPORT, viewBuffer);
1342 viewportImpl(viewF * viewX, viewF * viewY, viewF * viewW, viewF * viewH);
1343
1344 useProgram(ppgl.tex2DShaderProgram);
1345
1346 enableVertexAttribArray(ppgl.tex2DVertLoc);
1347 enableVertexAttribArray(ppgl.tex2DTCoordLoc);
1348
1349 // Vertex coordinates of the textured quad are specified
1350 // in normalized screen space (-1, 1):
1351 // Corner 1
1352 texCoords[ 0] = 2 * (float)scrX0 / viewW - 1;
1353 texCoords[ 1] = 2 * (float)scrY0 / viewH - 1;
1354 texCoords[ 2] = (float)texX0 / texW;
1355 texCoords[ 3] = (float)texY0 / texH;
1356 // Corner 2
1357 texCoords[ 4] = 2 * (float)scrX1 / viewW - 1;
1358 texCoords[ 5] = 2 * (float)scrY0 / viewH - 1;
1359 texCoords[ 6] = (float)texX1 / texW;
1360 texCoords[ 7] = (float)texY0 / texH;
1361 // Corner 3
1362 texCoords[ 8] = 2 * (float)scrX0 / viewW - 1;
1363 texCoords[ 9] = 2 * (float)scrY1 / viewH - 1;
1364 texCoords[10] = (float)texX0 / texW;
1365 texCoords[11] = (float)texY1 / texH;
1366 // Corner 4
1367 texCoords[12] = 2 * (float)scrX1 / viewW - 1;
1368 texCoords[13] = 2 * (float)scrY1 / viewH - 1;
1369 texCoords[14] = (float)texX1 / texW;
1370 texCoords[15] = (float)texY1 / texH;
1371
1372 texData.rewind();
1373 texData.put(texCoords);
1374
1375 activeTexture(TEXTURE0);
1376 boolean enabledTex = false;
1377 if (!texturingIsEnabled(TEXTURE_2D)) {
1378 enableTexturing(TEXTURE_2D);

Callers 1

drawTextureMethod · 0.95

Calls 15

initTex2DShaderMethod · 0.95
getDepthTestMethod · 0.95
disableMethod · 0.95
getDepthWriteMaskMethod · 0.95
depthMaskMethod · 0.95
getIntegervMethod · 0.95
viewportImplMethod · 0.95
useProgramMethod · 0.95
activeTextureMethod · 0.95
texturingIsEnabledMethod · 0.95
enableTexturingMethod · 0.95

Tested by

no test coverage detected