summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-18 09:35:11 +0200
committerSven Gothel <[email protected]>2012-10-18 09:35:11 +0200
commit153a37378beff3f8b40fed8e55b62c2f2790eca5 (patch)
treeecb38e0b814fe563bb90e644a3d2aab8945995c4 /src/jogl/classes
parent1b327874356130096546533a690deff3b7bc876c (diff)
FixedFuncPipeline/Hook: Add glColor4ub() w/ value conversion, make glColor4f() more efficient, use pre-alloc NIO buffer
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java22
2 files changed, 24 insertions, 9 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
index 814d7f519..ee2a08d1f 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
@@ -44,6 +44,7 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.ValueConv;
import com.jogamp.opengl.util.GLArrayDataWrapper;
import com.jogamp.opengl.util.GLBuffers;
import com.jogamp.opengl.util.PMVMatrix;
@@ -306,9 +307,15 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
// LightingIf
//
public void glColor4f(float red, float green, float blue, float alpha) {
- fixedFunction.glColor4fv(gl, GLBuffers.newDirectFloatBuffer(new float[] { red, green, blue, alpha }));
+ fixedFunction.glColor4f(gl, red, green, blue, alpha);
+ }
+
+ public void glColor4ub(byte red, byte green, byte blue, byte alpha) {
+ glColor4f(ValueConv.byte_to_float(red, false),
+ ValueConv.byte_to_float(green, false),
+ ValueConv.byte_to_float(blue, false),
+ ValueConv.byte_to_float(alpha, false) );
}
-
public void glLightfv(int light, int pname, java.nio.FloatBuffer params) {
fixedFunction.glLightfv(gl, light, pname, params);
}
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index 09f52e2a5..5a1678efa 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -135,16 +135,22 @@ public class FixedFuncPipeline {
//
// Simple Globals
//
-
- public void glColor4fv(GL2ES2 gl, FloatBuffer data ) {
+ public void glColor4f(GL2ES2 gl, float red, float green, float blue, float alpha) {
+ colorStatic.put(0, red);
+ colorStatic.put(1, green);
+ colorStatic.put(2, blue);
+ colorStatic.put(3, alpha);
+
shaderState.useProgram(gl, true);
- GLUniformData ud = shaderState.getUniform(mgl_ColorStatic);
+ final GLUniformData ud = shaderState.getUniform(mgl_ColorStatic);
if(null!=ud) {
- ud.setData(data);
+ // same data object ..
shaderState.uniform(gl, ud);
- }
+ } else {
+ throw new GLException("Failed to update: mgl_ColorStatic");
+ }
}
-
+
//
// Arrays / States
//
@@ -897,7 +903,7 @@ public class FixedFuncPipeline {
}
shaderState.uniform(gl, new GLUniformData(mgl_ColorEnabled, 0));
- shaderState.uniform(gl, new GLUniformData(mgl_ColorStatic, 4, one4f));
+ shaderState.uniform(gl, new GLUniformData(mgl_ColorStatic, 4, colorStatic));
texID2Format.setKeyNotFoundValue(0);
shaderState.uniform(gl, new GLUniformData(mgl_TexCoordEnabled, 1, textureCoordEnabled));
@@ -943,6 +949,8 @@ public class FixedFuncPipeline {
protected boolean verbose = DEBUG;
+ private final FloatBuffer colorStatic = Buffers.copyFloatBuffer(one4f);
+
private int activeTextureUnit=0;
private int clientActiveTextureUnit=0;
private final IntIntHashMap texID2Format = new IntIntHashMap();