Class SharedTexture

java.lang.Object
org.jzy3d.plot3d.rendering.textures.SharedTexture
All Implemented Interfaces:
IGLBindedResource
Direct Known Subclasses:
BufferedImageTexture

public class SharedTexture extends Object implements IGLBindedResource
An image stored in a 2D texture, that can be shared by several drawables. The texture is loaded in GPU through IPainter at mount, hence works with any native painter. A texture may be shared by drawables rendered by several charts, hence in several GL contexts : the texture is loaded once per painter. Image rows are stored from top to bottom, hence getCoords() gives a top coordinate of 0 and a bottom coordinate of 1.
  • Field Details

    • file

      protected String file
    • coords

      protected TextureCoords coords
    • halfWidth

      protected float halfWidth
    • halfHeight

      protected float halfHeight
    • width

      protected int width
    • height

      protected int height
    • useMipMap

      protected boolean useMipMap
    • textureMagnificationFilter

      protected int textureMagnificationFilter
    • textureMinificationFilter

      protected int textureMinificationFilter
    • textureIds

      protected Map<IPainter,Integer> textureIds
      Texture name of each painter in which this texture was loaded.
  • Constructor Details

    • SharedTexture

      protected SharedTexture()
    • SharedTexture

      public SharedTexture(String file)
  • Method Details

    • mount

      public void mount(IPainter painter)
      Load the texture in the GL context of this painter. A GL context MUST be current.
      Specified by:
      mount in interface IGLBindedResource
    • bind

      public void bind(IPainter painter)
      Bind this texture to GL_TEXTURE_2D, after loading it if not done yet for this painter.
    • getTextureId

      public int getTextureId(IPainter painter)
      The texture name in the GL context of this painter, after loading it if not done yet.
    • hasMountedOnce

      public boolean hasMountedOnce()
      Description copied from interface: IGLBindedResource
      Return true if mount(...) has been called at least one time
      Specified by:
      hasMountedOnce in interface IGLBindedResource
    • loadImage

      protected BufferedImage loadImage() throws IOException
      The image to store in the texture.
      Throws:
      IOException
    • rgba

      protected static ByteBuffer rgba(BufferedImage image)
      RGBA bytes of an image, rows ordered from top to bottom.
    • getFile

      public String getFile()
    • getCoords

      public TextureCoords getCoords()
    • getHalfWidth

      public float getHalfWidth()
    • getHalfHeight

      public float getHalfHeight()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • isUseMipMap

      public boolean isUseMipMap()
    • setUseMipMap

      public void setUseMipMap(boolean useMipMap)
      Will apply if set before actually loading the texture.
      Parameters:
      useMipMap -
    • getTextureMagnificationFilter

      public int getTextureMagnificationFilter()
    • setTextureMagnificationFilter

      public void setTextureMagnificationFilter(int textureMagnificationFilter)
      Will apply if set before actually loading the texture. Possible values documented in https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexParameter.xhtml (see parameter GL_TEXTURE_MAG_FILTER) Use -1 to avoid magnification
      Parameters:
      textureMagnificationFilter -
    • getTextureMinificationFilter

      public int getTextureMinificationFilter()
    • setTextureMinificationFilter

      public void setTextureMinificationFilter(int textureMinificationFilter)
      Will apply if set before actually loading the texture. Possible values documented in https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexParameter.xhtml (see parameter GL_TEXTURE_MIN_FILTER) Use -1 to avoid minification
      Parameters:
      textureMinificationFilter -