Top Description Inners Fields Constructors Methods
org.lwjgl.test.opengl.sprites

public final Class SpriteShootoutMapped

extends Object
Class Inheritance
Imports
org.lwjgl.BufferUtils, .LWJGLException, .Sys, org.lwjgl.input.Keyboard, .Mouse, org.lwjgl.opengl.*, org.lwjgl.util.mapped.MappedObject, .MappedObjectClassLoader, .MappedObjectTransformer, .MappedType, java.awt.image.BufferedImage, .Raster, java.io.IOException, java.nio.ByteBuffer, java.util.Random, javax.imageio.ImageIO

Sprite rendering demo. Three implementations are supported: a) CPU animation + BufferData VBO update. b) CPU animation + MapBufferRange VBO update. c) GPU animation using transform feedback with a vertex shader.
Author
Spasi
Since
18/3/2011

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
private abstract class
private abstract class
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private boolean
pack-priv long
private static final int
pack-priv int
pack-priv int
private boolean
private boolean
private SpriteShootoutMapped.SpriteRenderer
private boolean
pack-priv static final int
pack-priv static final int
private boolean
private int
private int
private int
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int
createTexture(final String path)

private void
private void
private void
public static void
main(String[] args)

private static byte
packUByte01(final float x)

private static ByteBuffer
private void
run()

private void
private static float
unpackUByte01(final byte x)

private void
updateBalls(final int count)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

animateback to summary
private boolean animate
animateTimeback to summary
pack-priv long animateTime
ANIMATION_TICKSback to summary
private static final int ANIMATION_TICKS
ballCountback to summary
pack-priv int ballCount
ballSizeback to summary
pack-priv int ballSize
colorMaskback to summary
private boolean colorMask
renderback to summary
private boolean render
rendererback to summary
private SpriteShootoutMapped.SpriteRenderer renderer
runback to summary
private boolean run
SCREEN_HEIGHTback to summary
pack-priv static final int SCREEN_HEIGHT
SCREEN_WIDTHback to summary
pack-priv static final int SCREEN_WIDTH
smoothback to summary
private boolean smooth
texBigIDback to summary
private int texBigID
texIDback to summary
private int texID
texSmallIDback to summary
private int texSmallID
vsyncback to summary
private boolean vsync

Constructor Detail

SpriteShootoutMappedback to summary
private SpriteShootoutMapped()

Method Detail

createTextureback to summary
private static int createTexture(final String path) throws IOException
destroyback to summary
private void destroy()
handleInputback to summary
private void handleInput()
initGLback to summary
private void initGL() throws LWJGLException
mainback to summary
public static void main(String[] args)
packUByte01back to summary
private static byte packUByte01(final float x)
readImageback to summary
private static ByteBuffer readImage(final BufferedImage img) throws IOException
runback to summary
private void run()
startback to summary
private void start() throws LWJGLException
unpackUByte01back to summary
private static float unpackUByte01(final byte x)
updateBallsback to summary
private void updateBalls(final int count)
org.lwjgl.test.opengl.sprites back to summary

public Class SpriteShootoutMapped.Pixel3b

extends MappedObject
Class Inheritance
Annotations
@MappedType
align:3

Field Summary

Modifier and TypeField and Description
public byte
b

public byte
g

public byte
r

Inherited from org.lwjgl.util.mapped.MappedObject:
baseAddressSIZEOFviewviewAddress

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.lwjgl.util.mapped.MappedObject:
asArraybackingByteBuffercapacitycopyRangecopyTodupforeachforeachgetAligngetSizeofgetViewAddressmallocmapmapnextrunViewConstructorsetViewAddressslice

Field Detail

bback to summary
public byte b
gback to summary
public byte g
rback to summary
public byte r

Constructor Detail

Pixel3bback to summary
public Pixel3b()
org.lwjgl.test.opengl.sprites back to summary

public Class SpriteShootoutMapped.Pixel4b

extends MappedObject
Class Inheritance

Field Summary

Modifier and TypeField and Description
public byte
a

public byte
b

public byte
g

public byte
r

Inherited from org.lwjgl.util.mapped.MappedObject:
baseAddressSIZEOFviewviewAddress

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.lwjgl.util.mapped.MappedObject:
asArraybackingByteBuffercapacitycopyRangecopyTodupforeachforeachgetAligngetSizeofgetViewAddressmallocmapmapnextrunViewConstructorsetViewAddressslice

Field Detail

aback to summary
public byte a
bback to summary
public byte b
gback to summary
public byte g
rback to summary
public byte r

Constructor Detail

Pixel4bback to summary
public Pixel4b()
org.lwjgl.test.opengl.sprites back to summary

public Class SpriteShootoutMapped.Sprite

extends MappedObject
Class Inheritance

Field Summary

Modifier and TypeField and Description
public float
public float
public float
x

public float
y

Inherited from org.lwjgl.util.mapped.MappedObject:
baseAddressSIZEOFviewviewAddress

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.lwjgl.util.mapped.MappedObject:
asArraybackingByteBuffercapacitycopyRangecopyTodupforeachforeachgetAligngetSizeofgetViewAddressmallocmapmapnextrunViewConstructorsetViewAddressslice

Field Detail

dxback to summary
public float dx
dyback to summary
public float dy
xback to summary
public float x
yback to summary
public float y

Constructor Detail

Spriteback to summary
public Sprite()
org.lwjgl.test.opengl.sprites back to summary

public Class SpriteShootoutMapped.SpriteRender

extends MappedObject
Class Inheritance

