### codeanticode.glgraphics

# Class GLTexturePingPong

- `java.lang.Object`
- - `codeanticode.glgraphics.GLTexturePingPong`

`public class GLTexturePingPong`
`extends java.lang.Object`

This class encapsulates two GLTextures, that are labeled as read and write. The role of each texture is swaped upon calling the swap function. This class is intended to simplify the code in GP-GPU applications, where there is the need to apply iterative operations on textures holding float data that represents coordinates or velocities of particles, etc. This technique of alternatively swaping the textures to allow for read/write operations is called "Ping-Pong".

  ## Constructor Summary
  `GLTexturePingPong(GLTexture tex0, GLTexture tex1)` The constructor of the class.

  ## Method Summary
  `GLTexture` | `getNewTex()` Returns the current write texture.
  `GLTexture` | `getOldTex()` Returns the current read texture.
  `GLTexture` | `getReadTex()` Returns the current read texture.
  `GLTexture` | `getWriteTex()` Returns the current write texture.
  `void` | `init()` Inits the read and write indices.
  `void` | `setNewTex(int idx)` Sets the value for the write texture.
  `void` | `setOldTex(int idx)` Sets the value for the read texture.
  `void` | `setReadTex(int idx)` Sets the value for the read texture.
  `void` | `setWriteTex(int idx)` Sets the value for the write texture.
  `void` | `swap()` Swaps the two textures, read becomes write and viceversa.

## Constructor Details

### GLTexturePingPong

    public GLTexturePingPong(GLTexture tex0,
                             GLTexture tex1)

> The constructor of the class. Sets the two textures to use.
> Parameters:
>   `tex0` - GLTexture
>   `tex1` - GLTexture

## Method Details

### getNewTex

    public GLTexture getNewTex()

> Returns the current write texture.
> Returns:
>   GLTexture

### getOldTex

    public GLTexture getOldTex()

> Returns the current read texture.
> Returns:
>   GLTexture

### getReadTex

    public GLTexture getReadTex()

> Returns the current read texture.
> Returns:
>   GLTexture

### getWriteTex

    public GLTexture getWriteTex()

> Returns the current write texture.
> Returns:
>   GLTexture

### init

    public void init()

> Inits the read and write indices.

### setNewTex

    public void setNewTex(int idx)

> Sets the value for the write texture.
> Parameters:
>   `idx` - int

### setOldTex

    public void setOldTex(int idx)

> Sets the value for the read texture.
> Parameters:
>   `idx` - int

### setReadTex

    public void setReadTex(int idx)

> Sets the value for the read texture.
> Parameters:
>   `idx` - int

### setWriteTex

    public void setWriteTex(int idx)

> Sets the value for the write texture.
> Parameters:
>   `idx` - int

### swap

    public void swap()

> Swaps the two textures, read becomes write and viceversa.

processing library glgraphics by Andres Colubri. (c) 2008