()
| 1327 | |
| 1328 | |
| 1329 | protected PGL initTex2DShader() { |
| 1330 | PGL ppgl = primaryPGL ? this : graphics.getPrimaryPGL(); |
| 1331 | |
| 1332 | if (!ppgl.loadedTex2DShader || ppgl.tex2DShaderContext != ppgl.glContext) { |
| 1333 | String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion(), getGLSLVersionSuffix()); |
| 1334 | String vertSource = PApplet.join(preprocVertSrc, "\n"); |
| 1335 | String[] preprocFragSrc = preprocessFragmentSource(tex2DFragShaderSource, getGLSLVersion(), getGLSLVersionSuffix()); |
| 1336 | String fragSource = PApplet.join(preprocFragSrc, "\n"); |
| 1337 | ppgl.tex2DVertShader = createShader(VERTEX_SHADER, vertSource); |
| 1338 | ppgl.tex2DFragShader = createShader(FRAGMENT_SHADER, fragSource); |
| 1339 | if (0 < ppgl.tex2DVertShader && 0 < ppgl.tex2DFragShader) { |
| 1340 | ppgl.tex2DShaderProgram = createProgram(ppgl.tex2DVertShader, ppgl.tex2DFragShader); |
| 1341 | } |
| 1342 | if (0 < ppgl.tex2DShaderProgram) { |
| 1343 | ppgl.tex2DVertLoc = getAttribLocation(ppgl.tex2DShaderProgram, "position"); |
| 1344 | ppgl.tex2DTCoordLoc = getAttribLocation(ppgl.tex2DShaderProgram, "texCoord"); |
| 1345 | ppgl.tex2DSamplerLoc = getUniformLocation(ppgl.tex2DShaderProgram, "texMap"); |
| 1346 | } |
| 1347 | ppgl.loadedTex2DShader = true; |
| 1348 | ppgl.tex2DShaderContext = ppgl.glContext; |
| 1349 | |
| 1350 | genBuffers(1, intBuffer); |
| 1351 | ppgl.tex2DGeoVBO = intBuffer.get(0); |
| 1352 | bindBuffer(ARRAY_BUFFER, ppgl.tex2DGeoVBO); |
| 1353 | bufferData(ARRAY_BUFFER, 16 * SIZEOF_FLOAT, null, STATIC_DRAW); |
| 1354 | } |
| 1355 | |
| 1356 | if (texData == null) { |
| 1357 | texData = allocateDirectFloatBuffer(texCoords.length); |
| 1358 | } |
| 1359 | |
| 1360 | return ppgl; |
| 1361 | } |
| 1362 | |
| 1363 | |
| 1364 | protected void drawTexture2D(int id, int texW, int texH, |
no test coverage detected