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

Method drawTextureRect

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

1448
1449
1450 protected void drawTextureRect(int id, int texW, int texH,
1451 int viewX, int viewY, int viewW, int viewH, int viewF,
1452 int texX0, int texY0, int texX1, int texY1,
1453 int scrX0, int scrY0, int scrX1, int scrY1) {
1454 PGL ppgl = initTexRectShader();
1455
1456 if (texData == null) {
1457 texData = allocateDirectFloatBuffer(texCoords.length);
1458 }
1459
1460 if (0 < ppgl.texRectShaderProgram) {
1461 // The texture overwrites anything drawn earlier.
1462 boolean depthTest = getDepthTest();
1463 disable(DEPTH_TEST);
1464
1465 // When drawing the texture we don't write to the
1466 // depth mask, so the texture remains in the background
1467 // and can be occluded by anything drawn later, even if
1468 // if it is behind it.
1469 boolean depthMask = getDepthWriteMask();
1470 depthMask(false);
1471
1472 // Making sure that the viewport matches the provided screen dimensions
1473 viewBuffer.rewind();
1474 getIntegerv(VIEWPORT, viewBuffer);
1475 viewportImpl(viewF * viewX, viewF * viewY, viewF * viewW, viewF * viewH);
1476
1477 useProgram(ppgl.texRectShaderProgram);
1478
1479 enableVertexAttribArray(ppgl.texRectVertLoc);
1480 enableVertexAttribArray(ppgl.texRectTCoordLoc);
1481
1482 // Vertex coordinates of the textured quad are specified
1483 // in normalized screen space (-1, 1):
1484 // Corner 1
1485 texCoords[ 0] = 2 * (float)scrX0 / viewW - 1;
1486 texCoords[ 1] = 2 * (float)scrY0 / viewH - 1;
1487 texCoords[ 2] = texX0;
1488 texCoords[ 3] = texY0;
1489 // Corner 2
1490 texCoords[ 4] = 2 * (float)scrX1 / viewW - 1;
1491 texCoords[ 5] = 2 * (float)scrY0 / viewH - 1;
1492 texCoords[ 6] = texX1;
1493 texCoords[ 7] = texY0;
1494 // Corner 3
1495 texCoords[ 8] = 2 * (float)scrX0 / viewW - 1;
1496 texCoords[ 9] = 2 * (float)scrY1 / viewH - 1;
1497 texCoords[10] = texX0;
1498 texCoords[11] = texY1;
1499 // Corner 4
1500 texCoords[12] = 2 * (float)scrX1 / viewW - 1;
1501 texCoords[13] = 2 * (float)scrY1 / viewH - 1;
1502 texCoords[14] = texX1;
1503 texCoords[15] = texY1;
1504
1505 texData.rewind();
1506 texData.put(texCoords);
1507

Callers 1

drawTextureMethod · 0.95

Calls 15

initTexRectShaderMethod · 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

Tested by

no test coverage detected