Sets texture target and internal format according to the target and type specified. @param target int @param params GLTextureParameters
(Parameters params)
| 1408 | * @param params GLTextureParameters |
| 1409 | */ |
| 1410 | protected void setParameters(Parameters params) { |
| 1411 | if (params.target == TEX2D) { |
| 1412 | glTarget = PGL.TEXTURE_2D; |
| 1413 | } else { |
| 1414 | throw new RuntimeException("Unknown texture target"); |
| 1415 | } |
| 1416 | |
| 1417 | if (params.format == RGB) { |
| 1418 | glFormat = PGL.RGB; |
| 1419 | } else if (params.format == ARGB) { |
| 1420 | glFormat = PGL.RGBA; |
| 1421 | } else if (params.format == ALPHA) { |
| 1422 | glFormat = PGL.ALPHA; |
| 1423 | } else { |
| 1424 | throw new RuntimeException("Unknown texture format"); |
| 1425 | } |
| 1426 | |
| 1427 | boolean mipmaps = params.mipmaps && PGL.MIPMAPS_ENABLED; |
| 1428 | if (mipmaps && !PGraphicsOpenGL.autoMipmapGenSupported) { |
| 1429 | PGraphics.showWarning("Mipmaps were requested but automatic mipmap " + |
| 1430 | "generation is not supported and manual " + |
| 1431 | "generation still not implemented, so mipmaps " + |
| 1432 | "will be disabled."); |
| 1433 | mipmaps = false; |
| 1434 | } |
| 1435 | |
| 1436 | if (params.sampling == POINT) { |
| 1437 | glMagFilter = PGL.NEAREST; |
| 1438 | glMinFilter = PGL.NEAREST; |
| 1439 | } else if (params.sampling == LINEAR) { |
| 1440 | glMagFilter = PGL.NEAREST; |
| 1441 | glMinFilter = mipmaps ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR; |
| 1442 | } else if (params.sampling == BILINEAR) { |
| 1443 | glMagFilter = PGL.LINEAR; |
| 1444 | glMinFilter = mipmaps ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR; |
| 1445 | } else if (params.sampling == TRILINEAR) { |
| 1446 | glMagFilter = PGL.LINEAR; |
| 1447 | glMinFilter = mipmaps ? PGL.LINEAR_MIPMAP_LINEAR : PGL.LINEAR; |
| 1448 | } else { |
| 1449 | throw new RuntimeException("Unknown texture filtering mode"); |
| 1450 | } |
| 1451 | |
| 1452 | if (params.wrapU == CLAMP) { |
| 1453 | glWrapS = PGL.CLAMP_TO_EDGE; |
| 1454 | } else if (params.wrapU == REPEAT) { |
| 1455 | glWrapS = PGL.REPEAT; |
| 1456 | } else { |
| 1457 | throw new RuntimeException("Unknown wrapping mode"); |
| 1458 | } |
| 1459 | |
| 1460 | if (params.wrapV == CLAMP) { |
| 1461 | glWrapT = PGL.CLAMP_TO_EDGE; |
| 1462 | } else if (params.wrapV == REPEAT) { |
| 1463 | glWrapT = PGL.REPEAT; |
| 1464 | } else { |
| 1465 | throw new RuntimeException("Unknown wrapping mode"); |
| 1466 | } |
| 1467 |