Field Summary

Modifier and TypeField and Description
public float
x

public float
y

Inherited from org.lwjgl.util.mapped.MappedObject:
baseAddressSIZEOFviewviewAddress

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.lwjgl.util.mapped.MappedObject:
asArraybackingByteBuffercapacitycopyRangecopyTodupforeachforeachgetAligngetSizeofgetViewAddressmallocmapmapnextrunViewConstructorsetViewAddressslice

Field Detail

xback to summary
public float x
yback to summary
public float y

Constructor Detail

SpriteRenderback to summary
public SpriteRender()
org.lwjgl.test.opengl.sprites back to summary

private abstract Class SpriteShootoutMapped.SpriteRenderer

extends Object
Class Inheritance
  • java.lang.Object
  • org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer
Known Direct Subclasses
org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched, org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererTF

Field Summary

Modifier and TypeField and Description
protected int
protected int
protected SpriteShootoutMapped.Sprite
protected int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
protected abstract void
render(boolean render, boolean animate, int delta)

public abstract void
updateBalls(int count)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

progIDback to summary
protected int progID
spriteCountback to summary
protected int spriteCount
spritesback to summary
protected SpriteShootoutMapped.Sprite sprites
vshIDback to summary
protected int vshID

Constructor Detail

SpriteRendererback to summary
private SpriteRenderer()

Method Detail

createProgramback to summary
protected void createProgram()
renderback to summary
protected abstract void render(boolean render, boolean animate, int delta)
updateBallsback to summary
public abstract void updateBalls(int count)
updateBallSizeback to summary
public void updateBallSize()
org.lwjgl.test.opengl.sprites back to summary

private abstract Class SpriteShootoutMapped.SpriteRendererBatched

extends SpriteRenderer
Class Inheritance
Known Direct Subclasses
org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererPlain, org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererMapped

Field Summary

Modifier and TypeField and Description
protected static final int
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer:
progIDspriteCountspritesvshID

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
animate(final SpriteShootoutMapped.Sprite sprite, final SpriteShootoutMapped.SpriteRender spriteRender, final int ballSize, final int ballIndex, final int batchSize, final int delta)

public void
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer:
createProgramrenderupdateBallSize

Field Detail

BALLS_PER_BATCHback to summary
protected static final int BALLS_PER_BATCH

Constructor Detail

SpriteRendererBatchedback to summary
pack-priv SpriteRendererBatched()

Method Detail

animateback to summary
protected void animate(final SpriteShootoutMapped.Sprite sprite, final SpriteShootoutMapped.SpriteRender spriteRender, final int ballSize, final int ballIndex, final int batchSize, final int delta)
updateBallsback to summary
public void updateBalls(final int count)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.updateBalls.

org.lwjgl.test.opengl.sprites back to summary

private Class SpriteShootoutMapped.SpriteRendererMapped

extends SpriteRendererBatched
Class Inheritance

Field Summary

Modifier and TypeField and Description
private StreamVBO
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched:
BALLS_PER_BATCH

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

public void
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched:
animate

Field Detail

animVBOback to summary
private StreamVBO animVBO

Constructor Detail

SpriteRendererMappedback to summary
pack-priv SpriteRendererMapped()

Method Detail

renderback to summary
public void render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

updateBallsback to summary
public void updateBalls(final int count)

Overrides org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched.updateBalls.

org.lwjgl.test.opengl.sprites back to summary

private Class SpriteShootoutMapped.SpriteRendererPlain

extends SpriteRendererBatched
Class Inheritance

Field Summary

Modifier and TypeField and Description
protected int[]
private final int
private SpriteShootoutMapped.SpriteRender
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched:
BALLS_PER_BATCH

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
animate(final int ballIndex, final int batchSize, final int delta)

public void
render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

public void
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched:
animate

Field Detail

animVBOback to summary
protected int[] animVBO
DATA_PER_BATCHback to summary
private final int DATA_PER_BATCH
spritesRenderback to summary
private SpriteShootoutMapped.SpriteRender spritesRender

Constructor Detail

SpriteRendererPlainback to summary
pack-priv SpriteRendererPlain()

Method Detail

animateback to summary
private void animate(final int ballIndex, final int batchSize, final int delta)
renderback to summary
public void render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

updateBallsback to summary
public void updateBalls(final int count)

Overrides org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRendererBatched.updateBalls.

org.lwjgl.test.opengl.sprites back to summary

private Class SpriteShootoutMapped.SpriteRendererTF

extends SpriteRenderer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private int
private int
private int
private int[]
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer:
progIDspriteCountspritesvshID

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
doUpdateBalls(final int count)

public void
render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

public void
public void
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer:
createProgram

Field Detail

ballSizeLocback to summary
private int ballSizeLoc
currVBOback to summary
private int currVBO
deltaLocback to summary
private int deltaLoc
progIDTFback to summary
private int progIDTF
tfVBOback to summary
private int[] tfVBO

Constructor Detail

SpriteRendererTFback to summary
pack-priv SpriteRendererTF()

Method Detail

doUpdateBallsback to summary
private void doUpdateBalls(final int count)
renderback to summary
public void render(final boolean render, final boolean animate, final int delta)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.render.

updateBallsback to summary
public void updateBalls(final int count)

Implements abstract org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.updateBalls.

updateBallSizeback to summary
public void updateBallSize()

Overrides org.lwjgl.test.opengl.sprites.SpriteShootoutMapped.SpriteRenderer.updateBallSize.