summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-04 02:30:00 +0200
committerSven Gothel <[email protected]>2014-04-04 02:30:00 +0200
commit9c71f276d1fcc87b69b413847fd1da34b30d0932 (patch)
tree71f738861036221827062450a9d7d4cff5a9f766 /src/jogl/classes/javax/media
parentabc833631e0ab30a06c7aff47a39a551544fd735 (diff)
Bug 801: Cleanup shader-program location/data update ; Add COLORTEXTURE + TextureSequence to Region (Demo: TextureButton)
Cleanup shader-program location/data update - GLUniformData: - Allow lazy data setup, as used for RenderState.ProgramLocal, see below - RenderState - Separate data (pmv, weight, colorStatic) from program-local uniforms -> add class ProgramLocal. Reduces uniform location lookups, since ProgramLocal is bound to Region impl. - ProgramLocal.update(..) needs to write uniform data always, since data is being used in multiple programs! - No 'dirty' tracking possible, removed - see above. - RegionRenderer - Fix shader-selection: 2-pass programs differ from 1-pass! - No shader-setup at init +++ Add COLORTEXTURE + TextureSequence to Region - Create color-texture coords in vertex-shader via region's bounding box (pass-1) - Use color-texture unit in pass-1 if enabled (own shader program) - Use TextureSequence in Region impl. providing all required data (unit + texture-name) - Demo: TextureButton (a UIShape)
Diffstat (limited to 'src/jogl/classes/javax/media')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLUniformData.java78
1 files changed, 56 insertions, 22 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java
index 412bfb0a9..fac8b7a1f 100644
--- a/src/jogl/classes/javax/media/opengl/GLUniformData.java
+++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java
@@ -15,7 +15,7 @@ public class GLUniformData {
*
*/
public GLUniformData(String name, int val) {
- init(name, 1, new Integer(val));
+ initScalar(name, 1, new Integer(val));
}
/**
@@ -25,7 +25,7 @@ public class GLUniformData {
*
*/
public GLUniformData(String name, float val) {
- init(name, 1, new Float(val));
+ initScalar(name, 1, new Float(val));
}
/**
@@ -36,7 +36,7 @@ public class GLUniformData {
* @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, int components, IntBuffer data) {
- init(name, components, data);
+ initBuffer(name, components, data);
}
/**
@@ -47,7 +47,19 @@ public class GLUniformData {
* @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, int components, FloatBuffer data) {
- init(name, components, data);
+ initBuffer(name, components, data);
+ }
+
+ private GLUniformData(int components, String name) {
+ initBuffer(name, components, null);
+ }
+
+ public static GLUniformData creatEmptyVector(String name, int components) {
+ return new GLUniformData(components, name);
+ }
+
+ public static GLUniformData creatEmptyMatrix(String name, int rows, int columns) {
+ return new GLUniformData(name, rows, columns, null);
}
/**
@@ -59,13 +71,13 @@ public class GLUniformData {
* @param column the matrix column
*/
public GLUniformData(String name, int rows, int columns, FloatBuffer data) {
- init(name, rows, columns, data);
+ initBuffer(name, rows, columns, data);
}
- public GLUniformData setData(int data) { init(new Integer(data)); return this; }
- public GLUniformData setData(float data) { init(new Float(data)); return this; }
- public GLUniformData setData(IntBuffer data) { init(data); return this; }
- public GLUniformData setData(FloatBuffer data) { init(data); return this; }
+ public GLUniformData setData(final int data) { initScalar(new Integer(data)); return this; }
+ public GLUniformData setData(final float data) { initScalar(new Float(data)); return this; }
+ public GLUniformData setData(final IntBuffer data) { initBuffer(data); return this; }
+ public GLUniformData setData(final FloatBuffer data) { initBuffer(data); return this; }
public int intValue() { return ((Integer)data).intValue(); };
public float floatValue() { return ((Float)data).floatValue(); };
@@ -102,7 +114,7 @@ public class GLUniformData {
return toString(null).toString();
}
- private void init(String name, int rows, int columns, Object data) {
+ private void initBuffer(String name, int rows, int columns, Buffer buffer) {
if( 2>rows || rows>4 || 2>columns || columns>4 ) {
throw new GLException("rowsXcolumns must be within [2..4]X[2..4], is: "+rows+"X"+columns);
}
@@ -111,10 +123,20 @@ public class GLUniformData {
this.columns=columns;
this.isMatrix=true;
this.location=-1;
- init(data);
+ initBuffer(buffer);
}
-
- private void init(String name, int components, Object data) {
+ private void initScalar(String name, int components, Object data) {
+ if( 1>components || components>4 ) {
+ throw new GLException("components must be within [1..4], is: "+components);
+ }
+ this.name=name;
+ this.columns=components;
+ this.rows=1;
+ this.isMatrix=false;
+ this.location=-1;
+ initScalar(data);
+ }
+ private void initBuffer(String name, int components, Buffer buffer) {
if( 1>components || components>4 ) {
throw new GLException("components must be within [1..4], is: "+components);
}
@@ -123,24 +145,36 @@ public class GLUniformData {
this.rows=1;
this.isMatrix=false;
this.location=-1;
- init(data);
+ initBuffer(buffer);
}
- private void init(Object data) {
+ private void initScalar(Object data) {
if(data instanceof Buffer) {
+ initBuffer((Buffer)data);
+ } else if( null != data ) {
+ if(isMatrix) {
+ throw new GLException("Atom type not allowed for matrix : "+this);
+ }
+ this.count=1;
+ this.data=data;
+ } else {
+ this.count=0;
+ this.data=data;
+ }
+ }
+
+ private void initBuffer(final Buffer buffer) {
+ if( null != buffer ) {
final int sz = rows*columns;
- final Buffer buffer = (Buffer)data;
if(buffer.remaining()<sz || 0!=buffer.remaining()%sz) {
throw new GLException("remaining data buffer size invalid: buffer: "+buffer.toString()+"\n\t"+this);
}
- this.count=buffer.remaining()/(rows*columns);
+ this.count=buffer.remaining()/sz;
+ this.data=buffer;
} else {
- if(isMatrix) {
- throw new GLException("Atom type not allowed for matrix : "+this);
- }
- this.count=1;
+ this.count=0;
+ this.data=null;
}
- this.data=data;
}
public String getName() { return name; }