|
JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java (public API).
|
Static Public Member Functions | |
| static TextureData | newTextureData (final GLProfile glp, final File file, final boolean mipmap, String fileSuffix) throws IOException |
| Creates a TextureData from the given file. More... | |
| static TextureData | newTextureData (final GLProfile glp, final InputStream stream, final boolean mipmap, final String fileSuffix) throws IOException |
| Creates a TextureData from the given stream. More... | |
| static TextureData | newTextureData (final GLProfile glp, final URL url, final boolean mipmap, String fileSuffix) throws IOException |
| Creates a TextureData from the given URL. More... | |
| static TextureData | newTextureData (final GLProfile glp, final File file, final int internalFormat, final int pixelFormat, final boolean mipmap, String fileSuffix) throws IOException, IllegalArgumentException |
| Creates a TextureData from the given file, using the specified OpenGL internal format and pixel format for the texture which will eventually result. More... | |
| static TextureData | newTextureData (final GLProfile glp, final InputStream stream, final int internalFormat, final int pixelFormat, final boolean mipmap, final String fileSuffix) throws IOException, IllegalArgumentException |
| Creates a TextureData from the given stream, using the specified OpenGL internal format and pixel format for the texture which will eventually result. More... | |
| static TextureData | newTextureData (final GLProfile glp, final URL url, final int internalFormat, final int pixelFormat, final boolean mipmap, String fileSuffix) throws IOException, IllegalArgumentException |
| Creates a TextureData from the given URL, using the specified OpenGL internal format and pixel format for the texture which will eventually result. More... | |
| static Texture | newTexture (final TextureData data) throws GLException, IllegalArgumentException |
| Creates an OpenGL texture object from the specified TextureData using the current OpenGL context. More... | |
| static Texture | newTexture (final GL gl, final TextureData data) throws GLException, IllegalArgumentException |
| Creates an OpenGL texture object from the specified TextureData using the given OpenGL context. More... | |
| static Texture | newTexture (final File file, final boolean mipmap) throws IOException, GLException |
| Creates an OpenGL texture object from the specified file using the current OpenGL context. More... | |
| static Texture | newTexture (final InputStream stream, final boolean mipmap, final String fileSuffix) throws IOException, GLException |
| Creates an OpenGL texture object from the specified stream using the current OpenGL context. More... | |
| static Texture | newTexture (final URL url, final boolean mipmap, String fileSuffix) throws IOException, GLException |
| Creates an OpenGL texture object from the specified URL using the current OpenGL context. More... | |
| static Texture | newTexture (final int target) |
| Creates an OpenGL texture object associated with the given OpenGL texture target. More... | |
| static void | write (final Texture texture, final File file) throws IOException, GLException |
| Writes the given texture to a file. More... | |
| static void | write (final TextureData data, final File file) throws IOException, GLException |
| static void | addTextureProvider (final TextureProvider provider) |
Adds a TextureProvider to support reading of a new file format. More... | |
| static void | addTextureWriter (final TextureWriter writer) |
| Adds a TextureWriter to support writing of a new file format. More... | |
| static void | setTexRectEnabled (final boolean enabled) |
| Toggles the use of the GL_ARB_texture_rectangle extension by the TextureIO classes. More... | |
| static boolean | isTexRectEnabled () |
Indicates whether the GL_ARB_texture_rectangle extension is allowed to be used for non-power-of-two textures; see setTexRectEnabled. More... | |
Static Public Attributes | |
| static final String | DDS = ImageType.T_DDS |
| Constant which can be used as a file suffix to indicate a DirectDraw Surface file, value {@value}. More... | |
| static final String | SGI = "sgi" |
| Constant which can be used as a file suffix to indicate an SGI RGB file, value {@value}. More... | |
| static final String | SGI_RGB = ImageType.T_SGI_RGB |
| Constant which can be used as a file suffix to indicate an SGI RGB file, value {@value}. More... | |
| static final String | GIF = ImageType.T_GIF |
| Constant which can be used as a file suffix to indicate a GIF file, value {@value}. More... | |
| static final String | JPG = ImageType.T_JPG |
| Constant which can be used as a file suffix to indicate a JPEG file, value {@value}. More... | |
| static final String | PNG = ImageType.T_PNG |
| Constant which can be used as a file suffix to indicate a PNG file, value {@value}. More... | |
| static final String | TGA = ImageType.T_TGA |
| Constant which can be used as a file suffix to indicate a Targa file, value {@value}. More... | |
| static final String | TIFF = ImageType.T_TIFF |
| Constant which can be used as a file suffix to indicate a TIFF file, value {@value}. More... | |
| static final String | PAM = ImageType.T_PAM |
| Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 7 - binary RGB and RGBA. More... | |
| static final String | PPM = ImageType.T_PPM |
| Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 6 - binary RGB. More... | |
Provides input and output facilities for both loading OpenGL textures from disk and streams as well as writing textures already in memory back to disk.
The TextureIO class supports an arbitrary number of plug-in readers and writers via TextureProviders and TextureWriters. TextureProviders know how to produce TextureData objects from files, InputStreams and URLs. TextureWriters know how to write TextureData objects to disk in various file formats. The TextureData class represents the raw data of the texture before it has been converted to an OpenGL texture object. The Texture class represents the OpenGL texture object and provides easy facilities for using the texture.
There are several built-in TextureProviders and TextureWriters supplied with the TextureIO implementation. The most basic provider uses the platform's Image I/O facilities to read in a BufferedImage and convert it to a texture. This is the baseline provider and is registered so that it is the last one consulted. All others are asked first to open a given file.
There are three other providers registered by default as of the time of this writing. One handles SGI RGB (".sgi", ".rgb") images from both files and streams. One handles DirectDraw Surface (".dds") images read from files, though can not read these images from streams. One handles Targa (".tga") images read from both files and streams. These providers are executed in an arbitrary order. Some of these providers require the file's suffix to either be specified via the newTextureData methods or for the file to be named with the appropriate suffix. In general a file suffix should be provided to the newTexture and newTextureData methods if at all possible.
Note that additional TextureProviders, if reading images from InputStreams, must use the mark()/reset() methods on InputStream when probing for e.g. magic numbers at the head of the file to make sure not to disturb the state of the InputStream for downstream TextureProviders.
There are analogous TextureWriters provided for writing textures back to disk if desired. As of this writing, there are four TextureWriters registered by default: one for Targa files, one for SGI RGB files, one for DirectDraw surface (.dds) files, and one for ImageIO-supplied formats such as .jpg and .png. Some of these writers have certain limitations such as only being able to write out textures stored in GL_RGB or GL_RGBA format. The DDS writer supports fetching and writing to disk of texture data in DXTn compressed format. Whether this will occur is dependent on whether the texture's internal format is one of the DXTn compressed formats and whether the target file is .dds format.
Definition at line 138 of file TextureIO.java.
|
static |
Adds a TextureProvider to support reading of a new file format.
The last provider added, will be the first provider to be tested.
The TextureProvider is being mapped to its supporting ImageTypes allowing an O(1) association, if TextureProvider#
Definition at line 708 of file TextureIO.java.
|
static |
Adds a TextureWriter to support writing of a new file format.
The last provider added, will be the first provider to be tested.
Definition at line 728 of file TextureIO.java.
|
static |
Indicates whether the GL_ARB_texture_rectangle extension is allowed to be used for non-power-of-two textures; see setTexRectEnabled.
Definition at line 760 of file TextureIO.java.
|
static |
Creates an OpenGL texture object from the specified file using the current OpenGL context.
| file | the file from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| IOException | if an error occurred while reading the file |
| GLException | if no OpenGL context is current or if an OpenGL error occurred |
Definition at line 494 of file TextureIO.java.
|
static |
Creates an OpenGL texture object from the specified TextureData using the given OpenGL context.
| data | the texture data to turn into an OpenGL texture |
| GLException | if no OpenGL context is current or if an OpenGL error occurred |
| IllegalArgumentException | if the passed TextureData was null |
Definition at line 472 of file TextureIO.java.
|
static |
Creates an OpenGL texture object from the specified stream using the current OpenGL context.
| stream | the stream from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IOException | if an error occurred while reading the stream |
| GLException | if no OpenGL context is current or if an OpenGL error occurred |
Definition at line 523 of file TextureIO.java.
|
static |
Creates an OpenGL texture object associated with the given OpenGL texture target.
The texture has no initial data. This is used, for example, to construct cube maps out of multiple TextureData objects.
| target | the OpenGL target type, eg GL.GL_TEXTURE_2D, GL.GL_TEXTURE_RECTANGLE_ARB |
Definition at line 573 of file TextureIO.java.
|
static |
Creates an OpenGL texture object from the specified TextureData using the current OpenGL context.
| data | the texture data to turn into an OpenGL texture |
| GLException | if no OpenGL context is current or if an OpenGL error occurred |
| IllegalArgumentException | if the passed TextureData was null |
Definition at line 459 of file TextureIO.java.
|
static |
Creates an OpenGL texture object from the specified URL using the current OpenGL context.
| url | the URL from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IOException | if an error occurred while reading the URL |
| GLException | if no OpenGL context is current or if an OpenGL error occurred |
Definition at line 552 of file TextureIO.java.
|
static |
Creates a TextureData from the given file.
Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| file | the file from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IOException | if an error occurred while reading the file |
Definition at line 233 of file TextureIO.java.
|
static |
Creates a TextureData from the given file, using the specified OpenGL internal format and pixel format for the texture which will eventually result.
The internalFormat and pixelFormat must be specified and may not be zero; to use default values, use the variant of this method which does not take these arguments. Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| file | the file from which to read the texture data |
| internalFormat | the OpenGL internal format of the texture which will eventually result from the TextureData |
| pixelFormat | the OpenGL pixel format of the texture which will eventually result from the TextureData |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IllegalArgumentException | if either internalFormat or pixelFormat was 0 |
| IOException | if an error occurred while reading the file |
Definition at line 338 of file TextureIO.java.
|
static |
Creates a TextureData from the given stream.
Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| stream | the stream from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IOException | if an error occurred while reading the stream |
Definition at line 263 of file TextureIO.java.
|
static |
Creates a TextureData from the given stream, using the specified OpenGL internal format and pixel format for the texture which will eventually result.
The internalFormat and pixelFormat must be specified and may not be zero; to use default values, use the variant of this method which does not take these arguments. Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| stream | the stream from which to read the texture data |
| internalFormat | the OpenGL internal format of the texture which will eventually result from the TextureData |
| pixelFormat | the OpenGL pixel format of the texture which will eventually result from the TextureData |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IllegalArgumentException | if either internalFormat or pixelFormat was 0 |
| IOException | if an error occurred while reading the stream |
Definition at line 386 of file TextureIO.java.
|
static |
Creates a TextureData from the given URL.
Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| url | the URL from which to read the texture data |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IOException | if an error occurred while reading the URL |
Definition at line 290 of file TextureIO.java.
|
static |
Creates a TextureData from the given URL, using the specified OpenGL internal format and pixel format for the texture which will eventually result.
The internalFormat and pixelFormat must be specified and may not be zero; to use default values, use the variant of this method which does not take these arguments. Does no OpenGL work.
| glp | the OpenGL Profile this texture data should be created for. |
| url | the URL from which to read the texture data |
| internalFormat | the OpenGL internal format of the texture which will eventually result from the TextureData |
| pixelFormat | the OpenGL pixel format of the texture which will eventually result from the TextureData |
| mipmap | whether mipmaps should be produced for this texture either by autogenerating them or reading them from the file. Some file formats support multiple mipmaps in a single file in which case those mipmaps will be used rather than generating them. |
| fileSuffix | the suffix of the file name to be used as a hint of the file format to the underlying texture provider, or null if none and should be auto-detected (some texture providers do not support this) |
| IllegalArgumentException | if either internalFormat or pixelFormat was 0 |
| IOException | if an error occurred while reading the URL |
Definition at line 430 of file TextureIO.java.
|
static |
Toggles the use of the GL_ARB_texture_rectangle extension by the TextureIO classes.
By default, on hardware supporting this extension, the TextureIO classes may use the GL_ARB_texture_rectangle extension for non-power-of-two textures. (If the hardware supports the GL_ARB_texture_non_power_of_two extension, that one is preferred.) In some situations, for example when writing shaders, it is advantageous to force the texture target to always be GL_TEXTURE_2D in order to have one version of the shader, even at the expense of texture memory in the case where NPOT textures are not supported. This method allows the use of the GL_ARB_texture_rectangle extension to be turned off globally for this purpose. The default is that the use of the extension is enabled.
Definition at line 753 of file TextureIO.java.
|
static |
Writes the given texture to a file.
The type of the file is inferred from its suffix. An OpenGL context must be current in order to fetch the texture data back from the OpenGL pipeline. This method causes the specified Texture to be bound to the GL_TEXTURE_2D state. If no suitable writer for the requested file format was found, throws an IOException.
Reasonable attempts are made to produce good results in the resulting images. The Targa, SGI and ImageIO writers produce results in the correct vertical orientation for those file formats. The DDS writer performs no vertical flip of the data, even in uncompressed mode. (It is impossible to perform such a vertical flip with compressed data.) Applications should keep this in mind when using this routine to save textures to disk for later re-loading.
Any mipmaps for the specified texture are currently discarded when it is written to disk, regardless of whether the underlying file format supports multiple mipmaps in a given file.
Method required a GL2GL3 profile.
| IOException | if an error occurred during writing or no suitable writer was found |
| GLException | if no OpenGL context was current or an OpenGL-related error occurred |
Definition at line 607 of file TextureIO.java.
|
static |
|
static |
Constant which can be used as a file suffix to indicate a DirectDraw Surface file, value {@value}.
Alias for ImageType#T_DDS.
Definition at line 143 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a GIF file, value {@value}.
Alias for ImageType#T_GIF.
Definition at line 161 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a JPEG file, value {@value}.
Alias for ImageType#T_JPG.
Definition at line 166 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 7 - binary RGB and RGBA.
Write support only, value {@value}.
Alias for ImageType#T_PAM.
Definition at line 187 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
Alias for ImageType#T_PNG.
Definition at line 171 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 6 - binary RGB.
Write support only, value {@value}.
Alias for ImageType#T_PPM.
Definition at line 193 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate an SGI RGB file, value {@value}.
Same semantics as ImageType#SGI_RGB and SGI_RGB.
Definition at line 151 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate an SGI RGB file, value {@value}.
Alias for ImageType#T_SGI_RGB.
Definition at line 156 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a Targa file, value {@value}.
Alias for ImageType#T_TGA.
Definition at line 176 of file TextureIO.java.
|
static |
Constant which can be used as a file suffix to indicate a TIFF file, value {@value}.
Alias for ImageType#T_TIFF.
Definition at line 181 of file TextureIO.java.