Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## codeanticode.glgraphics
Class GLTexture

    java.lang.Object
      PImage
          codeanticode.glgraphics.GLTexture

All Implemented Interfaces:
  GLConstants

    public class GLTexture

extends PImage
implements GLConstants

This class adds an opengl texture to a PImage object. The texture is handled in a similar way to the pixels property: image data can be copied to and from the texture using loadTexture and updateTexture methods. However, bringing the texture down to image or pixels data can slow down the application considerably (since involves copying texture data from GPU to CPU), especially when handling large textures. So it is recommended to do all the texture handling without calling updateTexture, and doing so only at the end if the texture is needed as a regular image.

Field Summary
`protected boolean` | `flippedX`
`protected boolean` | `flippedY`
`protected GL` | `gl`
`protected GLState` | `glstate`
`protected int` | `magFilter`
`protected float` | `maxTexCoordS`
`protected float` | `maxTexCoordT`
`protected int` | `minFilter`
`protected PGraphicsOpenGL` | `pgl`
`protected int[]` | `tex`
`protected int` | `texInternalFormat`
`protected int` | `texTarget`
`protected boolean` | `usingMipmaps`

Fields inherited from interface codeanticode.glgraphics.GLConstants
`COLOR, DOUBLE4, FLOAT4, GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8, GLGRAPHICS, LINEAR, LINEAR_MIPMAP_LINEAR, LINEAR_MIPMAP_NEAREST, NEAREST, NEAREST_MIPMAP_LINEAR, NEAREST_MIPMAP_NEAREST, NORMAL, RECTANGULAR`

Constructor Summary
`GLTexture(PApplet parent)` Creates an instance of GLTexture with size 1x1.
`GLTexture(PApplet parent, int width, int height)` Creates an instance of GLTexture with size width x height.
`GLTexture(PApplet parent, int width, int height, GLTextureParameters params)` Creates an instance of GLTexture with size width x height and with the specified parameters.
`GLTexture(PApplet parent, java.lang.String filename)` Creates an instance of GLTexture using image file filename as source.

