28package com.jogamp.opengl.util;
30import java.nio.FloatBuffer;
31import java.nio.IntBuffer;
33import com.jogamp.opengl.GL;
34import com.jogamp.opengl.GLException;
35import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
37import com.jogamp.math.FloatUtil;
38import com.jogamp.math.Matrix4f;
39import com.jogamp.math.Quaternion;
40import com.jogamp.math.Recti;
41import com.jogamp.math.Vec3f;
42import com.jogamp.math.geom.Frustum;
43import com.jogamp.math.util.PMVMatrix4f;
69 switch(matrixModeName) {
83 switch(matrixModeName) {
91 throw new GLException(
"unsupported matrixName: "+matrixModeName);
100 switch(matrixGetName) {
115 switch(matrixGetName) {
123 throw new GLException(
"unsupported matrixGetName: "+matrixGetName);
162 super(derivedMatrices);
191 return getMat(matrixMode);
213 throw new GLException(
"unsupported matrixName: "+matrixName);
225 throw new GLException(
"unsupported matrixName: "+matrixName);
227 matrixMode = matrixName;
231 public final void glGetFloatv(
final int matrixGetName,
final FloatBuffer params) {
232 final int pos = params.position();
234 params.put(matrixMode);
238 params.position(pos);
242 public final void glGetFloatv(
final int matrixGetName,
final float[] params,
final int params_offset) {
244 params[params_offset]=matrixMode;
246 getMat(matrixGetName).
get(params, params_offset);
252 final int pos = params.position();
254 params.put(matrixMode);
256 throw new GLException(
"unsupported pname: "+pname);
258 params.position(pos);
262 public final void glGetIntegerv(
final int pname,
final int[] params,
final int params_offset) {
264 params[params_offset]=matrixMode;
266 throw new GLException(
"unsupported pname: "+pname);
275 loadP(values, offset);
277 loadT(values, offset);
337 final int spos = m.position();
379 public final void glTranslatef(
final float x,
final float y,
final float z) {
396 public final void glScalef(
final float x,
final float y,
final float z) {
413 public final void glRotatef(
final float ang_deg,
final float x,
final float y,
final float z) {
469 public final void glOrthof(
final float left,
final float right,
final float bottom,
final float top,
final float zNear,
final float zFar) {
481 public final void glFrustumf(
final float left,
final float right,
final float bottom,
final float top,
final float zNear,
final float zFar)
throws IllegalArgumentException {
499 public final void gluPerspective(
final float fovy_rad,
final float aspect,
final float zNear,
final float zFar)
throws IllegalArgumentException {
525 public final void gluPickMatrix(
final float x,
final float y,
final float deltaX,
final float deltaY,
final Recti viewport) {
Basic Float math utility functions.
static float adegToRad(final float arc_degree)
Converts arc-degree to radians.
Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).
Matrix4f load(final Matrix4f src)
Load the values of the given matrix src to this matrix.
Matrix4f setToPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Set this matrix to perspective frustum projection.
final Matrix4f setToRotation(final Quaternion q)
Set this matrix to rotation using the given Quaternion.
float get(final int i)
Gets the ith component, 0 <= i < 16.
final Matrix4f setToRotationAxis(final float ang_rad, float x, float y, float z)
Set this matrix to rotation from the given axis and angle in radians.
Matrix4f setToOrtho(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Set this matrix to orthogonal projection.
Matrix4f setToLookAt(final Vec3f eye, final Vec3f center, final Vec3f up, final Matrix4f tmp)
Set this matrix to the look-at matrix based on given parameters.
Matrix4f setToPick(final float x, final float y, final float deltaX, final float deltaY, final Recti viewport, final Matrix4f mat4Tmp)
Set this matrix to the pick matrix based on given parameters.
final Matrix4f setToScale(final float x, final float y, final float z)
Set this matrix to scale.
Matrix4f setToFrustum(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Set this matrix to frustum.
final Matrix4f setToTranslation(final float x, final float y, final float z)
Set this matrix to translation.
Quaternion implementation supporting Gimbal-Lock free rotations.
Rectangle with x, y, width and height integer components.
3D Vector based upon three float components.
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
final PMVMatrix4f mulMv(final Matrix4f m)
Multiply the modelview matrix: [c] = [c] x [m].
final PMVMatrix4f loadTIdentity()
Load the texture matrix with the values of the given Matrix4f.
final PMVMatrix4f loadMv(final float[] values, final int offset)
Load the modelview matrix with the provided values.
final PMVMatrix4f loadMvIdentity()
Load the modelview matrix with the values of the given Matrix4f.
final PMVMatrix4f pushP()
Push the projection matrix to its stack, while preserving its values.
final PMVMatrix4f loadP(final float[] values, final int offset)
Load the projection matrix with the provided values.
final PMVMatrix4f mulT(final Matrix4f m)
Multiply the texture matrix: [c] = [c] x [m].
final PMVMatrix4f mulP(final Matrix4f m)
Multiply the projection matrix: [c] = [c] x [m].
final PMVMatrix4f popP()
Pop the projection matrix from its stack.
final PMVMatrix4f popT()
Pop the texture matrix from its stack.
final PMVMatrix4f loadPIdentity()
Load the projection matrix with the values of the given Matrix4f.
final Matrix4f getTmp2Mat()
Return the second temporary Matrix4f exposed to be reused for efficiency.
final PMVMatrix4f popMv()
Pop the modelview matrix from its stack.
final PMVMatrix4f loadT(final float[] values, final int offset)
Load the texture matrix with the provided values.
final PMVMatrix4f pushMv()
Push the modelview matrix to its stack, while preserving its values.
final PMVMatrix4f pushT()
Push the texture matrix to its stack, while preserving its values.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
final void glTranslatef(final float x, final float y, final float z)
Translate the current matrix.
final void glScalef(final float x, final float y, final float z)
Scale the current matrix.
void reset()
Issues Matrix4f#loadIdentity() on all matrices and resets all internal states.
final PMVMatrix glRotate(final Quaternion quat)
Rotate the current matrix with the given Quaternion's rotation matrix representation.
final void glMultMatrixf(final float[] m, final int m_offset)
Multiply the current matrix: [c] = [c] x [m].
final void glMultMatrixf(final FloatBuffer m)
final void glGetIntegerv(final int pname, final int[] params, final int params_offset)
final PMVMatrix glMultMatrixf(final Matrix4f m)
Multiply the current matrix: [c] = [c] x [m].
static final boolean isMatrixModeName(final int matrixModeName)
static final boolean isMatrixGetName(final int matrixGetName)
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
final Matrix4f getMat(final int matrixName)
final void glGetIntegerv(final int pname, final IntBuffer params)
glGetIntegerv
final PMVMatrix glRotatef(final float ang_rad, final Vec3f axis)
Rotate the current matrix by the given axis and angle in radians.
final PMVMatrix glScalef(final Vec3f s)
Scale the current matrix.
final void glLoadMatrixf(final java.nio.FloatBuffer m)
Load the current matrix w/ the provided one.
final void glGetFloatv(final int matrixGetName, final FloatBuffer params)
final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Multiply the current matrix with the orthogonal matrix.
static final int matrixGetName2MatrixModeName(final int matrixGetName)
static final int matrixModeName2MatrixGetName(final int matrixModeName)
final void glLoadMatrixf(final Matrix4f m)
Load the current matrix with the values of the given Matrix4f.
final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Multiply the current matrix with the perspective/frustum matrix.
final void glPushMatrix()
Push the current matrix to it's stack, while preserving it's values.
final PMVMatrix glTranslatef(final Vec3f t)
Translate the current matrix.
final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Multiply the current matrix with the frustum matrix.
final void glLoadMatrix(final Quaternion quat)
Load the current matrix with the values of the given Quaternion's rotation matrix representation.
final Matrix4f getCurrentMat()
final void glRotatef(final float ang_deg, final float x, final float y, final float z)
Rotate the current matrix.
final void gluLookAt(final Vec3f eye, final Vec3f center, final Vec3f up)
Multiply the current matrix with the eye, object and orientation, i.e.
final void gluPickMatrix(final float x, final float y, final float deltaX, final float deltaY, final Recti viewport)
Make given matrix the pick matrix based on given parameters.
PMVMatrix()
Creates an instance of PMVMatrix.
final void glPopMatrix()
Pop the current matrix from it's stack.
final void glGetFloatv(final int matrixGetName, final float[] params, final int params_offset)
Copy the named matrix to the given storage at offset.
final int glGetMatrixMode()
Returns the current matrix-mode, one of GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE.
final void glLoadIdentity()
Load the current matrix with the identity matrix.
PMVMatrix(final int derivedMatrices)
Creates an instance of PMVMatrix.
final void glLoadMatrixf(final float[] values, final int offset)
Load the current matrix w/ the provided one.
static final int GL_TEXTURE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TEXTURE" with express...
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW_MATRIX
Matrix access name for modelview.
static final int GL_MATRIX_MODE
static final int GL_TEXTURE_MATRIX
Matrix access name for texture.
static final int GL_MODELVIEW
Matrix mode modelview.
static final int GL_PROJECTION_MATRIX
Matrix access name for projection.