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

Method drawTexture2D

core/src/processing/opengl/PGL.java:1364–1458  ·  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

1362
1363
1364 protected void drawTexture2D(int id, int texW, int texH,
1365 int viewX, int viewY, int viewW, int viewH, int viewF,
1366 int texX0, int texY0, int texX1, int texY1,
1367 int scrX0, int scrY0, int scrX1, int scrY1) {
1368 PGL ppgl = initTex2DShader();
1369
1370 if (0 < ppgl.tex2DShaderProgram) {
1371 // The texture overwrites anything drawn earlier.
1372 boolean depthTest = getDepthTest();
1373 disable(DEPTH_TEST);
1374
1375 // When drawing the texture we don't write to the
1376 // depth mask, so the texture remains in the background
1377 // and can be occluded by anything drawn later, even if
1378 // if it is behind it.
1379 boolean depthMask = getDepthWriteMask();
1380 depthMask(false);
1381
1382 // Making sure that the viewport matches the provided screen dimensions
1383 viewBuffer.rewind();
1384 getIntegerv(VIEWPORT, viewBuffer);
1385 viewportImpl(viewF * viewX, viewF * viewY, viewF * viewW, viewF * viewH);
1386
1387 useProgram(ppgl.tex2DShaderProgram);
1388
1389 enableVertexAttribArray(ppgl.tex2DVertLoc);
1390 enableVertexAttribArray(ppgl.tex2DTCoordLoc);
1391
1392 // Vertex coordinates of the textured quad are specified
1393 // in normalized screen space (-1, 1):
1394 // Corner 1
1395 texCoords[ 0] = 2 * (float)scrX0 / viewW - 1;
1396 texCoords[ 1] = 2 * (float)scrY0 / viewH - 1;
1397 texCoords[ 2] = (float)texX0 / texW;
1398 texCoords[ 3] = (float)texY0 / texH;
1399 // Corner 2
1400 texCoords[ 4] = 2 * (float)scrX1 / viewW - 1;
1401 texCoords[ 5] = 2 * (float)scrY0 / viewH - 1;
1402 texCoords[ 6] = (float)texX1 / texW;
1403 texCoords[ 7] = (float)texY0 / texH;
1404 // Corner 3
1405 texCoords[ 8] = 2 * (float)scrX0 / viewW - 1;
1406 texCoords[ 9] = 2 * (float)scrY1 / viewH - 1;
1407 texCoords[10] = (float)texX0 / texW;
1408 texCoords[11] = (float)texY1 / texH;
1409 // Corner 4
1410 texCoords[12] = 2 * (float)scrX1 / viewW - 1;
1411 texCoords[13] = 2 * (float)scrY1 / viewH - 1;
1412 texCoords[14] = (float)texX1 / texW;
1413 texCoords[15] = (float)texY1 / texH;
1414
1415 texData.rewind();
1416 texData.put(texCoords);
1417
1418 activeTexture(TEXTURE0);
1419 boolean enabledTex = false;
1420 if (!texturingIsEnabled(TEXTURE_2D)) {
1421 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