Method Summary
`boolean` | `available()` Returns true if the texture has been initialized.
`void` | `filter(GLTextureFilter texFilter, GLTexture destTex)` Applies filter texFilter using this texture as source and destTex as destination.
`void` | `filter(GLTextureFilter texFilter, GLTexture[] destTexArray)` Applies filter texFilter using this texture as source and destTex as multiple destinations.
`void` | `filter(GLTextureFilter texFilter, GLTexture[] destTexArray, float fadeConst)` Applies filter texFilter using this texture as source, destTex as multiple destinations and fadeConst as the fading constant for the filter.
`void` | `filter(GLTextureFilter texFilter, GLTexture[] destTexArray, float fadeConst, GLTextureFilterParameters params)` Applies filter texFilter using this texture as source, destTex as multiple destinations, fadeConst as the fading constant for the filter and params as the parameters for the filter.
`void` | `filter(GLTextureFilter texFilter, GLTexture[] destTexArray, GLTextureFilterParameters params)` Applies filter texFilter using this texture as source, destTex as multiple destinations and params as the parameters for the filter.
`void` | `filter(GLTextureFilter texFilter, GLTexture destTex, float fadeConst)` Applies filter texFilter using this texture as source, destTex as destination and fadeConst as the fading constant for the filter.
`void` | `filter(GLTextureFilter texFilter, GLTexture destTex, float fadeConst, GLTextureFilterParameters params)` Applies filter texFilter using this texture as source, destTex as destination, fadeConst as the fading constant for the filter and params as the parameters for the filter.
`void` | `filter(GLTextureFilter texFilter, GLTexture destTex, GLTextureFilterParameters params)` Applies filter texFilter using this texture as source, destTex as destination and params as the parameters for the filter.
`void` | `getImage(PImage img)` Copies texture to img.
`float` | `getMaxTextureCoordS()` Returns the maximum possible value for the texture coordinate S.
`float` | `getMaxTextureCoordT()` Returns the maximum possible value for the texture coordinate T.
`int` | `getTextureID()` Provides the ID of the opegl texture object.
`int` | `getTextureInternalFormat()` Returns the texture internal format.
`int` | `getTextureMagFilter()` Returns the texture magnification filter.
`int` | `getTextureMinFilter()` Returns the texture minimization filter.
`int` | `getTextureTarget()` Returns the texture target.
`void` | `init(int width, int height)` Sets the size of the image and texture to width x height.
`void` | `init(int width, int height, GLTextureParameters params)` Sets the size of the image and texture to width x height, and the parameters of the texture to params .
`protected void` | `initTexture(int w, int h)`
`boolean` | `isFlippedX()` Returns true if the texture is flipped along the horizontal direction.
`boolean` | `isFlippedY()` Returns true if the texture is flipped along the vertical direction.
`void` | `loadTexture()` Copy pixels to texture (loadPixels should have been called beforehand).
`void` | `loadTexture(java.lang.String filename)` Load texture, pixels and image from file.
`void` | `putImage(PImage img)` Puts img into texture, pixels and image.
`protected void` | `putPixels(int[] pix)`
`void` | `putPixelsIntoTexture(PImage img)` Puts pixels of img into texture only.
`protected void` | `releaseTexture()`
`void` | `render()` Draws the texture using the opengl commands, inside a rectangle located at the origin with the original size of the texture.
`void` | `render(float x, float y)` Draws the texture using the opengl commands, inside a rectangle located at (x,y) with the original size of the texture.
`void` | `render(float x, float y, float w, float h)` Draws the texture using the opengl commands, inside a rectangle of width w and height h located at (x,y).
`void` | `setFlippedX(boolean v)` Sets the texture as flipped or not flipped on the horizontal direction.
`void` | `setFlippedY(boolean v)` Sets the texture as flipped or not flipped on the vertical direction.
`protected void` | `setTextureParams(GLTextureParameters params)`
`void` | `updateTexture()` Copy texture to pixels (doesn't call updatePixels).
`boolean` | `usingMipmaps()` Returns true or false whether or not the texture is using mipmaps.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### gl

    protected GL gl

### pgl

    protected PGraphicsOpenGL pgl

### tex

    protected int[] tex

### texTarget

    protected int texTarget

### texInternalFormat

    protected int texInternalFormat

### minFilter

    protected int minFilter

### magFilter

    protected int magFilter

### usingMipmaps

    protected boolean usingMipmaps

### maxTexCoordS

    protected float maxTexCoordS

### maxTexCoordT

    protected float maxTexCoordT

### flippedX

    protected boolean flippedX

### flippedY

    protected boolean flippedY

### glstate

    protected GLState glstate

Constructor Detail

### GLTexture

    public GLTexture(PApplet parent)

  Creates an instance of GLTexture with size 1x1. The texture is not initialized.

  Parameters:
    `parent` - PApplet

### GLTexture

    public GLTexture(PApplet parent,
                     int width,
                     int height)

  Creates an instance of GLTexture with size width x height. The texture is initialized (empty) to that size.

  Parameters:
    `parent` - PApplet
    `width` - int
    `height` - int

### GLTexture

    public GLTexture(PApplet parent,
                     int width,
                     int height,
                     GLTextureParameters params)

  Creates an instance of GLTexture with size width x height and with the specified parameters. The texture is initialized (empty) to that size.

  Parameters:
    `parent` - PApplet
    `width` - int
    `height` - int
    `params` - GLTextureParameters

### GLTexture

    public GLTexture(PApplet parent,
                     java.lang.String filename)

  Creates an instance of GLTexture using image file filename as source.

  Parameters:
    `filename` - String

Method Detail

### init

    public void init(int width,
                     int height)

  Sets the size of the image and texture to width x height. If the texture is already initialized, it first destroys the current opengl texture object and then creates a new one with the specified size.

  Parameters:
    `width` - int
    `height` - int

### init

    public void init(int width,
                     int height,
                     GLTextureParameters params)

  Sets the size of the image and texture to width x height, and the parameters of the texture to params . If the texture is already initialized, it first destroys the current opengl texture object and then creates a new one with the specified size.

  Parameters:
    `width` - int
    `height` - int
    `params` - GLTextureParameters

### available

    public boolean available()

  Returns true if the texture has been initialized.

  Returns:
    boolean

### getTextureID

    public int getTextureID()

  Provides the ID of the opegl texture object.

  Returns:
    int

### getTextureTarget

    public int getTextureTarget()

  Returns the texture target.

  Returns:
    int

### getTextureInternalFormat

    public int getTextureInternalFormat()

  Returns the texture internal format.

  Returns:
    int

### getTextureMinFilter

    public int getTextureMinFilter()

  Returns the texture minimization filter.

  Returns:
    int

### getTextureMagFilter

    public int getTextureMagFilter()

  Returns the texture magnification filter.

  Returns:
    int

### usingMipmaps

    public boolean usingMipmaps()

  Returns true or false whether or not the texture is using mipmaps.

  Returns:
    boolean

### getMaxTextureCoordS

    public float getMaxTextureCoordS()

  Returns the maximum possible value for the texture coordinate S.

  Returns:
    float

### getMaxTextureCoordT

    public float getMaxTextureCoordT()

  Returns the maximum possible value for the texture coordinate T.

  Returns:
    float

### isFlippedX

    public boolean isFlippedX()

  Returns true if the texture is flipped along the horizontal direction.

  Returns:
    boolean;

### setFlippedX

    public void setFlippedX(boolean v)

  Sets the texture as flipped or not flipped on the horizontal direction.

  Parameters:
    `v` - boolean;

### isFlippedY

    public boolean isFlippedY()

  Returns true if the texture is flipped along the vertical direction.

  Returns:
    boolean;

### setFlippedY

    public void setFlippedY(boolean v)

  Sets the texture as flipped or not flipped on the vertical direction.

  Parameters:
    `v` - boolean;

### putImage

    public void putImage(PImage img)

  Puts img into texture, pixels and image.

  Parameters:
    `img` - PImage

### putPixelsIntoTexture

    public void putPixelsIntoTexture(PImage img)

  Puts pixels of img into texture only.

  Parameters:
    `img` - PImage

### getImage

    public void getImage(PImage img)

  Copies texture to img.

  Parameters:
    `img` - PImage

### loadTexture

    public void loadTexture(java.lang.String filename)

  Load texture, pixels and image from file.

  Parameters:
    `filename` - String

### loadTexture

    public void loadTexture()

  Copy pixels to texture (loadPixels should have been called beforehand).

### updateTexture

    public void updateTexture()

  Copy texture to pixels (doesn't call updatePixels).

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture destTex)

  Applies filter texFilter using this texture as source and destTex as destination.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTex` - GLTexture

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture[] destTexArray)

  Applies filter texFilter using this texture as source and destTex as multiple destinations.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTexArray` - GLTexture[]

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture destTex,
                       GLTextureFilterParameters params)

  Applies filter texFilter using this texture as source, destTex as destination and params as the parameters for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTex` - GLTexture
    `params` - GLTextureFilterParameters

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture[] destTexArray,
                       GLTextureFilterParameters params)

  Applies filter texFilter using this texture as source, destTex as multiple destinations and params as the parameters for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTexArray` - GLTexture[]
    `params` - GLTextureFilterParameters

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture destTex,
                       float fadeConst)

  Applies filter texFilter using this texture as source, destTex as destination and fadeConst as the fading constant for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTex` - GLTexture
    `fadeConst` - float

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture[] destTexArray,
                       float fadeConst)

  Applies filter texFilter using this texture as source, destTex as multiple destinations and fadeConst as the fading constant for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTexArray` - GLTexture[]
    `fadeConst` - float

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture destTex,
                       float fadeConst,
                       GLTextureFilterParameters params)

  Applies filter texFilter using this texture as source, destTex as destination, fadeConst as the fading constant for the filter and params as the parameters for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTex` - GLTexture
    `fadeConst` - float

### filter

    public void filter(GLTextureFilter texFilter,
                       GLTexture[] destTexArray,
                       float fadeConst,
                       GLTextureFilterParameters params)

  Applies filter texFilter using this texture as source, destTex as multiple destinations, fadeConst as the fading constant for the filter and params as the parameters for the filter.

  Parameters:
    `texFilter` - GLTextureFilter
    `destTexArray` - GLTexture[]
    `fadeConst` - float

### render

    public void render()

  Draws the texture using the opengl commands, inside a rectangle located at the origin with the original size of the texture.

### render

    public void render(float x,
                       float y)

  Draws the texture using the opengl commands, inside a rectangle located at (x,y) with the original size of the texture.

  Parameters:
    `x` - float
    `y` - float

### render

    public void render(float x,
                       float y,
                       float w,
                       float h)

  Draws the texture using the opengl commands, inside a rectangle of width w and height h located at (x,y).

  Parameters:
    `x` - float
    `y` - float
    `w` - float
    `h` - float

### initTexture

    protected void initTexture(int w,
                               int h)

  Parameters:
    `w` - int
    `h` - int

### releaseTexture

    protected void releaseTexture()

### putPixels

    protected void putPixels(int[] pix)

  Parameters:
    `pix` - int[]

### setTextureParams

    protected void setTextureParams(GLTextureParameters params)

  Parameters:
    `target` - int
    `params` - GLTextureParameters

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD