de.javagl.simplerenderer
Class RenderingUtils

java.lang.Object
  extended by de.javagl.simplerenderer.RenderingUtils

public class RenderingUtils
extends java.lang.Object

Utility methods for rendering


Method Summary
static java.nio.ByteBuffer createByteBuffer(int size)
          Create a direct byte buffer with the given size
static java.nio.ByteBuffer createDirectBuffer(byte[] a)
          Create a direct byte buffer which has the contents of the given array.
static java.nio.FloatBuffer createDirectBuffer(float[] a)
          Create a direct float buffer which has the contents of the given array.
static java.nio.IntBuffer createDirectBuffer(int[] a)
          Create a direct int buffer which has the contents of the given array.
static java.nio.FloatBuffer createFloatBuffer(int size)
          Create a direct float buffer with the given size
static java.nio.IntBuffer createIntBuffer(int size)
          Create a direct int buffer with the given size
static float[] identity()
          Creates an identity matrix
static float[] multiply(float[] m0, float[] m1)
          Multiplies the given matrices and returns the result
static float[] perspective(float fovy, float aspect, float zNear, float zFar)
          Helper method that creates a perspective matrix
static float[] rotationX(float angleDeg)
          Creates a matrix describing a rotation around the x-axis
static float[] rotationY(float angleDeg)
          Creates a matrix describing a rotation around the y-axis
static float[] translation(float x, float y, float z)
          Creates a translation matrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(int size)
Create a direct byte buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(int size)
Create a direct float buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(int size)
Create a direct int buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createDirectBuffer

public static java.nio.ByteBuffer createDirectBuffer(byte[] a)
Create a direct byte buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

createDirectBuffer

public static java.nio.IntBuffer createDirectBuffer(int[] a)
Create a direct int buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

createDirectBuffer

public static java.nio.FloatBuffer createDirectBuffer(float[] a)
Create a direct float buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

perspective

public static float[] perspective(float fovy,
                                  float aspect,
                                  float zNear,
                                  float zFar)
Helper method that creates a perspective matrix

Parameters:
fovy - The fov in y-direction, in degrees
aspect - The aspect ratio
zNear - The near clipping plane
zFar - The far clipping plane
Returns:
A perspective matrix

identity

public static float[] identity()
Creates an identity matrix

Returns:
An identity matrix

multiply

public static float[] multiply(float[] m0,
                               float[] m1)
Multiplies the given matrices and returns the result

Parameters:
m0 - The first matrix
m1 - The second matrix
Returns:
The product m0*m1

translation

public static float[] translation(float x,
                                  float y,
                                  float z)
Creates a translation matrix

Parameters:
x - The x translation
y - The y translation
z - The z translation
Returns:
A translation matrix

rotationX

public static float[] rotationX(float angleDeg)
Creates a matrix describing a rotation around the x-axis

Parameters:
angleDeg - The rotation angle, in degrees
Returns:
The rotation matrix

rotationY

public static float[] rotationY(float angleDeg)
Creates a matrix describing a rotation around the y-axis

Parameters:
angleDeg - The rotation angle, in degrees
Returns:
The rotation matrix