aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-09 09:09:51 +0200
committerSven Gothel <[email protected]>2014-04-09 09:09:51 +0200
commitfe47c613e3e07681a5366d6ec3f071fdc4ade65d (patch)
treefd980c33b0fde468918227d31174320b8ae6b163 /src/jogl
parentff4e2b1996d2cfab1eb154020106004fb71471fd (diff)
Bug 801: Region Dirty Update; TextureSequence GLMediaPlayer Fix; Blending Fix ;
- Region Dirty Update - Split dirty -> ShapeDirty + StateDirty, where StateDirty forces re-rendering content w/o geometry update as req. for 2-pass mode. - Fix TextureSequence (GLMediaPlayer) usage in RegionRenderer / GLRegion* - handle GL_TEXTURE_EXTERNAL_OES incl. Android ES3 bug - inject TextureSequence's shader stubs - shader: Use abstract lookup 'texture2D' -> 'gcuTexture2D' - flip scaled colorTexBBox if TextureSequence 'tex.getMustFlipVertically()' - TODO: Handle multiple TextureSequence shader programs! - Fix Blending: GLRegion* / RegionRenderer / RenderState - Disable/Enable depth-writing w/ blending - Region impl. sets proper glBlendFunc*(..), i.e. 2-pass: - render2FBO: glClearColor(0f, 0f, 0f, 0f) glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA) - renderFBO: glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA) - User code shall not set glClearColor(..) for 2-pass anymore - Graph-UI Demo - UIShape: - Add MouseGestureListener, combining MouseListener + GestureListener - EventDetails -> PointerEventInfo - PointerEventInfo contains objPos (ray-intersection) and glWin-pos - Toggle: - Separate color (on/off) if enabled - Toggle on click if enabled - SceneUIController - Use PinchToZoomGesture and propagete same gesture to UIShape - Use AABBox.getRayIntersection(..) using 'real' shape coordinates for 1st picking. - Use shape PMV for secondary picking (drag, zoom 2-pointer, etc), see windowToShapeCoords(..) - Sort shapes according to z-value (render: ascending; picking: descending) - Only 'drag' if pointerId matches 1st pressed pointer
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java48
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java6
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java83
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java6
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java62
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java57
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java45
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl8
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.orig.glsl14
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp3
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl1
11 files changed, 241 insertions, 92 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 230fa324d..45ad20f1b 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -105,9 +105,12 @@ public abstract class Region {
public static final int DEFAULT_TWO_PASS_TEXTURE_UNIT = 0;
+ protected static final int DIRTY_SHAPE = 1 << 0 ;
+ protected static final int DIRTY_STATE = 1 << 1 ;
+
private final int renderModes;
private int quality;
- private boolean dirty = true;
+ private int dirty = DIRTY_SHAPE | DIRTY_STATE;
private int numVertices = 0;
protected final AABBox box = new AABBox();
protected Frustum frustum = null;
@@ -187,7 +190,7 @@ public abstract class Region {
public final void setQuality(int q) { quality=q; }
protected void clearImpl() {
- dirty = true;
+ dirty = DIRTY_SHAPE | DIRTY_STATE;
numVertices = 0;
box.reset();
}
@@ -356,7 +359,7 @@ public abstract class Region {
// int vertsDupCountV = 0, vertsDupCountT = 0;
System.err.println("Region.addOutlineShape().X: box "+box);
}
- setDirty(true);
+ markShapeDirty();
}
public final void addOutlineShapes(final List<OutlineShape> shapes, final AffineTransform transform, final float[] rgbaColor) {
@@ -371,32 +374,35 @@ public abstract class Region {
}
/**
- * Check if this region is dirty. A region is marked dirty when new
- * Vertices, Triangles, and or Lines are added after a call to update().
- * <p>
- * A region is also dirty if other render attributes or parameters are changed!
- * </p>
- *
- * @return true if region is Dirty, false otherwise
- *
- * @see update(GL2ES2)
+ * Mark this region's shape dirty, i.e. it's
+ * Vertices, Triangles, and or Lines changed.
*/
- public final boolean isDirty() {
- return dirty;
+ public final void markShapeDirty() {
+ dirty |= DIRTY_SHAPE;
+ }
+ /** Returns true if this region's shape are dirty, see {@link #markShapeDirty()}. */
+ public final boolean isShapeDirty() {
+ return 0 != ( dirty & DIRTY_SHAPE ) ;
}
-
/**
- * See {@link #isDirty()}.
+ * Mark this region's state dirty, i.e.
+ * it's render attributes or parameters changed.
*/
- protected final void setDirty(boolean v) {
- dirty = v;
+ public final void markStateDirty() {
+ dirty |= DIRTY_STATE;
+ }
+ /** Returns true if this region's state is dirty, see {@link #markStateDirty()}. */
+ public final boolean isStateDirty() {
+ return 0 != ( dirty & DIRTY_STATE ) ;
}
+
/**
- * See {@link #isDirty()}.
+ * See {@link #markShapeDirty()} and {@link #markStateDirty()}.
*/
- public final void markDirty() {
- dirty = true;
+ protected final void clearDirtyBits(int v) {
+ dirty &= ~v;
}
+ protected final int getDirtyBits() { return dirty; }
public String toString() {
return "Region["+getRenderModeString(this.renderModes)+", q "+quality+", dirty "+dirty+", vertices "+numVertices+", box "+box+"]";
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 3c6045a1f..49c1944b1 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -83,7 +83,7 @@ public abstract class GLRegion extends Region {
/**
* Updates a graph region by updating the ogl related
- * objects for use in rendering if {@link #isDirty()}.
+ * objects for use in rendering if {@link #isShapeDirty()}.
* <p>Allocates the ogl related data and initializes it the 1st time.<p>
* <p>Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.</p>
*/
@@ -139,11 +139,11 @@ public abstract class GLRegion extends Region {
* @see RegionRenderer#enable(GL2ES2, boolean)
*/
public final void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
- if(isDirty()) {
+ if( isShapeDirty() ) {
updateImpl(gl);
- setDirty(false);
}
drawImpl(gl, renderer, sampleCount);
+ clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
}
protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount);
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 7337aca36..a0a318a49 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -32,15 +32,19 @@ import java.util.Iterator;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLES2;
import javax.media.opengl.GLException;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import jogamp.graph.curve.opengl.shader.AttributeNames;
+import jogamp.graph.curve.opengl.shader.UniformNames;
import com.jogamp.opengl.GLExtensions;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.texture.TextureSequence;
import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.IntObjectHashMap;
import com.jogamp.graph.curve.Region;
@@ -65,10 +69,12 @@ public class RegionRenderer {
/**
* Default {@link GL#GL_BLEND} <i>enable</i> {@link GLCallback},
- * turning on the {@link GL#GL_BLEND} state and setting up
- * {@link GL#glBlendFunc(int, int) glBlendFunc}({@link GL#GL_SRC_ALPHA}, {@link GL#GL_ONE_MINUS_SRC_ALPHA}).
+ * turning-off depth writing via {@link GL#glDepthMask(boolean)} and turning-on the {@link GL#GL_BLEND} state.
* <p>
- * Implementation also sets {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
+ * Implementation also sets {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint},
+ * which will cause {@link GLRegion#draw(GL2ES2, RegionRenderer, int[]) GLRegion's draw-method}
+ * to set the proper {@link GL#glBlendFuncSeparate(int, int, int, int) blend-function}
+ * and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering.
* </p>
* @see #create(RenderState, GLCallback, GLCallback)
* @see #enable(GL2ES2, boolean)
@@ -76,16 +82,17 @@ public class RegionRenderer {
public static final GLCallback defaultBlendEnable = new GLCallback() {
@Override
public void run(final GL gl, final RegionRenderer renderer) {
+ gl.glDepthMask(false);
gl.glEnable(GL.GL_BLEND);
gl.glBlendEquation(GL.GL_FUNC_ADD); // default
- gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
renderer.rs.setHintMask(RenderState.BITHINT_BLENDING_ENABLED);
}
};
/**
* Default {@link GL#GL_BLEND} <i>disable</i> {@link GLCallback},
- * simply turning off the {@link GL#GL_BLEND} state.
+ * simply turning-off the {@link GL#GL_BLEND} state
+ * and turning-on depth writing via {@link GL#glDepthMask(boolean)}.
* <p>
* Implementation also clears {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
* </p>
@@ -97,6 +104,7 @@ public class RegionRenderer {
public void run(final GL gl, final RegionRenderer renderer) {
renderer.rs.clearHintMask(RenderState.BITHINT_BLENDING_ENABLED);
gl.glDisable(GL.GL_BLEND);
+ gl.glDepthMask(true);
}
};
@@ -160,7 +168,7 @@ public class RegionRenderer {
* <p>Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, int)}</p>
*
* @param gl referencing the current GLContext to which the ShaderState is bound to
- * @param renderModes TODO
+ * @param renderModes
* @throws GLException if initialization failed
*/
public final void init(final GL2ES2 gl, final int renderModes) throws GLException {
@@ -270,6 +278,8 @@ public class RegionRenderer {
private static String USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n";
private static String USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n";
private static String DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT ";
+ private static String MAIN_BEGIN = "void main (void)\n{\n";
+ private static final String gcuTexture2D = "gcuTexture2D";
private String getVersionedShaderName() {
return "curverenderer01";
@@ -367,14 +377,16 @@ public class RegionRenderer {
* @param pass1
* @param quality
* @param sampleCount
+ * @param colorTexSeq
* @return true if a new shader program is being used and hence external uniform-data and -location,
* as well as the attribute-location must be updated, otherwise false.
*/
public final boolean useShaderProgram(final GL2ES2 gl, final int renderModes,
- final boolean pass1, final int quality, final int sampleCount) {
+ final boolean pass1, final int quality, final int sampleCount, final TextureSequence colorTexSeq) {
final ShaderModeSelector1 sel1 = pass1 ? ShaderModeSelector1.selectPass1(renderModes) :
ShaderModeSelector1.selectPass2(renderModes, quality, sampleCount);
final boolean isTwoPass = Region.isTwoPass( renderModes );
+ final boolean isPass1ColorTexSeq = pass1 && null != colorTexSeq;
final int shaderKey = sel1.ordinal() | ( HIGH_MASK & renderModes ) | ( isTwoPass ? TWO_PASS_BIT : 0 );
/**
@@ -404,15 +416,40 @@ public class RegionRenderer {
}
final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, vertexShaderName, true);
final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, versionedBaseName+"-segment-head", true);
- int posVp = rsVp.defaultShaderCustomization(gl, true, true);
+
+ int posVp = 0;
+ int posFp = 0;
+
+ if( isPass1ColorTexSeq && GLES2.GL_TEXTURE_EXTERNAL_OES == colorTexSeq.getTextureTarget() ) {
+ if( !gl.isExtensionAvailable(GLExtensions.OES_EGL_image_external) ) {
+ throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available");
+ }
+ }
+ boolean supressGLSLVersionES30 = false;
+ if( isPass1ColorTexSeq && GLES2.GL_TEXTURE_EXTERNAL_OES == colorTexSeq.getTextureTarget() ) {
+ if( Platform.OSType.ANDROID == Platform.getOSType() && gl.isGLES3() ) {
+ // Bug on Nexus 10, ES3 - Android 4.3, where
+ // GL_OES_EGL_image_external extension directive leads to a failure _with_ '#version 300 es' !
+ // P0003: Extension 'GL_OES_EGL_image_external' not supported
+ supressGLSLVersionES30 = true;
+ }
+ }
+ posVp = rsVp.defaultShaderCustomization(gl, !supressGLSLVersionES30, true);
// rsFp.defaultShaderCustomization(gl, true, true);
- int posFp = rsFp.addGLSLVersion(gl);
- if( gl.isGLES2() && ! gl.isGLES3() ) {
+ posFp = supressGLSLVersionES30 ? 0 : rsFp.addGLSLVersion(gl);
+ if( isPass1ColorTexSeq ) {
+ posFp = rsFp.insertShaderSource(0, posFp, colorTexSeq.getRequiredExtensionsShaderStub());
+ }
+ if( pass1 && supressGLSLVersionES30 || ( gl.isGLES2() && !gl.isGLES3() ) ) {
posFp = rsFp.insertShaderSource(0, posFp, ShaderCode.createExtensionDirective(GLExtensions.OES_standard_derivatives, ShaderCode.ENABLE));
}
- final String rsFpDefPrecision = getFragmentShaderPrecision(gl);
- if( null != rsFpDefPrecision ) {
- rsFp.insertShaderSource(0, posFp, rsFpDefPrecision);
+ if( false ) {
+ final String rsFpDefPrecision = getFragmentShaderPrecision(gl);
+ if( null != rsFpDefPrecision ) {
+ posFp = rsFp.insertShaderSource(0, posFp, rsFpDefPrecision);
+ }
+ } else {
+ posFp = rsFp.addDefaultShaderPrecision(gl, posFp);
}
if( Region.hasColorChannel( renderModes ) ) {
posVp = rsVp.insertShaderSource(0, posVp, USE_COLOR_CHANNEL);
@@ -426,20 +463,35 @@ public class RegionRenderer {
posFp = rsFp.insertShaderSource(0, posFp, DEF_SAMPLE_COUNT+sel1.sampleCount+"\n");
}
+ final String texLookupFuncName;
+ if( isPass1ColorTexSeq ) {
+ posFp = rsFp.insertShaderSource(0, posFp, "uniform "+colorTexSeq.getTextureSampler2DType()+" "+UniformNames.gcu_ColorTexUnit+";\n");
+ texLookupFuncName = colorTexSeq.getTextureLookupFunctionName(gcuTexture2D);
+ posFp = rsFp.insertShaderSource(0, posFp, colorTexSeq.getTextureLookupFragmentShaderImpl());
+ } else {
+ texLookupFuncName = null;
+ }
+
+ posFp = rsFp.insertShaderSource(0, -1, MAIN_BEGIN);
+
final String passS = pass1 ? "-pass1-" : "-pass2-";
final String shaderSegment = versionedBaseName+passS+sel1.tech+sel1.sub+".glsl";
if(DEBUG) {
System.err.printf("RegionRendererImpl01.useShaderProgram.1: segment %s%n", shaderSegment);
}
try {
- posFp = rsFp.insertShaderSource(0, -1, AttributeNames.class, shaderSegment);
+ posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, shaderSegment);
} catch (IOException ioe) {
throw new RuntimeException("Failed to read: "+shaderSegment, ioe);
}
if( 0 > posFp ) {
throw new RuntimeException("Failed to read: "+shaderSegment);
}
- posFp = rsFp.insertShaderSource(0, -1, "}\n");
+ posFp = rsFp.insertShaderSource(0, posFp, "}\n");
+
+ if( isPass1ColorTexSeq ) {
+ rsFp.replaceInShaderSource(gcuTexture2D, texLookupFuncName);
+ }
sp = new ShaderProgram();
sp.add(rsVp);
@@ -461,5 +513,4 @@ public class RegionRenderer {
}
return true;
}
-
} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
index 818526cd7..7eb34a62d 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -53,9 +53,9 @@ public class RenderState {
* Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}.
* </p>
* <p>
- * Due to alpha blending and multipass rendering, e.g. {@link Region#VBAA_RENDERING_BIT},
- * the clear-color shall be set to the {@link #getColorStaticUniform() foreground color} and <i>zero alpha</i>,
- * otherwise blending will amplify the scene's clear-color.
+ * If set, {@link GLRegion#draw(GL2ES2, RegionRenderer, int[]) GLRegion's draw-method}
+ * will set the proper {@link GL#glBlendFuncSeparate(int, int, int, int) blend-function}
+ * and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering.
* </p>
* <p>
* Shall be called by custom code, e.g. via {@link RegionRenderer}'s
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index 33527381d..b52308e05 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -46,6 +46,7 @@ import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
public class VBORegion2PMSAAES2 extends GLRegion {
@@ -96,7 +97,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
*/
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
final RenderState rs = renderer.getRenderState();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal;
if( pass1 ) {
@@ -250,11 +251,22 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_ColorsAttr.seal(gl, true);
gca_ColorsAttr.enableBuffer(gl, false);
}
- if( null != gcu_ColorTexUnit ) {
- colorTexBBox[0] = box.getMinX();
- colorTexBBox[1] = box.getMinY();
- colorTexBBox[2] = box.getMaxX();
- colorTexBBox[3] = box.getMaxY();
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
+ final TextureSequence.TextureFrame frame = colorTexSeq.getLastTexture();
+ final Texture tex = frame.getTexture();
+ final TextureCoords tc = tex.getImageTexCoords();
+ final float tcSx = 1f / ( tc.right() - tc.left() );
+ colorTexBBox[0] = box.getMinX() * tcSx;
+ colorTexBBox[2] = box.getMaxX() * tcSx;
+ if( tex.getMustFlipVertically() ) {
+ final float tcSy = 1f / ( tc.bottom() - tc.top() );
+ colorTexBBox[1] = box.getMaxY() * tcSy;
+ colorTexBBox[3] = box.getMinY() * tcSy;
+ } else {
+ final float tcSy = 1f / ( tc.top() - tc.bottom() );
+ colorTexBBox[1] = box.getMinY() * tcSy;
+ colorTexBBox[3] = box.getMaxY() * tcSy;
+ }
}
gca_FboVerticesAttr.seal(gl, false);
{
@@ -364,9 +376,8 @@ public class VBORegion2PMSAAES2 extends GLRegion {
System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n",
sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
}
- if( hasDelta || fboDirty || null == fbo || ( fbo != null && fbo.getNumSamples() != sampleCount[0] ) ) {
+ if( hasDelta || fboDirty || isShapeDirty() || null == fbo || ( fbo != null && fbo.getNumSamples() != sampleCount[0] ) ) {
// FIXME: rescale
-
final float minX = box.getMinX()-diffObjBorderWidth;
final float minY = box.getMinY()-diffObjBorderHeight;
final float maxX = box.getMaxX()+diffObjBorderWidth+diffObjWidth;
@@ -384,10 +395,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
- } else {
- gca_FboTexCoordsAttr.setVBOWritten(false);
+ } else if( isStateDirty() ) {
+ useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
}
- // System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]);
renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]);
}
@@ -396,6 +407,11 @@ public class VBORegion2PMSAAES2 extends GLRegion {
private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, final int sampleCount) {
gl.glViewport(0, 0, width, height);
+ if( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
+ // RGB is already multiplied w/ alpha via renderRegion2FBO(..)
+ gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+ }
+
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
fbo.use(gl, fbo.getSamplingSink());
@@ -419,6 +435,8 @@ public class VBORegion2PMSAAES2 extends GLRegion {
throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
}
+ final boolean blendingEnabled = rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED);
+
if(null == fbo) {
fboWidth = targetFboWidth;
fboHeight = targetFboHeight;
@@ -433,7 +451,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
// FIXME: shall not use bilinear (GL_LINEAR), due to MSAA ???
// ssink.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
ssink.attachTexture2D(gl, 0, true, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ if( !blendingEnabled ) {
+ // no depth-buffer w/ blending
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ }
}
fbo.setSamplingSink(ssink);
fbo.resetSamplingSink(gl); // validate
@@ -453,9 +474,20 @@ public class VBORegion2PMSAAES2 extends GLRegion {
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
+ if( blendingEnabled ) {
+ gl.glClearColor(0f, 0f, 0f, 0.0f);
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT); // no depth-buffer w/ blending
+ // For already pre-multiplied alpha values, use:
+ // gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+
+ // Multiply RGB w/ Alpha, preserve alpha for renderFBO(..)
+ gl.glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+ } else {
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+ }
- gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
renderRegion(gl);
+
fbo.unbind(gl);
fboDirty = false;
}
@@ -468,7 +500,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_ColorsAttr.enableBuffer(gl, true);
}
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
- if( null != gcu_ColorTexUnit ) {
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl);
gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit());
final Texture tex = frame.getTexture();
@@ -479,7 +511,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexUnit);
gl.glUniform(gcu_ColorTexUnit);
}
- gl.glUniform(gcu_ColorTexBBox); // FIXME: Only if changed!
+ gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
tex.disable(gl); // nop on core
} else {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index c623eddb7..cea292210 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -49,6 +49,7 @@ import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
public class VBORegion2PVBAAES2 extends GLRegion {
@@ -131,7 +132,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
*/
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
final RenderState rs = renderer.getRenderState();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal;
if( pass1 ) {
@@ -295,11 +296,22 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gca_ColorsAttr.seal(gl, true);
gca_ColorsAttr.enableBuffer(gl, false);
}
- if( null != gcu_ColorTexUnit ) {
- colorTexBBox[0] = box.getMinX();
- colorTexBBox[1] = box.getMinY();
- colorTexBBox[2] = box.getMaxX();
- colorTexBBox[3] = box.getMaxY();
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
+ final TextureSequence.TextureFrame frame = colorTexSeq.getLastTexture();
+ final Texture tex = frame.getTexture();
+ final TextureCoords tc = tex.getImageTexCoords();
+ final float tcSx = 1f / ( tc.right() - tc.left() );
+ colorTexBBox[0] = box.getMinX() * tcSx;
+ colorTexBBox[2] = box.getMaxX() * tcSx;
+ if( tex.getMustFlipVertically() ) {
+ final float tcSy = 1f / ( tc.bottom() - tc.top() );
+ colorTexBBox[1] = box.getMaxY() * tcSy;
+ colorTexBBox[3] = box.getMinY() * tcSy;
+ } else {
+ final float tcSy = 1f / ( tc.top() - tc.bottom() );
+ colorTexBBox[1] = box.getMinY() * tcSy;
+ colorTexBBox[3] = box.getMaxY() * tcSy;
+ }
}
gca_FboVerticesAttr.seal(gl, false);
{
@@ -419,7 +431,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n",
sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
}
- if( hasDelta || fboDirty || null == fbo ) {
+ if( hasDelta || fboDirty || isShapeDirty() || null == fbo ) {
final int maxLength = Math.max(targetFboWidth, targetFboHeight);
if( maxLength > maxTexSize[0] ) {
if( targetFboWidth > targetFboHeight ) {
@@ -503,6 +515,9 @@ public class VBORegion2PVBAAES2 extends GLRegion {
FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
+ } else if( isStateDirty() ) {
+ useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, fboWidth, fboHeight, vpWidth, vpHeight, sampleCount[0]);
}
useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]);
renderFBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount[0]);
@@ -513,6 +528,11 @@ public class VBORegion2PVBAAES2 extends GLRegion {
final int vpWidth, final int vpHeight, final int sampleCount) {
gl.glViewport(0, 0, vpWidth, vpHeight);
+ if( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
+ // RGB is already multiplied w/ alpha via renderRegion2FBO(..)
+ gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+ }
+
gl.glUniform(gcu_FboTexSize);
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
@@ -539,6 +559,8 @@ public class VBORegion2PVBAAES2 extends GLRegion {
throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
}
+ final boolean blendingEnabled = rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED);
+
if(null == fbo) {
fboWidth = newFboWidth;
fboHeight = newFboHeight;
@@ -553,7 +575,10 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// FIXME: FXAA requires bilinear filtering!
// texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ if( !blendingEnabled ) {
+ // no depth-buffer w/ blending
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ }
if( DEBUG_FBO_1 ) {
System.err.printf("XXX.createFBO: %dx%d%n%s%n", fboWidth, fboHeight, fbo.toString());
}
@@ -576,7 +601,17 @@ public class VBORegion2PVBAAES2 extends GLRegion {
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
- gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+ if( blendingEnabled ) {
+ gl.glClearColor(0f, 0f, 0f, 0.0f);
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT); // no depth-buffer w/ blending
+ // For already pre-multiplied alpha values, use:
+ // gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+
+ // Multiply RGB w/ Alpha, preserve alpha for renderFBO(..)
+ gl.glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+ } else {
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+ }
renderRegion(gl);
@@ -593,7 +628,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gca_ColorsAttr.enableBuffer(gl, true);
}
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
- if( null != gcu_ColorTexUnit ) {
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl);
gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit());
final Texture tex = frame.getTexture();
@@ -604,7 +639,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexUnit);
gl.glUniform(gcu_ColorTexUnit);
}
- gl.glUniform(gcu_ColorTexBBox); // FIXME: Only if changed!
+ gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
tex.disable(gl); // nop on core
} else {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 0ec139a0f..24d53c1a2 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -43,6 +43,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
public class VBORegionSPES2 extends GLRegion {
@@ -149,11 +150,23 @@ public class VBORegionSPES2 extends GLRegion {
gca_ColorsAttr.seal(gl, true);
gca_ColorsAttr.enableBuffer(gl, false);
}
- if( null != gcu_ColorTexUnit ) {
- colorTexBBox[0] = box.getMinX();
- colorTexBBox[1] = box.getMinY();
- colorTexBBox[2] = box.getMaxX();
- colorTexBBox[3] = box.getMaxY();
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
+ final TextureSequence.TextureFrame frame = colorTexSeq.getLastTexture();
+ final Texture tex = frame.getTexture();
+ final TextureCoords tc = tex.getImageTexCoords();
+ final float tcSx = 1f / ( tc.right() - tc.left() );
+ colorTexBBox[0] = box.getMinX() * tcSx;
+ colorTexBBox[2] = box.getMaxX() * tcSx;
+ final float tcSy;
+ if( tex.getMustFlipVertically() ) {
+ tcSy = 1f / ( tc.bottom() - tc.top() );
+ colorTexBBox[1] = box.getMaxY() * tcSy;
+ colorTexBBox[3] = box.getMinY() * tcSy;
+ } else {
+ tcSy = 1f / ( tc.top() - tc.bottom() );
+ colorTexBBox[1] = box.getMinY() * tcSy;
+ colorTexBBox[3] = box.getMaxY() * tcSy;
+ }
}
indicesBuffer.seal(gl, true);
indicesBuffer.enableBuffer(gl, false);
@@ -164,6 +177,7 @@ public class VBORegionSPES2 extends GLRegion {
}
}
+ private static final boolean throwOnError = false; // FIXME
/**
* <p>
* Since multiple {@link Region}s may share one
@@ -177,7 +191,7 @@ public class VBORegionSPES2 extends GLRegion {
*/
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final int quality) {
final RenderState rs = renderer.getRenderState();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, true, quality, 0);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, true, quality, 0, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal = !sp.equals(spPass1);
spPass1 = sp;
@@ -185,16 +199,16 @@ public class VBORegionSPES2 extends GLRegion {
System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
}
if( updateLocLocal ) {
- rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true);
- rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true);
+ rs.updateAttributeLoc(gl, true, gca_VerticesAttr, throwOnError);
+ rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, throwOnError);
if( null != gca_ColorsAttr ) {
- rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
+ rs.updateAttributeLoc(gl, true, gca_ColorsAttr, throwOnError);
}
}
- rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true);
+ rsLocal.update(gl, rs, updateLocLocal, renderModes, true, throwOnError);
if( null != gcu_ColorTexUnit ) {
- rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
- rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, throwOnError);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, throwOnError);
}
}
@@ -216,7 +230,12 @@ public class VBORegionSPES2 extends GLRegion {
gca_ColorsAttr.enableBuffer(gl, true);
}
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
- if( null != gcu_ColorTexUnit ) {
+
+ if( renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
+ gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
+ }
+
+ if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl);
gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit());
final Texture tex = frame.getTexture();
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
index 83b312a0b..447242438 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
@@ -2,9 +2,9 @@
if( gcv_CurveParam.x == 0.0 && gcv_CurveParam.y == 0.0 ) {
// pass-1: Lines
#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
- mgl_FragColor = texture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcv_Color * gcu_ColorStatic;
+ mgl_FragColor = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcv_Color * gcu_ColorStatic;
#elif defined(USE_COLOR_TEXTURE)
- mgl_FragColor = texture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcu_ColorStatic;
+ mgl_FragColor = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcu_ColorStatic;
#elif defined(USE_COLOR_CHANNEL)
mgl_FragColor = gcv_Color * gcu_ColorStatic;
#else
@@ -22,10 +22,10 @@
float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_CurveParam.y), 0.0, 1.0);
#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
- vec4 t = texture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
+ vec4 t = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
mgl_FragColor = vec4(t.rgb * gcv_Color.rgb * gcu_ColorStatic.rgb, t.a * gcv_Color.a * gcu_ColorStatic.a * a);
#elif defined(USE_COLOR_TEXTURE)
- vec4 t = texture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
+ vec4 t = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
mgl_FragColor = vec4(t.rgb * gcu_ColorStatic.rgb, t.a * gcu_ColorStatic.a * a);
#elif defined(USE_COLOR_CHANNEL)
mgl_FragColor = vec4(gcv_Color.rgb * gcu_ColorStatic.rgb, gcv_Color.a * gcu_ColorStatic.a * a);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.orig.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.orig.glsl
index 92f0fc07b..fa2608365 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.orig.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.orig.glsl
@@ -3,7 +3,11 @@
if( gcv_CurveParam.x == 0.0 && gcv_CurveParam.y == 0.0 ) {
// pass-1: Lines
-#ifdef USE_COLOR_CHANNEL
+#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
+ mgl_FragColor = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcv_Color * gcu_ColorStatic;
+#elif defined(USE_COLOR_TEXTURE)
+ mgl_FragColor = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st) * gcu_ColorStatic;
+#elif defined(USE_COLOR_CHANNEL)
mgl_FragColor = gcv_Color * gcu_ColorStatic;
#else
mgl_FragColor = gcu_ColorStatic;
@@ -25,7 +29,13 @@
float position = rtex.y - (rtex.x * (1.0 - rtex.x));
float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_CurveParam.y), 0.0, 1.0);
-#ifdef USE_COLOR_CHANNEL
+#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
+ vec4 t = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
+ mgl_FragColor = vec4(t.rgb * gcv_Color.rgb * gcu_ColorStatic.rgb, t.a * gcv_Color.a * gcu_ColorStatic.a * a);
+#elif defined(USE_COLOR_TEXTURE)
+ vec4 t = gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st);
+ mgl_FragColor = vec4(t.rgb * gcu_ColorStatic.rgb, t.a * gcu_ColorStatic.a * a);
+#elif defined(USE_COLOR_CHANNEL)
mgl_FragColor = vec4(gcv_Color.rgb * gcu_ColorStatic.rgb, gcv_Color.a * gcu_ColorStatic.a * a);
#else
mgl_FragColor = vec4(gcu_ColorStatic.rgb, gcu_ColorStatic.a * a);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
index 74a1dea4e..26e2bcf24 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
@@ -17,6 +17,3 @@
#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY))
-void main (void)
-{
-
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
index ae7fa8490..cd014b732 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
@@ -7,7 +7,6 @@ uniform vec4 gcu_ColorStatic;
uniform float gcu_Weight;
#ifdef USE_COLOR_TEXTURE
- uniform sampler2D gcu_ColorTexUnit;
uniform vec4 gcu_ColorTexBBox;
#endif