28package com.jogamp.graph.curve.opengl;
30import java.io.IOException;
31import java.util.HashMap;
32import java.util.Iterator;
33import java.util.Locale;
35import com.jogamp.opengl.GL;
36import com.jogamp.opengl.GL2ES2;
37import com.jogamp.opengl.GLES2;
38import com.jogamp.opengl.GLException;
40import jogamp.graph.curve.opengl.shader.AttributeNames;
41import jogamp.graph.curve.opengl.shader.UniformNames;
43import com.jogamp.opengl.GLExtensions;
44import com.jogamp.opengl.GLRendererQuirks;
45import com.jogamp.opengl.util.glsl.ShaderCode;
46import com.jogamp.opengl.util.glsl.ShaderProgram;
47import com.jogamp.opengl.util.texture.TextureSequence;
48import com.jogamp.common.os.Platform;
49import com.jogamp.common.util.LongObjectHashMap;
50import com.jogamp.graph.curve.Region;
51import com.jogamp.math.Recti;
52import com.jogamp.math.Vec4f;
53import com.jogamp.math.geom.Frustum;
54import com.jogamp.math.util.PMVMatrix4f;
72 private static final boolean DEBUG_SHADER_MAP =
DEBUG;
193 return new RegionRenderer(sharedPMVMatrix, enableCallback, disableCallback);
198 private final GLCallback enableCallback;
199 private final GLCallback disableCallback;
202 private boolean initialized;
203 private boolean vboSupported =
false;
209 target.
set(viewport);
217 public final int getWidth() {
return viewport.width(); }
219 public final int getHeight() {
return viewport.height(); }
224 this(
null, enableCallback, disableCallback);
231 this.enableCallback = enableCallback;
232 this.disableCallback = disableCallback;
233 if( UseShaderPrograms0 ) {
234 shaderPrograms0 =
new LongObjectHashMap();
235 shaderPrograms1 =
null;
237 shaderPrograms0 =
null;
238 shaderPrograms1 =
new HashMap<ShaderKey, ShaderProgram>();
257 vboSupported = gl.isFunctionAvailable(
"glGenBuffers") &&
258 gl.isFunctionAvailable(
"glBindBuffer") &&
259 gl.isFunctionAvailable(
"glBufferData") &&
260 gl.isFunctionAvailable(
"glDrawElements") &&
261 gl.isFunctionAvailable(
"glVertexAttribPointer") &&
262 gl.isFunctionAvailable(
"glDeleteBuffers");
265 System.err.println(
"TextRendererImpl01: VBO Supported = " +
isVBOSupported());
282 System.err.println(
"TextRenderer: Not initialized!");
286 if( UseShaderPrograms0 ) {
287 for(
final Iterator<LongObjectHashMap.Entry> i = shaderPrograms0.iterator(); i.hasNext(); ) {
291 shaderPrograms0.clear();
293 for(
final Iterator<ShaderProgram> i = shaderPrograms1.values().iterator(); i.hasNext(); ) {
297 shaderPrograms1.clear();
378 if(
null != enableCB ) {
379 enableCB.
run(gl,
this);
382 if(
null != disableCB ) {
383 disableCB.
run(gl,
this);
395 public final void reshapeNotify(
final int x,
final int y,
final int width,
final int height) {
396 viewport.
set(x, y, width, height);
407 public final void reshapePerspective(
final float angle_rad,
final int width,
final int height,
final float near,
final float far) {
409 final float ratio = (float)width/(
float)height;
422 public final void reshapeOrtho(
final int width,
final int height,
final float near,
final float far) {
426 p.
orthoP(0, width, 0, height, near, far);
433 private static final String SHADER_SRC_SUB =
"";
434 private static final String SHADER_BIN_SUB =
"bin";
435 private static final String GLSL_PARAM_COMMENT_START =
"\n// JogAmp Graph Parameter Start\n";
436 private static final String GLSL_PARAM_COMMENT_END =
"// JogAmp Graph Parameter End\n\n";
437 private static final String GLSL_USE_COLOR_CHANNEL =
"#define USE_COLOR_CHANNEL 1\n";
438 private static final String GLSL_USE_COLOR_TEXTURE =
"#define USE_COLOR_TEXTURE 1\n";
439 private static final String GLSL_USE_FRUSTUM_CLIPPING =
"#define USE_FRUSTUM_CLIPPING 1\n";
440 private static final String GLSL_DEF_SAMPLE_COUNT =
"#define SAMPLE_COUNT ";
441 private static final String GLSL_CONST_SAMPLE_COUNT =
"const float sample_count = ";
442 private static final String GLSL_MAIN_BEGIN =
"void main (void)\n{\n";
443 private static final String gcuTexture2D =
"gcuTexture2D";
444 private static final String GLSL_USE_DISCARD =
"#define USE_DISCARD 1\n";
446 private String getVersionedShaderName() {
447 return "curverenderer01";
451 private static final String es2_precision_fp =
"\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n";
453 private final String getFragmentShaderPrecision(
final GL2ES2 gl) {
455 return es2_precision_fp;
457 if( ShaderCode.requiresGL3DefaultPrecision(gl) ) {
458 return ShaderCode.gl3_default_precision_fp;
463 private static enum ShaderModeSelector1 {
465 PASS1_SIMPLE(
"curve",
"_simple", 0),
467 PASS1_WEIGHT(
"curve",
"_weight", 0),
469 PASS2_MSAA(
"msaa",
"", 0),
471 PASS2_VBAA_QUAL0_SAMPLES1(
"vbaa",
"_flipquad3", 1),
473 PASS2_VBAA_QUAL0_SAMPLES2(
"vbaa",
"_flipquad3", 2),
475 PASS2_VBAA_QUAL0_SAMPLES4(
"vbaa",
"_flipquad3", 4),
477 PASS2_VBAA_QUAL0_SAMPLES8(
"vbaa",
"_flipquad3", 8),
480 PASS2_VBAA_QUAL1_SAMPLES1(
"vbaa",
"_bforce_odd", 1),
482 PASS2_VBAA_QUAL1_SAMPLES2(
"vbaa",
"_bforce_even", 2),
484 PASS2_VBAA_QUAL1_SAMPLES3(
"vbaa",
"_bforce_odd", 3),
486 PASS2_VBAA_QUAL1_SAMPLES4(
"vbaa",
"_bforce_even", 4),
488 PASS2_VBAA_QUAL1_SAMPLES5(
"vbaa",
"_bforce_odd", 5),
490 PASS2_VBAA_QUAL1_SAMPLES6(
"vbaa",
"_bforce_even", 6),
492 PASS2_VBAA_QUAL1_SAMPLES7(
"vbaa",
"_bforce_odd", 7),
494 PASS2_VBAA_QUAL1_SAMPLES8(
"vbaa",
"_bforce_even", 8);
496 public final String tech;
497 public final String sub;
498 public final int sampleCount;
500 ShaderModeSelector1(
final String tech,
final String sub,
final int sampleCount) {
503 this.sampleCount = sampleCount;
506 public static ShaderModeSelector1 selectPass1(
final int renderModes) {
507 return Region.hasVariableWeight(renderModes) ? PASS1_WEIGHT : PASS1_SIMPLE;
510 public static ShaderModeSelector1 selectPass2(
final int renderModes,
final int quality,
final int sampleCount) {
511 if( Region.isVBAA(renderModes) ) {
513 if( sampleCount < 2 ) {
514 return PASS2_VBAA_QUAL0_SAMPLES1;
515 }
else if( sampleCount < 4 ) {
516 return PASS2_VBAA_QUAL0_SAMPLES2;
517 }
else if( sampleCount < 8 ) {
518 return PASS2_VBAA_QUAL0_SAMPLES4;
520 return PASS2_VBAA_QUAL0_SAMPLES8;
523 switch( sampleCount ) {
525 case 1:
return PASS2_VBAA_QUAL1_SAMPLES1;
526 case 2:
return PASS2_VBAA_QUAL1_SAMPLES2;
527 case 3:
return PASS2_VBAA_QUAL1_SAMPLES3;
528 case 4:
return PASS2_VBAA_QUAL1_SAMPLES4;
529 case 5:
return PASS2_VBAA_QUAL1_SAMPLES5;
530 case 6:
return PASS2_VBAA_QUAL1_SAMPLES6;
531 case 7:
return PASS2_VBAA_QUAL1_SAMPLES7;
532 default:
return PASS2_VBAA_QUAL1_SAMPLES8;
541 private static class ShaderKey {
542 final boolean isTwoPass;
544 final ShaderModeSelector1 sms;
545 final boolean hasFrustumClipping;
546 final boolean hasColorChannel;
547 final boolean hasColorTexture;
548 final String colorTexSeqID;
552 ShaderKey(
final boolean isTwoPass,
final boolean pass1,
final ShaderModeSelector1 sms,
553 final boolean hasFrustumClipping,
final boolean hasColorChannel,
554 final boolean hasColorTexture,
final TextureSequence colorTexSeq,
final int colorTexSeqHash)
556 this.isTwoPass = isTwoPass;
559 this.hasFrustumClipping = hasFrustumClipping;
560 this.hasColorChannel = hasColorChannel;
561 this.hasColorTexture = hasColorTexture;
562 if( hasColorTexture ) {
563 this.colorTexSeqID = colorTexSeq.getTextureFragmentShaderHashID();
565 this.colorTexSeqID =
"";
567 hashValue = getShaderKey1(isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms, colorTexSeqHash);
570 public final int hashCode() {
return hashValue; }
572 public final boolean equals(
final Object other) {
573 if(
this == other ) {
return true; }
574 if( !(other instanceof ShaderKey) ) {
577 final ShaderKey o = (ShaderKey)other;
578 return isTwoPass == o.isTwoPass &&
582 sms.ordinal() == o.sms.ordinal() &&
583 hasFrustumClipping == o.hasFrustumClipping &&
584 hasColorChannel == o.hasColorChannel &&
585 hasColorTexture == o.hasColorTexture &&
586 colorTexSeqID.equals(o.colorTexSeqID);
589 public String toString() {
590 return shaderHashToString(hashValue, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms);
593 private static final boolean UseShaderPrograms0 =
true;
594 private final LongObjectHashMap shaderPrograms0;
595 private final HashMap<ShaderKey, ShaderProgram> shaderPrograms1;
597 private static String shaderHashToString(
final int hashCode,
final boolean isTwoPass,
final boolean pass1,
598 final boolean hasFrustumClipping,
final boolean hasColorChannel,
final boolean hasColorTexture,
599 final ShaderModeSelector1 sms) {
600 return "ShaderHash[hash 0x"+Integer.toHexString(hashCode)+
", is2Pass "+isTwoPass+
", pass1 "+pass1+
601 ", has[clip "+hasFrustumClipping+
", colChan "+hasColorChannel+
", colTex "+hasColorTexture+
"], "+sms+
"]";
603 private static String shaderKeyToString(
final long key,
final boolean isTwoPass,
final boolean pass1,
604 final boolean hasFrustumClipping,
final boolean hasColorChannel,
final boolean hasColorTexture,
605 final ShaderModeSelector1 sms) {
606 return "ShaderKey[key 0x"+Long.toHexString(key)+
", is2Pass "+isTwoPass+
", pass1 "+pass1+
607 ", has[clip "+hasFrustumClipping+
", colChan "+hasColorChannel+
", colTex "+hasColorTexture+
"], "+sms+
"]";
610 private static long getShaderKey0(
final boolean isTwoPass,
final boolean pass1,
611 final boolean hasFrustumClipping,
final boolean hasColorChannel,
final boolean hasColorTexture,
612 final ShaderModeSelector1 sms,
final long colorTexSeqHash) {
621 long hash = isTwoPass ? 1L : 0L;
622 hash |= ( pass1 ? 1L : 0L ) << 1;
623 hash |= (long)( sms.ordinal() & 0b11111 ) << 2;
624 hash |= ( hasFrustumClipping ? 1L : 0L ) << 7;
625 hash |= ( hasColorChannel ? 1L : 0L ) << 8;
626 hash |= ( hasColorTexture ? 1L : 0L ) << 9;
627 hash |= ( colorTexSeqHash & 0xFFFFFFL ) << 32;
630 private static int getShaderKey1(
final boolean isTwoPass,
final boolean pass1,
631 final boolean hasFrustumClipping,
final boolean hasColorChannel,
final boolean hasColorTexture,
632 final ShaderModeSelector1 sms,
final int colorTexSeqHash) {
634 int hash = 31 * ( isTwoPass ? 1 : 0 );
635 hash = ((hash << 5) - hash) + ( pass1 ? 1 : 0 ) ;
638 hash = ((hash << 5) - hash) + sms.ordinal();
639 hash = ((hash << 5) - hash) + ( hasFrustumClipping ? 1 : 0 );
640 hash = ((hash << 5) - hash) + ( hasColorChannel ? 1 : 0 );
641 hash = ((hash << 5) - hash) + ( hasColorTexture ? 1 : 0 );
642 hash = ((hash << 5) - hash) + colorTexSeqHash;
664 final ShaderModeSelector1 sms = pass1 ? ShaderModeSelector1.selectPass1(renderModes) :
666 final boolean hasFrustumClipping = (
null !=
getClipFrustum() ) && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
668 final boolean hasColorTexture = pass1 &&
Region.
hasColorTexture( renderModes ) &&
null != colorTexSeq;
669 final int colorTexSeqHash;
670 final String colTexLookupFuncName;
671 if( hasColorTexture ) {
675 colTexLookupFuncName =
"";
679 if( UseShaderPrograms0 ) {
680 return useShaderProgram0(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel,
681 hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash);
683 return useShaderProgram1(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel,
684 hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash);
687 private final boolean useShaderProgram0(
final GL2ES2 gl,
final int renderModes,
688 final boolean isTwoPass,
final boolean pass1,
final ShaderModeSelector1 sms,
689 final boolean hasFrustumClipping,
final boolean hasColorChannel,
691 final String colTexLookupFuncName,
final int colorTexSeqHash)
693 final long shaderKey = getShaderKey0(isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms, colorTexSeqHash);
703 if( DEBUG_SHADER_MAP ) {
705 System.err.printf(
"RegionRenderer.useShaderProgram0.X1: GOT renderModes %s, %s -> sp %d / %d (changed)%n",
707 shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.
program(), sp.id());
709 System.err.printf(
"RegionRenderer.useShaderProgram0.X1: GOT renderModes %s, %s -> sp %d / %d (keep)%n",
711 shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.
program(), sp.id());
716 sp = createShaderProgram(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel,
717 hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash);
720 if( DEBUG_SHADER_MAP ) {
721 System.err.printf(
"RegionRenderer.useShaderProgram0.X2: NEW renderModes %s, %s -> sp %d / %d (new)%n",
722 Region.getRenderModeString(renderModes),
723 shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.
program(), sp.id());
726 final ShaderProgram spOld = (ShaderProgram) shaderPrograms0.put(shaderKey, sp);
727 if(
null != spOld ) {
729 final String msg = String.format((Locale)
null,
730 "RegionRenderer.useShaderProgram0: WARNING Shader-HashCode Collision: hash 0x%s: %s, %s -> sp %d / %d (new)%n",
731 Long.toHexString(shaderKey), Region.getRenderModeString(renderModes),
732 shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.
program(), sp.id());
733 throw new RuntimeException(msg);
737 private final boolean useShaderProgram1(
final GL2ES2 gl,
final int renderModes,
738 final boolean isTwoPass,
final boolean pass1,
final ShaderModeSelector1 sms,
739 final boolean hasFrustumClipping,
final boolean hasColorChannel,
740 final boolean hasColorTexture,
final TextureSequence colorTexSeq,
741 final String colTexLookupFuncName,
final int colorTexSeqHash) {
742 final ShaderKey shaderKey =
new ShaderKey(isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel,
743 hasColorTexture, colorTexSeq, colorTexSeqHash);
749 ShaderProgram sp = shaderPrograms1.get( shaderKey );
752 if( DEBUG_SHADER_MAP ) {
754 System.err.printf(
"RegionRenderer.useShaderProgram1.X1: GOT renderModes %s, %s -> sp %d / %d (changed)%n",
755 Region.getRenderModeString(renderModes), shaderKey, sp.program(), sp.id());
757 System.err.printf(
"RegionRenderer.useShaderProgram1.X1: GOT renderModes %s, %s -> sp %d / %d (keep)%n",
758 Region.getRenderModeString(renderModes), shaderKey, sp.program(), sp.id());
763 sp = createShaderProgram(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel,
764 hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash);
767 if( DEBUG_SHADER_MAP ) {
768 System.err.printf(
"RegionRenderer.useShaderProgram1.X2: NEW renderModes %s, %s -> sp %d / %d (new)%n",
769 Region.getRenderModeString(renderModes), shaderKey, sp.program(), sp.id());
773 shaderPrograms1.put(shaderKey, sp);
776 @SuppressWarnings(
"unused")
777 private final ShaderProgram createShaderProgram(final GL2ES2 gl, final
int renderModes,
778 final
boolean isTwoPass, final
boolean pass1, final ShaderModeSelector1 sms,
779 final
boolean hasFrustumClipping, final
boolean hasColorChannel,
780 final
boolean hasColorTexture, final TextureSequence colorTexSeq,
781 final String colTexLookupFuncName, final
int colorTexSeqHash)
783 final String versionedBaseName = getVersionedShaderName();
784 final String vertexShaderName;
786 vertexShaderName = versionedBaseName+
"-pass"+(pass1?1:2);
788 vertexShaderName = versionedBaseName+
"-single";
790 final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, vertexShaderName,
true);
791 final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, versionedBaseName+
"-segment-head",
true);
793 if( hasColorTexture && GLES2.GL_TEXTURE_EXTERNAL_OES == colorTexSeq.getTextureTarget() ) {
794 if( !gl.isExtensionAvailable(GLExtensions.OES_EGL_image_external) ) {
795 throw new GLException(GLExtensions.OES_EGL_image_external+
" requested but not available");
798 boolean preludeGLSLVersion =
true;
799 if( hasColorTexture && GLES2.GL_TEXTURE_EXTERNAL_OES == colorTexSeq.getTextureTarget() ) {
800 if( Platform.OSType.ANDROID == Platform.getOSType() && gl.isGLES3() ) {
804 preludeGLSLVersion =
false;
810 int posVp = rsVp.defaultShaderCustomization(gl, preludeGLSLVersion,
true);
812 int posFp = preludeGLSLVersion ? rsFp.addGLSLVersion(gl) : 0;
813 if( hasColorTexture ) {
814 posFp = rsFp.insertShaderSource(0, posFp, colorTexSeq.getRequiredExtensionsShaderStub());
816 if( pass1 && !preludeGLSLVersion || ( gl.isGLES2() && !gl.isGLES3() ) ) {
817 posFp = rsFp.insertShaderSource(0, posFp, ShaderCode.createExtensionDirective(GLExtensions.OES_standard_derivatives, ShaderCode.ENABLE));
820 final String rsFpDefPrecision = getFragmentShaderPrecision(gl);
821 if(
null != rsFpDefPrecision ) {
822 posFp = rsFp.insertShaderSource(0, posFp, rsFpDefPrecision);
825 posFp = rsFp.addDefaultShaderPrecision(gl, posFp);
832 posVp = rsVp.insertShaderSource(0, posVp, GLSL_PARAM_COMMENT_START);
833 posFp = rsFp.insertShaderSource(0, posFp, GLSL_PARAM_COMMENT_START);
835 if( !gl.getContext().hasRendererQuirk(GLRendererQuirks.GLSLBuggyDiscard) ) {
836 posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_DISCARD);
839 if( hasFrustumClipping ) {
840 posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_FRUSTUM_CLIPPING);
841 posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_FRUSTUM_CLIPPING);
844 if( hasColorChannel ) {
845 posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_CHANNEL);
846 posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_CHANNEL);
848 if( hasColorTexture ) {
849 rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_TEXTURE);
850 posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_TEXTURE);
853 posFp = rsFp.insertShaderSource(0, posFp, GLSL_DEF_SAMPLE_COUNT+sms.sampleCount+
"\n");
854 posFp = rsFp.insertShaderSource(0, posFp, GLSL_CONST_SAMPLE_COUNT+sms.sampleCount+
".0;\n");
857 posVp = rsVp.insertShaderSource(0, posVp, GLSL_PARAM_COMMENT_END);
858 posFp = rsFp.insertShaderSource(0, posFp, GLSL_PARAM_COMMENT_END);
861 posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class,
"uniforms.glsl");
862 posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class,
"varyings.glsl");
863 if( hasColorTexture || hasFrustumClipping ) {
864 posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class,
"functions.glsl");
866 }
catch (
final IOException ioe) {
867 throw new RuntimeException(
"Failed to read: includes", ioe);
870 throw new RuntimeException(
"Failed to read: includes");
873 if( hasColorTexture ) {
874 posFp = rsFp.insertShaderSource(0, posFp,
"uniform "+colorTexSeq.getTextureSampler2DType()+
" "+UniformNames.gcu_ColorTexUnit+
";\n");
875 posFp = rsFp.insertShaderSource(0, posFp, colorTexSeq.getTextureLookupFragmentShaderImpl());
878 posFp = rsFp.insertShaderSource(0, posFp, GLSL_MAIN_BEGIN);
880 final String passS = pass1 ?
"-pass1-" :
"-pass2-";
881 final String shaderSegment = versionedBaseName+passS+sms.tech+sms.sub+
".glsl";
883 System.err.printf(
"RegionRenderer.createShaderProgram.1: segment %s%n", shaderSegment);
886 posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, shaderSegment);
887 }
catch (
final IOException ioe) {
888 throw new RuntimeException(
"Failed to read: "+shaderSegment, ioe);
891 throw new RuntimeException(
"Failed to read: "+shaderSegment);
893 posFp = rsFp.insertShaderSource(0, posFp,
"}\n");
895 if( hasColorTexture ) {
896 rsFp.replaceInShaderSource(gcuTexture2D, colTexLookupFuncName);
899 final ShaderProgram sp =
new ShaderProgram();
904 throw new GLException(
"RegionRenderer: Couldn't init program: "+sp);
907 if( !sp.link(gl, System.err) ) {
908 throw new GLException(
"could not link program: "+sp);
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static boolean isTwoPass(final int renderModes)
Returns true if given renderModes has any of Region#AA_RENDERING_MASK set.
static final boolean DEBUG_ALL_EVENT
static String getRenderModeString(final int renderModes)
Returns a unique technical description string for renderModes as follows:
static final boolean DEBUG_INSTANCE
static boolean hasColorChannel(final int renderModes)
Returns true if render mode has a color channel, i.e.
static final boolean DEBUG
Debug flag for [com.
static boolean hasColorTexture(final int renderModes)
Returns true if render mode has a color texture, i.e.
final void setColorStatic(final float r, final float g, final float b, final float a)
final RenderState getRenderState()
Return the RenderState composition.
static RegionRenderer create(final PMVMatrix4f sharedPMVMatrix, final GLCallback enableCallback, final GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including its RenderState composition.
final boolean isVBOSupported()
final void enable(final GL2ES2 gl, final boolean enable)
Enabling or disabling the RenderState's current shader program.
static final boolean DEBUG_ALL_EVENT
final int getAAQuality()
Returns pass2 AA-quality rendering value for Graph Region AA render-modes: Region#VBAA_RENDERING_BIT.
final int getHeight()
Return height of current viewport.
final void reshapeOrtho(final int width, final int height, final float near, final float far)
Orthogonal projection, method also calls reshapeNotify(int, int, int, int).
static RegionRenderer create(final GLCallback enableCallback, final GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including its RenderState composition.
final boolean useShaderProgram(final GL2ES2 gl, final int renderModes, final boolean pass1, final TextureSequence colorTexSeq)
Generate, selects and caches the desired Curve-Graph ShaderProgram according to the given parameters.
final boolean isInitialized()
final void setColorStatic(final Vec4f rgbaColor)
final PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
RegionRenderer(final PMVMatrix4f sharedPMVMatrix, final GLCallback enableCallback, final GLCallback disableCallback)
final void setClipFrustum(final Frustum clipFrustum)
Set the optional clipping Frustum, which shall be pre-multiplied with the Mv-matrix or null to disabl...
RegionRenderer(final GLCallback enableCallback, final GLCallback disableCallback)
final void reshapeNotify(final int x, final int y, final int width, final int height)
No PMVMatrix4f operation is performed here.
final int getWidth()
Return width of current viewport.
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 void clearHintBits(final int mask)
static final GLCallback defaultBlendDisable
Default GL#GL_BLEND disable GLCallback, simply turning-off the GL#GL_BLEND state and turning-on depth...
final Vec4f getColorStatic(final Vec4f rgbaColor)
final int setAAQuality(final int v)
Sets pass2 AA-quality rendering value clipped to the range [Region#MIN_AA_QUALITY....
final boolean hintBitsSet(final int mask)
static final boolean DEBUG
static final GLCallback defaultBlendEnable
Default GL#GL_BLEND enable GLCallback, turning-off depth writing via GL#glDepthMask(boolean) if Rende...
final void init(final GL2ES2 gl)
Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext if no...
final int getSampleCount()
Returns pass2 AA sample count for Graph Region AA render-modes: VBAA_RENDERING_BIT or Region#MSAA_REN...
static RegionRenderer create()
Create a hardware accelerated RegionRenderer including its RenderState composition.
final void reshapePerspective(final float angle_rad, final int width, final int height, final float near, final float far)
Perspective projection, method also calls reshapeNotify(int, int, int, int).
final Recti getViewport(final Recti target)
Copies the current Rect4i viewport in given target and returns it for chaining.
final void setWeight(final float v)
final Recti getViewport()
Borrows the current Rect4i viewport w/o copying.
final Frustum getClipFrustum()
Returns the optional Mv-premultiplied clipping Frustum or null if unused.
final void enable(final GL2ES2 gl, final boolean enable, final GLCallback enableCB, final GLCallback disableCB)
Same as enable(GL2ES2, boolean) but allowing to force GLCallbacks off.
final void destroy(final GL2ES2 gl)
Deletes all ShaderPrograms and nullifies its references including RenderState#destroy(GL2ES2).
final void setHintBits(final int mask)
static final boolean DEBUG_INSTANCE
The RenderState is owned by RegionRenderer.
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)
static final int BITHINT_BLENDING_ENABLED
Bitfield hint, if set stating enabled GL#GL_BLEND, otherwise disabled.
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 int getSampleCount()
Returns pass2 AA sample count for Graph Region AA render-modes: VBAA_RENDERING_BIT or Region#MSAA_REN...
final boolean detachFrom(final GL2ES2 gl)
final PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
final void clearHintBits(final int mask)
final void setWeight(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 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 int setAAQuality(final int v)
Sets pass2 AA-quality rendering value clipped to the range [Region#MIN_AA_QUALITY....
Rectangle with x, y, width and height integer components.
void set(final Recti o)
this = o, returns this.
4D Vector based upon four float components.
Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects.
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
final PMVMatrix4f perspectiveP(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Multiply the projection matrix with the perspective/frustum matrix.
final void orthoP(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Multiply the projection matrix with the orthogonal matrix.
final PMVMatrix4f loadPIdentity()
Load the projection matrix with the values of the given Matrix4f.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
int program()
Returns the shader program name, which is non zero if valid.
synchronized void destroy(final GL2ES2 gl)
Detaches all shader codes and deletes the program.
synchronized void useProgram(final GL2ES2 gl, boolean on)
May be passed to RegionRenderer ctor, e.g.
void run(GL gl, RegionRenderer renderer)
void glBlendEquation(int mode)
Entry point to C language function: void {@native glBlendEquation}(GLenum mode) Part of GL_ES_VERS...
void glDisable(int cap)
Entry point to C language function: void {@native glDisable}(GLenum cap) Part of GL_ES_VERSION_2_0...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_BLEND
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BLEND" with expressio...
void glDepthMask(boolean flag)
Entry point to C language function: void {@native glDepthMask}(GLboolean flag) Part of GL_ES_VERSI...
static final int GL_FUNC_ADD
GL_ARB_imaging, GL_ES_VERSION_2_0, GL_VERSION_1_4, GL_EXT_blend_minmax, GL_OES_blend_subtract Alias f...
Protocol for texture sequences, like animations, movies, etc.
int getTextureFragmentShaderHashCode()
Returns the hash code of the string getTextureFragmentShaderHashID().
String setTextureLookupFunctionName(String texLookupFuncName)
Set the desired shader code's texture lookup function name.