aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2014-04-04 02:30:00 +0200
committerSven Gothel <sgothel@jausoft.com>2014-04-04 02:30:00 +0200
commit9c71f276d1fcc87b69b413847fd1da34b30d0932 (patch)
tree71f738861036221827062450a9d7d4cff5a9f766 /src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
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/com/jogamp/graph/curve/opengl/RegionRenderer.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index ade6098e1..8724baff8 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -139,9 +139,6 @@ public class RegionRenderer {
public final int getHeight() { return vp_height; }
public final PMVMatrix getMatrix() { return rs.getMatrix(); }
- public final PMVMatrix getMatrixMutable() { return rs.getMatrixMutable(); }
- public final void setMatrixDirty() { rs.setMatrixDirty(); }
- public final boolean isMatrixDirty() { return rs.isMatrixDirty(); }
//////////////////////////////////////
@@ -190,12 +187,6 @@ public class RegionRenderer {
if( null != enableCallback ) {
enableCallback.run(gl, this);
}
-
- useShaderProgram(gl, renderModes, true, 0, 0);
- initialized = rs.update(gl, true, renderModes, true);
- if(!initialized) {
- throw new GLException("Shader initialization failed");
- }
}
public final void destroy(GL2ES2 gl) {
@@ -247,14 +238,13 @@ public class RegionRenderer {
public final void reshapeNotify(int width, int height) {
this.vp_width = width;
this.vp_height = height;
- rs.setMatrixDirty();
}
public final void reshapePerspective(float angle, int width, int height, float near, float far) {
this.vp_width = width;
this.vp_height = height;
final float ratio = (float)width/(float)height;
- final PMVMatrix p = rs.getMatrixMutable();
+ final PMVMatrix p = rs.getMatrix();
p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
p.glLoadIdentity();
p.gluPerspective(angle, ratio, near, far);
@@ -263,7 +253,7 @@ public class RegionRenderer {
public final void reshapeOrtho(int width, int height, float near, float far) {
this.vp_width = width;
this.vp_height = height;
- final PMVMatrix p = rs.getMatrixMutable();
+ final PMVMatrix p = rs.getMatrix();
p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
p.glLoadIdentity();
p.glOrthof(0, width, 0, height, near, far);
@@ -368,6 +358,7 @@ public class RegionRenderer {
private final IntObjectHashMap shaderPrograms = new IntObjectHashMap();
private static final int HIGH_MASK = Region.COLORCHANNEL_RENDERING_BIT | Region.COLORTEXTURE_RENDERING_BIT;
+ private static final int TWO_PASS_BIT = 1 << 31;
/**
* @param gl
@@ -382,7 +373,8 @@ public class RegionRenderer {
final boolean pass1, final int quality, final int sampleCount) {
final ShaderModeSelector1 sel1 = pass1 ? ShaderModeSelector1.selectPass1(renderModes) :
ShaderModeSelector1.selectPass2(renderModes, quality, sampleCount);
- final int shaderKey = sel1.ordinal() | ( HIGH_MASK & renderModes );
+ final boolean isTwoPass = Region.isTwoPass( renderModes );
+ final int shaderKey = sel1.ordinal() | ( HIGH_MASK & renderModes ) | ( isTwoPass ? TWO_PASS_BIT : 0 );
/**
if(DEBUG) {
@@ -395,14 +387,16 @@ public class RegionRenderer {
final boolean spChanged = getRenderState().setShaderProgram(gl, sp);
if(DEBUG) {
if( spChanged ) {
- System.err.printf("RegionRendererImpl01.useShaderProgram.X1: GOT renderModes %s, sel1 %s, key 0x%X (changed)%n", Region.getRenderModeString(renderModes), sel1, shaderKey);
+ System.err.printf("RegionRendererImpl01.useShaderProgram.X1: GOT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (changed)%n", Region.getRenderModeString(renderModes), sel1, shaderKey, sp.program(), sp.id());
+ } else {
+ System.err.printf("RegionRendererImpl01.useShaderProgram.X1: GOT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (keep)%n", Region.getRenderModeString(renderModes), sel1, shaderKey, sp.program(), sp.id());
}
}
return spChanged;
}
final String versionedBaseName = getVersionedShaderName();
final String vertexShaderName;
- if( Region.isTwoPass( renderModes ) ) {
+ if( isTwoPass ) {
vertexShaderName = versionedBaseName+"-pass"+(pass1?1:2);
} else {
vertexShaderName = versionedBaseName+"-single";
@@ -453,6 +447,7 @@ public class RegionRenderer {
if( !sp.init(gl) ) {
throw new GLException("RegionRenderer: Couldn't init program: "+sp);
}
+
if( !sp.link(gl, System.err) ) {
throw new GLException("could not link program: "+sp);
}
@@ -460,8 +455,8 @@ public class RegionRenderer {
shaderPrograms.put(shaderKey, sp);
if(DEBUG) {
- System.err.printf("RegionRendererImpl01.useShaderProgram.X1: PUT renderModes %s, sel1 %s, key 0x%X -> SP %s (changed)%n",
- Region.getRenderModeString(renderModes), sel1, shaderKey, sp);
+ System.err.printf("RegionRendererImpl01.useShaderProgram.X1: PUT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (changed)%n",
+ Region.getRenderModeString(renderModes), sel1, shaderKey, sp.program(), sp.id());
}
return true;
}