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

public final Class SpriteShootout2P

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

Sprite rendering demo. In this version we're doing the animation computations on the GPU, using transform feedback and a vertex shader, then rendering is performed in 2 passes, with depth testing enabled: 1) Sprites are rendered front-to-back, opaque fragments only, blending is disabled. 2) Sprites are rendered back-to-front, transparent fragments only, blending is enabled. Sorting is free, because we're animating double the amount of sprites rendered, the first batch is sorted f2b, the second is sorted b2f. Ordering is achieved by modifying the z-axis position of the sprites in the vertex shader.
Author
Spasi
Since
18/3/2011

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract class
private class

Field Summary

Modifier and TypeField and Description
private boolean
private static final int
private int
private int
private boolean
private boolean
private SpriteShootout2P.SpriteRenderer
private boolean
private static final int
private 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
ANIMATION_TICKSback to summary
private static final int ANIMATION_TICKS
ballCountback to summary
private int ballCount
ballSizeback to summary
private int ballSize
colorMaskback to summary
private boolean colorMask
renderback to summary
private boolean render
rendererback to summary
private SpriteShootout2P.SpriteRenderer renderer
runback to summary
private boolean run
SCREEN_HEIGHTback to summary
private static final int SCREEN_HEIGHT
SCREEN_WIDTHback to summary
private 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

SpriteShootout2Pback to summary
private SpriteShootout2P()

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

private abstract Class SpriteShootout2P.SpriteRenderer

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

Field Summary

Modifier and TypeField and Description
protected int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
createPrograms(final int vshID)

protected abstract void
render(boolean render, boolean animate, int delta)

protected abstract void
updateBalls(final int count)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

progIDback to summary
protected int progID

Constructor Detail

SpriteRendererback to summary
private SpriteRenderer()

Method Detail

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

private Class SpriteShootout2P.SpriteRendererTF

extends SpriteRenderer
Class Inheritance

Field Summary

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

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.SpriteShootout2P.SpriteRenderer.render.

public void
public void
Inherited from org.lwjgl.test.opengl.sprites.SpriteShootout2P.SpriteRenderer:
createPrograms

Field Detail

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

Constructor Detail

SpriteRendererTFback to summary
pack-priv SpriteRendererTF()

Method Detail

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

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

updateBallsback to summary
public void updateBalls(final int count)

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

updateBallSizeback to summary
public void updateBallSize()

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