()
| 1459 | |
| 1460 | |
| 1461 | protected PGL initTexRectShader() { |
| 1462 | PGL ppgl = primaryPGL ? this : graphics.getPrimaryPGL(); |
| 1463 | |
| 1464 | if (!ppgl.loadedTexRectShader || ppgl.texRectShaderContext != ppgl.glContext) { |
| 1465 | String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion(), getGLSLVersionSuffix()); |
| 1466 | String vertSource = PApplet.join(preprocVertSrc, "\n"); |
| 1467 | String[] preprocFragSrc = preprocessFragmentSource(texRectFragShaderSource, getGLSLVersion(), getGLSLVersionSuffix()); |
| 1468 | String fragSource = PApplet.join(preprocFragSrc, "\n"); |
| 1469 | ppgl.texRectVertShader = createShader(VERTEX_SHADER, vertSource); |
| 1470 | ppgl.texRectFragShader = createShader(FRAGMENT_SHADER, fragSource); |
| 1471 | if (0 < ppgl.texRectVertShader && 0 < ppgl.texRectFragShader) { |
| 1472 | ppgl.texRectShaderProgram = createProgram(ppgl.texRectVertShader, |
| 1473 | ppgl.texRectFragShader); |
| 1474 | } |
| 1475 | if (0 < ppgl.texRectShaderProgram) { |
| 1476 | ppgl.texRectVertLoc = getAttribLocation(ppgl.texRectShaderProgram, "position"); |
| 1477 | ppgl.texRectTCoordLoc = getAttribLocation(ppgl.texRectShaderProgram, "texCoord"); |
| 1478 | ppgl.texRectSamplerLoc = getUniformLocation(ppgl.texRectShaderProgram, "texMap"); |
| 1479 | } |
| 1480 | ppgl.loadedTexRectShader = true; |
| 1481 | ppgl.texRectShaderContext = ppgl.glContext; |
| 1482 | |
| 1483 | genBuffers(1, intBuffer); |
| 1484 | ppgl.texRectGeoVBO = intBuffer.get(0); |
| 1485 | bindBuffer(ARRAY_BUFFER, ppgl.texRectGeoVBO); |
| 1486 | bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); |
| 1487 | } |
| 1488 | |
| 1489 | return ppgl; |
| 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | protected void drawTextureRect(int id, int texW, int texH, |
no test coverage detected