aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-14 08:13:42 +0100
committerSven Gothel <[email protected]>2014-03-14 08:13:42 +0100
commite16e974a3e2b38c65355838eeb010954354097d2 (patch)
treee1582436012d80ffddb5a81e6056a5aaa4e7368b /src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
parent70979247aad156418c32959bbf4962f175191ec2 (diff)
Bug 801: Add Frustum support to Region; Misc ..
Region: Add Frustum support, to drop 'out of sight' shapes RenderState: Add hints, e.g. BITHINT_BLENDING_ENABLED, allowing user code to toggle background color etc Demos: Incomplete - WIP - Reuse mapped object to window coords computed at reshape - TODO: Use minimal Scenegraph for Graph-UI ..
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java33
1 files changed, 33 insertions, 0 deletions
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 9b0f32ef6..d6eac19de 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -27,6 +27,7 @@
*/
package com.jogamp.graph.curve.opengl;
+import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLUniformData;
@@ -34,6 +35,7 @@ import jogamp.graph.curve.opengl.RenderStateImpl;
import jogamp.graph.curve.opengl.shader.UniformNames;
import com.jogamp.common.os.Platform;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -41,6 +43,25 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public abstract class RenderState {
private static final String thisKey = "jogamp.graph.curve.RenderState" ;
+ /**
+ * Bitfield hint, {@link #isHintBitSet(int) if set}
+ * stating <i>enabled</i> {@link GL#GL_BLEND}, otherwise <i>disabled</i>.
+ * <p>
+ * Shall be set via {@link #setHintBits(int)} and cleared via {@link #clearHintBits(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 #getColorStatic() foreground color} and <i>zero alpha</i>,
+ * otherwise blending will amplify the scene's clear-color.
+ * </p>
+ * <p>
+ * Shall be called by custom code, e.g. via {@link RegionRenderer}'s
+ * enable and disable {@link RegionRenderer.GLCallback} as done in
+ * {@link RegionRenderer#defaultBlendEnable} and {@link RegionRenderer#defaultBlendDisable}.
+ * </p>
+ */
+ public static final int BITHINT_BLENDING_ENABLED = 1 << 0 ;
+
public static RenderState createRenderState(ShaderState st, Vertex.Factory<? extends Vertex> pointFactory) {
return new RenderStateImpl(st, pointFactory, null);
}
@@ -57,6 +78,7 @@ public abstract class RenderState {
protected final Vertex.Factory<? extends Vertex> vertexFactory;
protected final PMVMatrix pmvMatrix;
protected final GLUniformData gcu_PMVMatrix;
+ protected int hintBitfield;
protected RenderState(ShaderState st, Vertex.Factory<? extends Vertex> vertexFactory, PMVMatrix pmvMatrix) {
this.st = st;
@@ -64,6 +86,7 @@ public abstract class RenderState {
this.pmvMatrix = null != pmvMatrix ? pmvMatrix : new PMVMatrix();
this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, this.pmvMatrix.glGetPMvMatrixf());
st.ownUniform(gcu_PMVMatrix);
+ this.hintBitfield = 0;
}
public final ShaderState getShaderState() { return st; }
@@ -71,6 +94,16 @@ public abstract class RenderState {
public final PMVMatrix pmvMatrix() { return pmvMatrix; }
public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; }
+ public final boolean isHintBitSet(int mask) {
+ return mask == ( hintBitfield & mask );
+ }
+ public final void setHintBits(int mask) {
+ hintBitfield |= mask;
+ }
+ public final void clearHintBits(int mask) {
+ hintBitfield &= ~mask;
+ }
+
public void destroy(GL2ES2 gl) {
st.destroy(gl);
}