diff options
19 files changed, 98 insertions, 91 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java index 1ec894d15..866d6623d 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java @@ -52,7 +52,7 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { public GPURegionGLListener00 (final int renderModes, final int sampleCount, final boolean debug, final boolean trace) { super(RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); setMatrix(-20, 00, -50, 0f, sampleCount); } @@ -92,7 +92,7 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { outlineShape.closeLastOutline(true); region = GLRegion.create(glp, getRenderModes(), null, outlineShape); - region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new Vec4f()) : null); + region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getColorStatic(new Vec4f()) : null); } @Override @@ -101,12 +101,10 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); + getRenderer().setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); createTestOutline(gl.getGLProfile()); } @@ -124,8 +122,8 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { pmv.glLoadIdentity(); pmv.glTranslatef(getXTran(), getYTran(), getZTran()); pmv.glRotatef(getAngle(), 0, 1, 0); - if( weight != regionRenderer.getRenderState().getWeight() ) { - regionRenderer.getRenderState().setWeight(weight); + if( weight != regionRenderer.getWeight() ) { + regionRenderer.setWeight(weight); } regionRenderer.enable(gl, true); region.draw(gl, regionRenderer, getSampleCount()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java index fd1ba4df3..e5699a2d6 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java @@ -59,7 +59,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { public GPURegionGLListener01 (final int shape_ctor_mode, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) { super(RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); this.shape_ctor_mode = shape_ctor_mode; - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); setMatrix(-20, 00, -50, 0f, sampleCount); } @@ -247,12 +247,10 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); + getRenderer().setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); outlineShape = new OutlineShape(); switch( shape_ctor_mode ) { @@ -273,7 +271,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { break; } region = GLRegion.create(gl.getGLProfile(), getRenderModes(), null, outlineShape); - region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new Vec4f()) : null); + region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getColorStatic(new Vec4f()) : null); } @Override @@ -289,8 +287,8 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { pmv.glLoadIdentity(); pmv.glTranslatef(getXTran(), getYTran(), getZTran()); pmv.glRotatef(getAngle(), 0, 1, 0); - if( weight != regionRenderer.getRenderState().getWeight() ) { - regionRenderer.getRenderState().setWeight(weight); + if( weight != regionRenderer.getWeight() ) { + regionRenderer.setWeight(weight); } regionRenderer.enable(gl, true); region.draw(gl, regionRenderer, getSampleCount()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java index f23d15b24..42b42a719 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java @@ -53,7 +53,7 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { public GPURegionGLListener10 (final int renderModes, final int sampleCount, final boolean debug, final boolean trace) { super(RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); setMatrix(-20, 00, -50, 0f, sampleCount); } @@ -106,12 +106,10 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); + getRenderer().setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); createTestOutline(gl.getGLProfile()); } @@ -130,8 +128,8 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { pmv.glLoadIdentity(); pmv.glTranslatef(getXTran(), getYTran(), getZTran()); pmv.glRotatef(getAngle(), 0, 1, 0); - if( weight != regionRenderer.getRenderState().getWeight() ) { - regionRenderer.getRenderState().setWeight(weight); + if( weight != regionRenderer.getWeight() ) { + regionRenderer.setWeight(weight); } regionRenderer.enable(gl, true); region.draw(gl, regionRenderer, getSampleCount()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextGLListener0A.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextGLListener0A.java index 0fd982cd6..1f6be695c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextGLListener0A.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextGLListener0A.java @@ -51,12 +51,10 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + getRenderer().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); } @Override diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java index 26feafa5a..a5fac1270 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java @@ -154,7 +154,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // NOTE_ALPHA_BLENDING: We use alpha-blending super(RegionRenderer.create(blending ? RegionRenderer.defaultBlendEnable : null, blending ? RegionRenderer.defaultBlendDisable : null), renderModes, debug, trace); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); this.textRegionUtil = new TextRegionUtil(renderModes); this.regionFPS = GLRegion.create(glp, renderModes, null, 0, 0); this.regionHead = GLRegion.create(glp, renderModes, null, 0, 0); @@ -302,11 +302,10 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; final RegionRenderer renderer = getRenderer(); - final RenderState rs = renderer.getRenderState(); final PMVMatrix pmv = renderer.getMatrix(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); - rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV); final float pixelSizeHead = FontScale.toPixels(fontSizeHead, dpiV); final float mmSizeHead = pixelSizeHead / ppmmV; @@ -333,7 +332,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB fontSizeHead, pixelSizeHead, mmSizeHead, fontSizeCenter, pixelSizeCenter, mmSizeCenter, modeS, getSampleCount()[0], sampleCountFPS[0], - renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), + renderer.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), drawable.getChosenGLCapabilities().getAlphaBits()); // bottom, half line up @@ -390,7 +389,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final float sxy = nearPlaneS * pixelSizeCenter; pmv.glScalef(sxy, sxy, 1.0f); } - rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); + renderer.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); if( bottomTextUseFrustum ) { regionBottom.setFrustum(pmv.getFrustum()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java index 3e6cec83e..438457993 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java +++ b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java @@ -132,11 +132,11 @@ public abstract class TextRendererGLELBase implements GLEventListener { public void init(final GLAutoDrawable drawable) { exclusivePMVMatrix = null == sharedPMVMatrix; renderer = RegionRenderer.create(sharedPMVMatrix, enableCallback, disableCallback); - renderer.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + renderer.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); this.textRenderUtil = new TextRegionUtil(renderModes); final GL2ES2 gl = drawable.getGL().getGL2ES2(); renderer.init(gl); - renderer.getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]); + renderer.setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]); final Object upObj = drawable.getUpstreamWidget(); if( upObj instanceof Window ) { diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java index 7fee8ef9b..436bab31a 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java @@ -313,7 +313,7 @@ public class UISceneDemo20 implements GLEventListener { } scene = new Scene(); scene.setPMVMatrixSetup(new MyPMVMatrixSetup()); - scene.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + scene.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); // scene.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? scene.setDebugBorderBox(options.debugBoxThickness); scene.addShape(buttonsLeft); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemoU01a.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemoU01a.java index 27bc34b58..dd4c0766c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemoU01a.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemoU01a.java @@ -92,10 +92,11 @@ import com.jogamp.opengl.util.PMVMatrix; */ public class UISceneDemoU01a { static final GraphUIDemoArgs options = new GraphUIDemoArgs(1432, 770, Region.VBAA_RENDERING_BIT | Region.COLORCHANNEL_RENDERING_BIT); - static final Vec4f fg_color = new Vec4f( 0, 0, 0, 1 ); + static final Vec4f text_color = new Vec4f( 0, 1, 0, 1 ); static Font font; static boolean projOrtho = true; static boolean projOrthoWin = false; + static boolean textOnly = false; static int pass2TexUnit = GLRegion.DEFAULT_TWO_PASS_TEXTURE_UNIT; static final Vec2i winOrigin = new Vec2i(options.surface_width/2, options.surface_height/2); static final float normWidgetSize = 1/4f; @@ -121,6 +122,8 @@ public class UISceneDemoU01a { } else if(args[idx[0]].equals("-y")) { idx[0]++; winOrigin.setY( MiscUtils.atoi(args[idx[0]], winOrigin.y()) ); + } else if(args[idx[0]].equals("-textOnly")) { + textOnly = true; } } } @@ -207,11 +210,13 @@ public class UISceneDemoU01a { public void init(final GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - shape = new CrossHair(options.renderModes, normWidgetSize, normWidgetSize, normWidgetSize/100f); // normalized: 1 is 100% surface size (width and/or height) - shape.setTextureUnit(pass2TexUnit); - shape.setColor(0, 0, 1, 1); - System.err.println("Init: Shape bounds "+shape.getBounds(drawable.getGLProfile())); - System.err.println("Init: Shape "+shape); + if( !textOnly ) { + shape = new CrossHair(options.renderModes, normWidgetSize, normWidgetSize, normWidgetSize/100f); // normalized: 1 is 100% surface size (width and/or height) + shape.setTextureUnit(pass2TexUnit); + shape.setColor(0, 0, 1, 1); + System.err.println("Init: Shape bounds "+shape.getBounds(drawable.getGLProfile())); + System.err.println("Init: Shape "+shape); + } renderer.init(gl); @@ -226,7 +231,7 @@ public class UISceneDemoU01a { setMatrix(renderer.getMatrix(), renderer.getViewport()); // scale shapes from normalized size 1 and to keep aspect ratio - { + if( !textOnly ) { final float s = Math.min(worldDim.x(), worldDim.y()); shape.setScale(s, s, 1f); } @@ -306,7 +311,7 @@ public class UISceneDemoU01a { drawText(gl, pmv, "Hello JogAmp Users!"); pmv.glPopMatrix(); } - { + if( !textOnly ) { pmv.glPushMatrix(); shape.setTransform(pmv); @@ -336,7 +341,7 @@ public class UISceneDemoU01a { final float txt_scale = full_width_s < full_height_s ? full_width_s * normWidgetSize : full_height_s * normWidgetSize; pmv.glScalef(txt_scale, txt_scale, 1f); pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); - final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, textRegion.clear(gl), renderer, font, text, fg_color, sampleCount, tempT1, tempT2); + final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, textRegion.clear(gl), renderer, font, text, text_color, sampleCount, tempT1, tempT2); if( onceAtDisplay ) { System.err.println("XXX: full_width: "+worldDim.x()+" / "+txt_box_em.getWidth()+" -> "+full_width_s); @@ -354,7 +359,9 @@ public class UISceneDemoU01a { public void dispose(final GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); textRegion.destroy(gl); - shape.destroy(gl, renderer); + if( !textOnly ) { + shape.destroy(gl, renderer); + } renderer.destroy(gl); System.err.println("Destroyed"); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java index f0329ad3c..2c724fa52 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java @@ -154,7 +154,7 @@ public abstract class GraphShape extends Shape { @Override protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final Vec4f rgba) { if( null != rgba ) { - renderer.getRenderState().setColorStatic(rgba); + renderer.setColorStatic(rgba); } region.draw(gl, renderer, sampleCount); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index c501b8eb8..5100aabf7 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -161,9 +161,6 @@ public final class Scene implements Container, GLEventListener { /** Returns the associated RegionRenderer */ public RegionRenderer getRenderer() { return renderer; } - /** Returns the associated RegionRenderer's RenderState. */ - public RenderState getRenderState() { return renderer.getRenderState(); } - /** * Sets the clear parameter for {@link GL#glClearColor(float, float, float, float) glClearColor(..)} and {@link GL#glClear(int) glClear(..)} * to be issued at {@link #display(GLAutoDrawable)}. @@ -401,7 +398,7 @@ public final class Scene implements Container, GLEventListener { final float color = ( i + 1f ) / ( shapeCount + 2f ); // FIXME // System.err.printf("drawGL: color %f, index %d of [0..%d[%n", color, i, shapeCount); - renderer.getRenderState().setColorStatic(color, color, color, 1f); + renderer.setColorStatic(color, color, color, 1f); shape.drawToSelect(gl, renderer, sampleCount0); } else { shape.draw(gl, renderer, sampleCount0); @@ -1041,7 +1038,7 @@ public final class Scene implements Container, GLEventListener { } else { qualityStr = ""; } - if( getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) { + if( getRenderer().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) { blendStr = ", blend"; } else { blendStr = ""; 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 6e5cd1487..c6a50b411 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -36,6 +36,7 @@ import com.jogamp.opengl.GLES2; import com.jogamp.opengl.GLException; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.opengl.math.Recti; +import com.jogamp.opengl.math.Vec4f; import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; @@ -99,14 +100,14 @@ public final class RegionRenderer { public static final GLCallback defaultBlendEnable = new GLCallback() { @Override public void run(final GL gl, final RegionRenderer renderer) { - if( renderer.rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { + if( renderer.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { gl.glDepthMask(false); // gl.glDisable(GL.GL_DEPTH_TEST); // gl.glDepthFunc(GL.GL_ALWAYS); } gl.glEnable(GL.GL_BLEND); gl.glBlendEquation(GL.GL_FUNC_ADD); // default - renderer.rs.setHintMask(RenderState.BITHINT_BLENDING_ENABLED); + renderer.setHintMask(RenderState.BITHINT_BLENDING_ENABLED); } }; @@ -123,9 +124,9 @@ public final class RegionRenderer { public static final GLCallback defaultBlendDisable = new GLCallback() { @Override public void run(final GL gl, final RegionRenderer renderer) { - renderer.rs.clearHintMask(RenderState.BITHINT_BLENDING_ENABLED); + renderer.clearHintMask(RenderState.BITHINT_BLENDING_ENABLED); gl.glDisable(GL.GL_BLEND); - if( renderer.rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { + if( renderer.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { // gl.glEnable(GL.GL_DEPTH_TEST); // gl.glDepthFunc(GL.GL_LESS); gl.glDepthMask(true); @@ -213,16 +214,10 @@ public final class RegionRenderer { /** Return height of current viewport */ public final int getHeight() { return viewport.height(); } - /** Borrow the current {@link PMVMatrix}. */ - public final PMVMatrix getMatrix() { return rs.getMatrix(); } - ////////////////////////////////////// - protected RegionRenderer(final GLCallback enableCallback, final GLCallback disableCallback) - { - this.rs = new RenderState(null); - this.enableCallback = enableCallback; - this.disableCallback = disableCallback; + protected RegionRenderer(final GLCallback enableCallback, final GLCallback disableCallback) { + this(null, enableCallback, disableCallback); } protected RegionRenderer(final PMVMatrix sharedPMVMatrix, @@ -289,6 +284,29 @@ public final class RegionRenderer { /** Return the {@link RenderState} composition. */ public final RenderState getRenderState() { return rs; } + // + // RenderState forwards + // + + /** Borrow the current {@link PMVMatrix}. */ + public final PMVMatrix getMatrix() { return rs.getMatrix(); } + + public final float getWeight() { return rs.getWeight(); } + + public final void setWeight(final float v) { rs.setWeight(v); } + + public final Vec4f getColorStatic(final Vec4f rgbaColor) { return rs.getColorStatic(rgbaColor); } + + public final void setColorStatic(final Vec4f rgbaColor){ rs.setColorStatic(rgbaColor); } + + public final void setColorStatic(final float r, final float g, final float b, final float a){ rs.setColorStatic(r, g, b, a); } + + public final boolean isHintMaskSet(final int mask) { return rs.isHintMaskSet(mask); } + + public final void setHintMask(final int mask) { rs.setHintMask(mask); } + + public final void clearHintMask(final int mask) { rs.clearHintMask(mask); } + /** * Enabling or disabling the {@link #getRenderState() RenderState}'s * current {@link RenderState#getShaderProgram() shader program}. @@ -346,7 +364,7 @@ public final class RegionRenderer { public final void reshapePerspective(final float angle, final int width, final int height, final float near, final float far) { reshapeNotify(0, 0, width, height); final float ratio = (float)width/(float)height; - final PMVMatrix p = rs.getMatrix(); + final PMVMatrix p = getMatrix(); p.glMatrixMode(GLMatrixFunc.GL_PROJECTION); p.glLoadIdentity(); p.gluPerspective(angle, ratio, near, far); @@ -357,7 +375,7 @@ public final class RegionRenderer { */ public final void reshapeOrtho(final int width, final int height, final float near, final float far) { reshapeNotify(0, 0, width, height); - final PMVMatrix p = rs.getMatrix(); + final PMVMatrix p = getMatrix(); p.glMatrixMode(GLMatrixFunc.GL_PROJECTION); p.glLoadIdentity(); p.glOrthof(0, width, 0, height, near, far); @@ -525,7 +543,7 @@ public final class RegionRenderer { ShaderProgram sp = (ShaderProgram) shaderPrograms.get( shaderKey ); if( null != sp ) { - final boolean spChanged = getRenderState().setShaderProgram(gl, sp); + final boolean spChanged = rs.setShaderProgram(gl, sp); if( DEBUG ) { if( spChanged ) { 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()); @@ -648,7 +666,7 @@ public final class RegionRenderer { if( !sp.link(gl, System.err) ) { throw new GLException("could not link program: "+sp); } - getRenderState().setShaderProgram(gl, sp); + rs.setShaderProgram(gl, sp); shaderPrograms.put(shaderKey, sp); if( DEBUG ) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java index 0b25b3d3a..42ee9d2c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java @@ -59,7 +59,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { public GPURegionGLListener01 (final int shape_ctor_mode, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) { super(RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); this.shape_ctor_mode = shape_ctor_mode; - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); setMatrix(-20, 00, -50, 0f, sampleCount); } @@ -247,12 +247,10 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); + getRenderer().setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); outlineShape = new OutlineShape(); switch( shape_ctor_mode ) { @@ -273,7 +271,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { break; } region = GLRegion.create(gl.getGLProfile(), getRenderModes(), null, outlineShape); - region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new Vec4f()) : null); + region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getColorStatic(new Vec4f()) : null); } @Override @@ -289,8 +287,8 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { pmv.glLoadIdentity(); pmv.glTranslatef(getXTran(), getYTran(), getZTran()); pmv.glRotatef(getAngle(), 0, 1, 0); - if( weight != regionRenderer.getRenderState().getWeight() ) { - regionRenderer.getRenderState().setWeight(weight); + if( weight != regionRenderer.getWeight() ) { + regionRenderer.setWeight(weight); } regionRenderer.enable(gl, true); region.draw(gl, regionRenderer, getSampleCount()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java index 10cabb213..716c9f2e7 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java @@ -53,7 +53,7 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { public GPURegionGLListener10 (final int renderModes, final int sampleCount, final boolean debug, final boolean trace) { super(RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); setMatrix(-20, 00, -50, 0f, sampleCount); } @@ -106,12 +106,10 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { final GL2ES2 gl = drawable.getGL().getGL2ES2(); - final RenderState rs = getRenderer().getRenderState(); - gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); - rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); + getRenderer().setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); createTestOutline(gl.getGLProfile()); } @@ -130,8 +128,8 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { pmv.glLoadIdentity(); pmv.glTranslatef(getXTran(), getYTran(), getZTran()); pmv.glRotatef(getAngle(), 0, 1, 0); - if( weight != regionRenderer.getRenderState().getWeight() ) { - regionRenderer.getRenderState().setWeight(weight); + if( weight != regionRenderer.getWeight() ) { + regionRenderer.setWeight(weight); } regionRenderer.enable(gl, true); region.draw(gl, regionRenderer, getSampleCount()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java index f4283bf41..b6391b1cf 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java @@ -153,7 +153,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // NOTE_ALPHA_BLENDING: We use alpha-blending super(RegionRenderer.create(blending ? RegionRenderer.defaultBlendEnable : null, blending ? RegionRenderer.defaultBlendDisable : null), renderModes, debug, trace); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); this.textRegionUtil = new TextRegionUtil(renderModes); this.regionFPS = GLRegion.create(glp, renderModes, null, 0, 0); this.regionHead = GLRegion.create(glp, renderModes, null, 0, 0); @@ -301,11 +301,10 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; final RegionRenderer renderer = getRenderer(); - final RenderState rs = renderer.getRenderState(); final PMVMatrix pmv = renderer.getMatrix(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); - rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV); final float pixelSizeHead = FontScale.toPixels(fontSizeHead, dpiV); final float mmSizeHead = pixelSizeHead / ppmmV; @@ -332,7 +331,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB fontSizeHead, pixelSizeHead, mmSizeHead, fontSizeCenter, pixelSizeCenter, mmSizeCenter, modeS, getSampleCount()[0], sampleCountFPS[0], - renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), + renderer.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), drawable.getChosenGLCapabilities().getAlphaBits()); // bottom, half line up @@ -389,7 +388,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final float sxy = nearPlaneS * pixelSizeCenter; pmv.glScalef(sxy, sxy, 1.0f); } - rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); + renderer.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); if( bottomTextUseFrustum ) { regionBottom.setFrustum(pmv.getFrustum()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java index 8719fea27..9b487a2f0 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java @@ -242,7 +242,7 @@ public class PerfTextRendererNEWT00 { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); final RegionRenderer renderer = RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - renderer.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + renderer.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null, font, text); System.err.println("Region post ctor w/ pre-calculated buffer size"); @@ -268,7 +268,7 @@ public class PerfTextRendererNEWT00 { // region.growBufferSize(123000, 62000); // hack-me gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); renderer.init(gl); - renderer.getRenderState().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); // reshape gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java index 3416958e3..80bb95d05 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -179,13 +179,13 @@ public class TestTextRendererNEWT01 extends UITestCase { System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); final RegionRenderer renderer = RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - renderer.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + renderer.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes); // init gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); renderer.init(gl); - renderer.getRenderState().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); screenshot = new GLReadBufferUtil(false, false); // reshape diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java index 511aa36ba..5ce4005a6 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java @@ -350,8 +350,7 @@ public class TestTextRendererNEWT20 extends UITestCase { System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString()); MSAATool.dump(drawable); - final RenderState rs = getRenderer().getRenderState(); - rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + getRenderer().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java index 3917f7c1b..41b556186 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java @@ -137,13 +137,13 @@ public class TestTextRendererNEWTBugXXXX extends UITestCase { System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); final RegionRenderer renderer = RegionRenderer.create(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - renderer.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + renderer.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes); // init gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); renderer.init(gl); - renderer.getRenderState().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); screenshot = new GLReadBufferUtil(false, false); // reshape diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java index f66d58d3c..8e90d88eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -128,11 +128,11 @@ public abstract class TextRendererGLELBase implements GLEventListener { public void init(final GLAutoDrawable drawable) { exclusivePMVMatrix = null == sharedPMVMatrix; this.renderer = RegionRenderer.create(sharedPMVMatrix, enableCallback, disableCallback); - this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + this.getRenderer().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); this.textRenderUtil = new TextRegionUtil(renderModes); final GL2ES2 gl = drawable.getGL().getGL2ES2(); renderer.init(gl); - renderer.getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]); + renderer.setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]); final Object upObj = drawable.getUpstreamWidget(); if( upObj instanceof Window ) { |