JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
FixedFuncUtil.java
Go to the documentation of this file.
1/*
2 * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
3 */
4
5package com.jogamp.opengl.util.glsl.fixedfunc;
6
7import com.jogamp.math.util.PMVMatrix4f;
8import com.jogamp.opengl.GL;
9import com.jogamp.opengl.GL2ES1;
10import com.jogamp.opengl.GL2ES2;
11import com.jogamp.opengl.GLContext;
12import com.jogamp.opengl.GLException;
13import com.jogamp.opengl.fixedfunc.GLPointerFuncUtil;
14
15import jogamp.opengl.util.glsl.fixedfunc.FixedFuncHook;
16import jogamp.opengl.util.glsl.fixedfunc.FixedFuncImpl;
17import jogamp.opengl.util.glsl.fixedfunc.FixedFuncPipeline;
18
19import com.jogamp.opengl.util.PMVMatrix;
20
21
22/**
23 * Tool to pipeline GL2ES2 into a fixed function emulation implementing GL2ES1.
24 */
25public class FixedFuncUtil {
26 /**
27 * @param gl
28 * @param mode one of the {@link ShaderSelectionMode}s
29 * @param pmvMatrix optional pass through PMVMatrix for the {@link FixedFuncHook} and {@link FixedFuncPipeline}
30 * @return If gl is a GL2ES1 and force is false, return the type cast object,
31 * otherwise create a fixed function emulation pipeline using the given GL2ES2 impl
32 * and hook it to the GLContext via {@link GLContext#setGL(GL)}.
33 * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2
34 *
35 * @see ShaderSelectionMode#AUTO
36 * @see ShaderSelectionMode#COLOR
37 * @see ShaderSelectionMode#COLOR_LIGHT_PER_VERTEX
38 * @see ShaderSelectionMode#COLOR_TEXTURE
39 * @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX
40 */
41 public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, final boolean force, final boolean verbose) {
42 if(gl.isGL2ES2() && ( !gl.isGL2ES1() || force ) ) {
43 final GL2ES2 es2 = gl.getGL2ES2();
44 final FixedFuncHook hook = new FixedFuncHook(es2, mode, pmvMatrix);
45 hook.setVerbose(verbose);
46 final FixedFuncImpl impl = new FixedFuncImpl(es2, hook);
47 gl.getContext().setGL(impl);
48 return impl;
49 } else if(gl.isGL2ES1()) {
50 return gl.getGL2ES1();
51 }
52 throw new GLException("GL Object is neither GL2ES1 nor GL2ES2: "+gl.getContext());
53 }
54
55 /**
56 * @param gl
57 * @param mode one of the {@link ShaderSelectionMode}s
58 * @param pmvMatrix optional pass through PMVMatrix for the {@link FixedFuncHook} and {@link FixedFuncPipeline}
59 * @return If gl is a GL2ES1, return the type cast object,
60 * otherwise create a fixed function emulation pipeline using the GL2ES2 impl.
61 * and hook it to the GLContext via {@link GLContext#setGL(GL)}.
62 * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2
63 *
64 * @see ShaderSelectionMode#AUTO
65 * @see ShaderSelectionMode#COLOR
66 * @see ShaderSelectionMode#COLOR_LIGHT_PER_VERTEX
67 * @see ShaderSelectionMode#COLOR_TEXTURE
68 * @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX
69 */
70 public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) {
71 return wrapFixedFuncEmul(gl, mode, null, false, false);
72 }
73
74 /**
75 * Mapping fixed function (client) array indices to
76 * GLSL array attribute names.
77 *
78 * Useful for uniq mapping of canonical array index names as listed.
79 *
80 * @see #mgl_Vertex
81 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#GL_VERTEX_ARRAY
82 * @see #mgl_Normal
83 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#GL_NORMAL_ARRAY
84 * @see #mgl_Color
85 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#GL_COLOR_ARRAY
86 * @see #mgl_MultiTexCoord
87 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#GL_TEXTURE_COORD_ARRAY
88 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#glEnableClientState
89 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#glVertexPointer
90 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#glColorPointer
91 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#glNormalPointer
92 * @see com.jogamp.opengl.fixedfunc.GLPointerFunc#glTexCoordPointer
93 */
94 public static String getPredefinedArrayIndexName(final int glArrayIndex) {
96 }
97
98 /**
99 * String name for
100 * @see com.jogamp.opengl.GL2#GL_VERTEX_ARRAY
101 */
102 public static final String mgl_Vertex = GLPointerFuncUtil.mgl_Vertex;
103
104 /**
105 * String name for
106 * @see com.jogamp.opengl.GL2#GL_NORMAL_ARRAY
107 */
108 public static final String mgl_Normal = GLPointerFuncUtil.mgl_Normal;
109
110 /**
111 * String name for
112 * @see com.jogamp.opengl.GL2#GL_COLOR_ARRAY
113 */
114 public static final String mgl_Color = GLPointerFuncUtil.mgl_Color;
115
116 /**
117 * String name for
118 * @see com.jogamp.opengl.GL2#GL_TEXTURE_COORD_ARRAY
119 */
121}
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
static String getPredefinedArrayIndexName(final int glArrayIndex)
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
Definition: PMVMatrix.java:62
Tool to pipeline GL2ES2 into a fixed function emulation implementing GL2ES1.
static String getPredefinedArrayIndexName(final int glArrayIndex)
Mapping fixed function (client) array indices to GLSL array attribute names.
static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, final boolean force, final boolean verbose)
static final String mgl_Vertex
String name for.
static final String mgl_Color
String name for.
static final String mgl_Normal
String name for.
static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix)
static final String mgl_MultiTexCoord
String name for.
boolean isGL2ES1()
Indicates whether this GL object conforms to a GL2ES1 compatible profile.
GL2ES1 getGL2ES1()
Casts this object to the GL2ES1 interface.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
boolean isGL2ES2()
Indicates whether this GL object conforms to a GL2ES2 compatible profile.
GLContext getContext()
Returns the GLContext associated which this GL object.