28package com.jogamp.graph.curve.opengl;
30import java.nio.FloatBuffer;
32import com.jogamp.opengl.GL;
33import com.jogamp.opengl.GL2ES2;
34import com.jogamp.opengl.GLException;
35import com.jogamp.opengl.GLUniformData;
37import jogamp.common.os.PlatformPropsImpl;
38import jogamp.graph.curve.opengl.shader.UniformNames;
40import com.jogamp.graph.curve.Region;
41import com.jogamp.math.Vec4f;
42import com.jogamp.math.geom.Frustum;
43import com.jogamp.math.util.PMVMatrix4f;
44import com.jogamp.opengl.util.GLArrayDataWrapper;
45import com.jogamp.opengl.util.glsl.ShaderProgram;
54 private static final String thisKey =
"jogamp.graph.curve.RenderState" ;
99 private final float[] weight;
100 private final FloatBuffer weightBuffer;
101 private final float[] colorStatic;
102 private final FloatBuffer colorStaticBuffer;
104 private int aaQuality;
106 private int sampleCount;
108 private final Frustum clipFrustum;
109 private boolean useClipFrustum;
110 private int hintBits;
111 private int debugBits;
114 private static synchronized int getNextID() {
117 private static int nextID = 1;
130 private int rsId = -1;
153 final boolean setPMVMat01,
final boolean pass1,
final boolean throwOnError) {
154 if( rs.id() != rsId ) {
162 if(
null != rs.sp && rs.sp.
inUse() ) {
181 public StringBuilder
toString(StringBuilder sb,
final boolean alsoUnlocated) {
183 sb =
new StringBuilder();
185 sb.append(
"ProgramLocal[rsID ").append(rsId).append(PlatformPropsImpl.NEWLINE);
187 sb.append(
gcu_PMVMatrix01).append(
", ").append(PlatformPropsImpl.NEWLINE);
195 return toString(
null,
false).toString();
204 this.id = getNextID();
205 this.pmvMatrix =
null != sharedPMVMatrix ? sharedPMVMatrix :
new PMVMatrix4f();
206 this.weight =
new float[1];
207 this.weightBuffer = FloatBuffer.wrap(weight);
208 this.colorStatic =
new float[] { 1, 1, 1, 1 };
209 this.colorStaticBuffer = FloatBuffer.wrap(colorStatic);
212 this.clipFrustum =
new Frustum();
213 this.useClipFrustum =
false;
220 public final int id() {
return id; }
239 if( spNext.
equals(
this.sp) ) {
243 if(
null != this.sp ) {
255 return 0.0f <= v && v <= 1.9f ;
260 throw new IllegalArgumentException(
"Weight out of range");
266 return rgbaColor.
set(colorStatic);
269 colorStatic[0] = rgbaColor.x();
270 colorStatic[1] = rgbaColor.y();
271 colorStatic[2] = rgbaColor.z();
272 colorStatic[3] = rgbaColor.w();
274 public final void setColorStatic(
final float r,
final float g,
final float b,
final float a){
293 if(
null != clipFrustum ) {
294 this.clipFrustum.
set(clipFrustum);
295 this.useClipFrustum=
true;
297 this.useClipFrustum=
false;
305 return mask == ( hintBits & mask );
316 return mask == ( debugBits & mask );
336 if( throwOnError && !ok ) {
356 updateLocation = updateLocation || 0 > data.
getLocation();
357 if( updateLocation ) {
359 if( throwOnError && !updateData ) {
368 return !updateLocation;
381 if( throwOnError && !ok ) {
413 return "RenderState["+sp+
"]";
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static final int clipAAQuality(final int v)
Returns clipped AA quality value to [Region#MIN_AA_QUALITY..Region#MAX_AA_QUALITY].
static final int DEFAULT_AA_QUALITY
Default pass2 AA-quality rendering {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT.
static boolean hasVariableWeight(final int renderModes)
Returns true if render mode capable of variable weights, i.e.
static final int clipAASampleCount(final int v)
Returns clipped AA sample-count to [Region#MIN_AA_SAMPLE_COUNT..Region#MAX_AA_SAMPLE_COUNT].
static final int DEFAULT_AA_SAMPLE_COUNT
Default pass2 AA sample count {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT or Region...
Representation of RenderState data per ShaderProgram as GLUniformData.
StringBuilder toString(StringBuilder sb, final boolean alsoUnlocated)
final GLUniformData gcu_PMVMatrix01
final boolean update(final GL2ES2 gl, final RenderState rs, final boolean updateLocation, final int renderModes, final boolean setPMVMat01, final boolean pass1, final boolean throwOnError)
final int getRenderStateId()
final GLUniformData gcu_Weight
final GLUniformData gcu_ColorStatic
The RenderState is owned by RegionRenderer.
final boolean isShaderProgramInUse()
Return whether the current ShaderProgram is in use.
final Frustum getClipFrustum()
Returns the optional Mv-premultiplied clipping Frustum or null if unused.
final boolean hintBitsSet(final int mask)
final Vec4f getColorStatic(final Vec4f rgbaColor)
final RenderState attachTo(final GL2ES2 gl)
final boolean updateAttributeLoc(final GL2ES2 gl, final boolean updateLocation, final GLArrayDataWrapper data, final boolean throwOnError)
static final int BITHINT_BLENDING_ENABLED
Bitfield hint, if set stating enabled GL#GL_BLEND, otherwise disabled.
final boolean updateUniformLoc(final GL2ES2 gl, final boolean updateLocation, final GLUniformData data, final boolean throwOnError)
final void setColorStatic(final Vec4f rgbaColor)
static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED
Bitfield hint, if set stating globally enabled GL#GL_DEPTH_TEST, otherwise disabled.
final void setColorStatic(final float r, final float g, final float b, final float a)
final int getSampleCount()
Returns pass2 AA sample count for Graph Region AA render-modes: VBAA_RENDERING_BIT or Region#MSAA_REN...
final void clearDebugBits(final int mask)
static final RenderState getRenderState(final GL2ES2 gl)
final boolean detachFrom(final GL2ES2 gl)
static final int DEBUG_LINESTRIP
final PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
final void clearHintBits(final int mask)
final void setWeight(final float v)
final boolean debugBitsSet(final int mask)
static boolean isWeightValid(final float v)
final int setSampleCount(final int v)
Sets pass2 AA sample count clipped to the range [Region#MIN_AA_SAMPLE_COUNT..Region#MAX_AA_SAMPLE_COU...
final boolean updateUniformDataLoc(final GL2ES2 gl, boolean updateLocation, boolean updateData, final GLUniformData data, final boolean throwOnError)
final void setHintBits(final int mask)
final boolean setShaderProgram(final GL2ES2 gl, final ShaderProgram spNext)
Sets the current ShaderProgram and enables it.
final int getAAQuality()
Returns pass2 AA-quality rendering value for Graph Region AA render-modes: Region#VBAA_RENDERING_BIT.
final void setClipFrustum(final Frustum clipFrustum)
Set the optional clipping Frustum, which shall be pre-multiplied with the Mv-matrix or null to disabl...
final ShaderProgram getShaderProgram()
Return the current ShaderProgram.
final void setDebugBits(final int mask)
final int setAAQuality(final int v)
Sets pass2 AA-quality rendering value clipped to the range [Region#MIN_AA_QUALITY....
4D Vector based upon four float components.
Vec4f set(final Vec4f o)
this = o, returns this.
Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects.
Frustum set(final Frustum o)
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
final SyncMatrices4f getSyncPMv()
Returns SyncMatrices4f of 2 matrices within one FloatBuffer: P and Mv.
final Object getAttachedObject(final String name)
Returns the attached user object for the given name to this GLContext.
final Object detachObject(final String name)
final Object attachObject(final String name, final Object obj)
Sets the attached user object for the given name to this GLContext.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
final int setLocation(final int v)
Sets the given location of the shader attribute.
final String getName()
The name of the reflecting shader array attribute.
final int getLocation()
Returns the shader attribute location for this name, -1 if not yet determined.
int program()
Returns the shader program name, which is non zero if valid.
synchronized void useProgram(final GL2ES2 gl, boolean on)
void dumpSource(final PrintStream out)
boolean equals(final Object obj)
synchronized void notifyNotInUse()
void glUniform(GLUniformData data)
GLContext getContext()
Returns the GLContext associated which this GL object.