Package arc.graphics
Class GLTexture
java.lang.Object
arc.graphics.GLTexture
- All Implemented Interfaces:
Disposable
- Direct Known Subclasses:
Cubemap
,Texture
,TextureArray
Class representing an OpenGL texture by its target and handle. Keeps track of its state like the TextureFilter and TextureWrap.
Also provides some (protected) static methods to create TextureData and upload image data.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
final int
The target of this texture, used when binding the texture, e.g.int
Do not change.protected Texture.TextureFilter
protected Texture.TextureFilter
protected Texture.TextureWrap
protected Texture.TextureWrap
int
Do not change. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
Binds this texture.void
bind
(int unit) Binds the texture to the given texture unit.void
dispose()
Releases all resources of this object.abstract int
getDepth()
int
getUWrap()
getVWrap()
void
setFilter
(Texture.TextureFilter filter) void
setFilter
(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter) Sets theTexture.TextureFilter
for this texture for minification and magnification.void
setWrap
(Texture.TextureWrap wrap) void
Sets theTexture.TextureWrap
for this texture on the u and v axis.void
unsafeSetFilter
(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter) Sets theTexture.TextureFilter
for this texture for minification and magnification.void
unsafeSetFilter
(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force) Sets theTexture.TextureFilter
for this texture for minification and magnification.void
Sets theTexture.TextureWrap
for this texture on the u and v axis.void
unsafeSetWrap
(Texture.TextureWrap u, Texture.TextureWrap v, boolean force) Sets theTexture.TextureWrap
for this texture on the u and v axis.protected static void
uploadImageData
(int target, TextureData data) static void
uploadImageData
(int target, TextureData data, int miplevel) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface arc.util.Disposable
isDisposed
-
Field Details
-
glTarget
public final int glTargetThe target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D -
width
public int widthDo not change. This is read-only and only set after texture data is loaded. -
height
public int heightDo not change. This is read-only and only set after texture data is loaded. -
glHandle
protected int glHandle -
minFilter
-
magFilter
-
uWrap
-
vWrap
-
-
Constructor Details
-
GLTexture
public GLTexture(int glTarget) Generates a new OpenGL texture with the specified target. -
GLTexture
public GLTexture(int glTarget, int glHandle)
-
-
Method Details
-
uploadImageData
-
uploadImageData
-
getDepth
public abstract int getDepth()- Returns:
- the depth of the texture in pixels
-
bind
public void bind()Binds this texture. The texture will be bound to the currently active texture unit specified viaGL20.glActiveTexture(int)
. -
bind
public void bind(int unit) Binds the texture to the given texture unit. Sets the currently active texture unit viaGL20.glActiveTexture(int)
.- Parameters:
unit
- the unit (0 to MAX_TEXTURE_UNITS).
-
getMinFilter
- Returns:
- The
Texture.TextureFilter
used for minification.
-
getMagFilter
- Returns:
- The
Texture.TextureFilter
used for magnification.
-
getUWrap
- Returns:
- The
Texture.TextureWrap
used for horizontal (U) texture coordinates.
-
getVWrap
- Returns:
- The
Texture.TextureWrap
used for vertical (V) texture coordinates.
-
getTextureObjectHandle
public int getTextureObjectHandle()- Returns:
- The OpenGL handle for this texture.
-
unsafeSetWrap
Sets theTexture.TextureWrap
for this texture on the u and v axis. Assumes the texture is bound and active!- Parameters:
u
- the u wrapv
- the v wrap
-
unsafeSetWrap
Sets theTexture.TextureWrap
for this texture on the u and v axis. Assumes the texture is bound and active!- Parameters:
u
- the u wrapv
- the v wrapforce
- True to always set the values, even if they are the same as the current values.
-
setWrap
-
setWrap
Sets theTexture.TextureWrap
for this texture on the u and v axis. This will bind this texture!- Parameters:
u
- the u wrapv
- the v wrap
-
unsafeSetFilter
Sets theTexture.TextureFilter
for this texture for minification and magnification. Assumes the texture is bound and active!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filter
-
unsafeSetFilter
public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force) Sets theTexture.TextureFilter
for this texture for minification and magnification. Assumes the texture is bound and active!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filterforce
- True to always set the values, even if they are the same as the current values.
-
setFilter
-
setFilter
Sets theTexture.TextureFilter
for this texture for minification and magnification. This will bind this texture!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filter
-
dispose
public void dispose()Description copied from interface:Disposable
Releases all resources of this object.- Specified by:
dispose
in interfaceDisposable
-