Texture

processing.opengl

## Class Texture

- java.lang.Object
- - processing.opengl.Texture

- All Implemented Interfaces:
    PConstants

      public class Texture
      extends Object
      implements PConstants

  This class wraps an OpenGL texture. By Andres Colubri

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Texture.Parameters` This class stores the parameters for a texture: target, internal format, minimization filter and magnification filter.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `glFormat`
    `int` | `glHeight`
    `int` | `glMagFilter`
    `int` | `glMinFilter`
    `int` | `glName`
    `int` | `glTarget`
    `int` | `glWidth`
    `int` | `glWrapS`
    `int` | `glWrapT`
    `int` | `height`
    `static int` | `MAX_BUFFER_CACHE_SIZE`
    `int` | `width`

    - ### Fields inherited from interface processing.core.PConstants

      `ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_RETINA_PIXELS, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_RETINA_PIXELS, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Texture()`
    `Texture(int width, int height)` Creates an instance of PTexture with size width x height.
    `Texture(int width, int height, Object params)` Creates an instance of PTexture with size width x height and with the specified parameters.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `available()` Returns true if the texture has been initialized.
    `void` | `bind()`
    `boolean` | `bound()`
    `boolean` | `colorBuffer()`
    `void` | `colorBuffer(boolean value)`
    `void` | `copyBufferFromSource(Object natRef, ByteBuffer byteBuf, int w, int h)`
    `void` | `disposeSourceBuffer()`
    `void` | `get(int[] pixels)` Copy texture to pixels.
    `void` | `getBufferPixels(int[] pixels)`
    `int` | `getModifiedX1()`
    `int` | `getModifiedX2()`
    `int` | `getModifiedY1()`
    `int` | `getModifiedY2()`
    `Texture.Parameters` | `getParameters()`
    `boolean` | `hasBuffers()`
    `boolean` | `hasBufferSource()`
    `void` | `init(int width, int height)` Sets the size of the image and texture to width x height.
    `void` | `init(int width, int height, int glName, int glTarget, int glFormat, int glWidth, int glHeight, int glMinFilter, int glMagFilter, int glWrapS, int glWrapT)` Initializes the texture using GL parameters
    `void` | `init(int width, int height, Texture.Parameters params)` Sets the size of the image and texture to width x height, and the parameters of the texture to params.
    `boolean` | `invertedX()` Returns true if the texture is inverted along the horizontal direction.
    `void` | `invertedX(boolean v)` Sets the texture as inverted or not along the horizontal direction.
    `boolean` | `invertedY()` Returns true if the texture is inverted along the vertical direction.
    `void` | `invertedY(boolean v)` Sets the texture as inverted or not along the vertical direction.
    `boolean` | `isModified()`
    `float` | `maxTexcoordU()` Returns the maximum possible value for the texture coordinate U (horizontal).
    `float` | `maxTexcoordV()` Returns the maximum possible value for the texture coordinate V (vertical).
    `void` | `put(int texTarget, int texName, int texWidth, int texHeight, int w, int h)`
    `void` | `put(int texTarget, int texName, int texWidth, int texHeight, int target, int tex, int x, int y, int w, int h)`
    `void` | `put(Texture tex)`
    `void` | `put(Texture tex, int x, int y, int w, int h)`
    `void` | `resize(int wide, int high)`
    `void` | `set(int[] pixels)`
    `void` | `set(int[] pixels, int format)`
    `void` | `set(int[] pixels, int x, int y, int w, int h)`
    `void` | `set(int[] pixels, int x, int y, int w, int h, int format)`
    `void` | `set(int texTarget, int texName, int texWidth, int texHeight, int w, int h)`
    `void` | `set(int texTarget, int texName, int texWidth, int texHeight, int target, int tex, int x, int y, int w, int h)`
    `void` | `set(Texture tex)`
    `void` | `set(Texture tex, int x, int y, int w, int h)`
    `void` | `setBufferSource(Object source)`
    `void` | `setModified()`
    `void` | `setModified(boolean m)`
    `void` | `setNative(int[] pixels)`
    `void` | `setNative(int[] pixels, int x, int y, int w, int h)`
    `void` | `setNative(IntBuffer pixBuf, int x, int y, int w, int h)`
    `void` | `unbind()`
    `void` | `updateTexels()`
    `void` | `updateTexels(int x, int y, int w, int h)`
    `boolean` | `usingMipmaps()` Returns true or false whether or not the texture is using mipmaps.
    `void` | `usingMipmaps(boolean mipmaps, int sampling)`
    `boolean` | `usingRepeat()` Returns true or false whether or not the texture is using repeat wrap mode along either U or V directions.
    `void` | `usingRepeat(boolean repeat)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### width

          public int width

    - #### height

          public int height

    - #### glName

          public int glName

    - #### glTarget

          public int glTarget

    - #### glFormat

          public int glFormat

    - #### glMinFilter

          public int glMinFilter

    - #### glMagFilter

          public int glMagFilter

    - #### glWrapS

          public int glWrapS

    - #### glWrapT

          public int glWrapT

    - #### glWidth

          public int glWidth

    - #### glHeight

          public int glHeight

    - #### MAX_BUFFER_CACHE_SIZE

          public static final int MAX_BUFFER_CACHE_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Texture

          public Texture()

    - #### Texture

          public Texture(int width,
                 int height)

      Creates an instance of PTexture with size width x height. The texture is initialized (empty) to that size.
      Parameters:
        `width` - int
        `height` - int

    - #### Texture

          public Texture(int width,
                 int height,
                 Object params)

      Creates an instance of PTexture with size width x height and with the specified parameters. The texture is initialized (empty) to that size.
      Parameters:
        `width` - int
        `height` - int
        `params` - Parameters

  - ### 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,
                  Texture.Parameters 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

    - #### init

          public void init(int width,
                  int height,
                  int glName,
                  int glTarget,
                  int glFormat,
                  int glWidth,
                  int glHeight,
                  int glMinFilter,
                  int glMagFilter,
                  int glWrapS,
                  int glWrapT)

      Initializes the texture using GL parameters

    - #### resize

          public void resize(int wide,
                    int high)

    - #### available

          public boolean available()

      Returns true if the texture has been initialized.
      Returns:
        boolean

    - #### set

          public void set(Texture tex)

    - #### set

          public void set(Texture tex,
                 int x,
                 int y,
                 int w,
                 int h)

    - #### set

          public void set(int texTarget,
                 int texName,
                 int texWidth,
                 int texHeight,
                 int w,
                 int h)

    - #### set

          public void set(int texTarget,
                 int texName,
                 int texWidth,
                 int texHeight,
                 int target,
                 int tex,
                 int x,
                 int y,
                 int w,
                 int h)

    - #### set

          public void set(int[] pixels)

    - #### set

          public void set(int[] pixels,
                 int format)

    - #### set

          public void set(int[] pixels,
                 int x,
                 int y,
                 int w,
                 int h)

    - #### set

          public void set(int[] pixels,
                 int x,
                 int y,
                 int w,
                 int h,
                 int format)

    - #### setNative

          public void setNative(int[] pixels)

    - #### setNative

          public void setNative(int[] pixels,
                       int x,
                       int y,
                       int w,
                       int h)

    - #### setNative

          public void setNative(IntBuffer pixBuf,
                       int x,
                       int y,
                       int w,
                       int h)

    - #### get

          public void get(int[] pixels)

      Copy texture to pixels. Involves video memory to main memory transfer (slow).

    - #### put

          public void put(Texture tex)

    - #### put

          public void put(Texture tex,
                 int x,
                 int y,
                 int w,
                 int h)

    - #### put

          public void put(int texTarget,
                 int texName,
                 int texWidth,
                 int texHeight,
                 int w,
                 int h)

    - #### put

          public void put(int texTarget,
                 int texName,
                 int texWidth,
                 int texHeight,
                 int target,
                 int tex,
                 int x,
                 int y,
                 int w,
                 int h)

    - #### usingMipmaps

          public boolean usingMipmaps()

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

    - #### usingMipmaps

          public void usingMipmaps(boolean mipmaps,
                          int sampling)

    - #### usingRepeat

          public boolean usingRepeat()

      Returns true or false whether or not the texture is using repeat wrap mode along either U or V directions.
      Returns:
        boolean

    - #### usingRepeat

          public void usingRepeat(boolean repeat)

    - #### maxTexcoordU

          public float maxTexcoordU()

      Returns the maximum possible value for the texture coordinate U (horizontal).
      Returns:
        float

    - #### maxTexcoordV

          public float maxTexcoordV()

      Returns the maximum possible value for the texture coordinate V (vertical).
      Returns:
        float

    - #### invertedX

          public boolean invertedX()

      Returns true if the texture is inverted along the horizontal direction.
      Returns:
        boolean;

    - #### invertedX

          public void invertedX(boolean v)

      Sets the texture as inverted or not along the horizontal direction.
      Parameters:
        `v` - boolean;

    - #### invertedY

          public boolean invertedY()

      Returns true if the texture is inverted along the vertical direction.
      Returns:
        boolean;

    - #### invertedY

          public void invertedY(boolean v)

      Sets the texture as inverted or not along the vertical direction.
      Parameters:
        `v` - boolean;

    - #### bind

          public void bind()

    - #### unbind

          public void unbind()

    - #### bound

          public boolean bound()

    - #### isModified

          public boolean isModified()

    - #### setModified

          public void setModified()

    - #### setModified

          public void setModified(boolean m)

    - #### getModifiedX1

          public int getModifiedX1()

    - #### getModifiedX2

          public int getModifiedX2()

    - #### getModifiedY1

          public int getModifiedY1()

    - #### getModifiedY2

          public int getModifiedY2()

    - #### updateTexels

          public void updateTexels()

    - #### updateTexels

          public void updateTexels(int x,
                          int y,
                          int w,
                          int h)

    - #### setBufferSource

          public void setBufferSource(Object source)

    - #### copyBufferFromSource

          public void copyBufferFromSource(Object natRef,
                                  ByteBuffer byteBuf,
                                  int w,
                                  int h)

    - #### disposeSourceBuffer

          public void disposeSourceBuffer()

    - #### getBufferPixels

          public void getBufferPixels(int[] pixels)

    - #### hasBufferSource

          public boolean hasBufferSource()

    - #### hasBuffers

          public boolean hasBuffers()

    - #### colorBuffer

          public void colorBuffer(boolean value)

    - #### colorBuffer

          public boolean colorBuffer()

    - #### getParameters

          public Texture.Parameters getParameters()