Top Description Fields Constructors Methods
org.lwjgl.examples.spaceinvaders

public Class Texture

extends Object
Class Inheritance
Static Imports
org.lwjgl.opengl.GL11.*

A texture to be bound within OpenGL. This object is responsible for keeping track of a given OpenGL texture and for calculating the texturing mapping coordinates of the full image. Since textures need to be powers of 2 the actual texture may be considerably bigged that the source image and hence the texture mapping coordinates need to be adjusted to matchup drawing the sprite against the texture.
Authors
Kevin Glass, Brian Matzon

Field Summary

Modifier and TypeField and Description
private int
height

The height of the image

private float
heightRatio

The ratio of the height of the image to the texture

private int
target

The GL target type

private int
texHeight

The height of the texture

private int
textureID

The GL texture ID

private int
texWidth

The width of the texture

private int
width

The width of the image

private float
widthRatio

The ratio of the width of the image to the texture

Constructor Summary

AccessConstructor and Description
public
Texture(int
The GL target
target
,
int
The GL texture ID
textureID
)

Create a new texture

Method Summary

Modifier and TypeMethod and Description
public void
bind()

Bind the specified GL context to a texture

public float

Returns:

The height of physical texture
getHeight
()

Get the height of the physical texture

public int

Returns:

The height of the original image
getImageHeight
()

Get the height of the original image

public int

Returns:

The width of the original image
getImageWidth
()

Get the width of the original image

public float

Returns:

The width of physical texture
getWidth
()

Get the width of the physical texture

public void
setHeight(int
The height of the image
height
)

Set the height of the image

private void
setHeight()

Set the height of the texture.

public void
setTextureHeight(int
The height of the texture
texHeight
)

Set the height of this texture

public void
setTextureWidth(int
The width of the texture
texWidth
)

Set the width of this texture

public void
setWidth(int
The width of the image
width
)

Set the width of the image

private void
setWidth()

Set the width of the texture.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

heightback to summary
private int height

The height of the image

heightRatioback to summary
private float heightRatio

The ratio of the height of the image to the texture

targetback to summary
private int target

The GL target type

texHeightback to summary
private int texHeight

The height of the texture

textureIDback to summary
private int textureID

The GL texture ID

texWidthback to summary
private int texWidth

The width of the texture

widthback to summary
private int width

The width of the image

widthRatioback to summary
private float widthRatio

The ratio of the width of the image to the texture

Constructor Detail

Textureback to summary
public Texture(int target, int textureID)

Create a new texture

Parameters
target:int

The GL target

textureID:int

The GL texture ID

Method Detail

bindback to summary
public void bind()

Bind the specified GL context to a texture

getHeightback to summary
public float getHeight()

Get the height of the physical texture

Returns:float

The height of physical texture

getImageHeightback to summary
public int getImageHeight()

Get the height of the original image

Returns:int

The height of the original image

getImageWidthback to summary
public int getImageWidth()

Get the width of the original image

Returns:int

The width of the original image

getWidthback to summary
public float getWidth()

Get the width of the physical texture

Returns:float

The width of physical texture

setHeightback to summary
public void setHeight(int height)

Set the height of the image

Parameters
height:int

The height of the image

setHeightback to summary
private void setHeight()

Set the height of the texture. This will update the ratio also.

setTextureHeightback to summary
public void setTextureHeight(int texHeight)

Set the height of this texture

Parameters
texHeight:int

The height of the texture

setTextureWidthback to summary
public void setTextureWidth(int texWidth)

Set the width of this texture

Parameters
texWidth:int

The width of the texture

setWidthback to summary
public void setWidth(int width)

Set the width of the image

Parameters
width:int

The width of the image

setWidthback to summary
private void setWidth()

Set the width of the texture. This will update the ratio also.