Copy texture to pixels. Involves video memory to main memory transfer (slow).
(int[] pixels)
| 438 | * Copy texture to pixels. Involves video memory to main memory transfer (slow). |
| 439 | */ |
| 440 | public void get(int[] pixels) { |
| 441 | if (pixels == null) { |
| 442 | throw new RuntimeException("Trying to copy texture to null pixels array"); |
| 443 | } |
| 444 | if (pixels.length != width * height) { |
| 445 | throw new RuntimeException("Trying to copy texture to pixels array of " + |
| 446 | "wrong size"); |
| 447 | } |
| 448 | |
| 449 | if (tempFbo == null) { |
| 450 | tempFbo = new FrameBuffer(pg, glWidth, glHeight); |
| 451 | } |
| 452 | |
| 453 | // Attaching the texture to the color buffer of a FBO, binding the FBO and |
| 454 | // reading the pixels from the current draw buffer (which is the color |
| 455 | // buffer of the FBO). |
| 456 | tempFbo.setColorBuffer(this); |
| 457 | pg.pushFramebuffer(); |
| 458 | pg.setFramebuffer(tempFbo); |
| 459 | tempFbo.readPixels(); |
| 460 | pg.popFramebuffer(); |
| 461 | |
| 462 | tempFbo.getPixels(pixels); |
| 463 | convertToARGB(pixels); |
| 464 | |
| 465 | if (invertedX) flipArrayOnX(pixels, 1); |
| 466 | if (invertedY) flipArrayOnY(pixels, 1); |
| 467 | } |
| 468 | |
| 469 | |
| 470 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected