diff options
author | Sven Gothel <[email protected]> | 2023-08-02 15:42:38 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-08-02 15:42:38 +0200 |
commit | bb6ee81bc5514663bb7b22224fcdd5ba34a51ac6 (patch) | |
tree | 2b27c8645cb98cfb558237e7161735e621123779 /src/jogl/classes | |
parent | 94def2d64fd6fb2d789e5d9176f67941f0bb5b8a (diff) |
Graph TextRegionUtil.drawString3D(..): Redefine 'rgbaColor' semantics: Either fill color-channel with value if used and set static-color to white - or just set static color channel with value.
Have the given rgbaColor to definitely setting the text color regardless whether a color channel is used or not.
Note: Using a color-channel is more expensive (color value per vertex) and should only be required if mixing
colors within one region!
Also removes potential side-effects if color-channel is used but user forgets to set the static value properly.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index d751f80f6..975e16e4c 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -199,7 +199,9 @@ public class TextRegionUtil { * @param renderer TODO * @param font {@link Font} to be used * @param str text to be rendered - * @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored. + * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used + * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. + * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only. * @param sampleCount desired multisampling sample count for msaa-rendering. * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched. * @return the bounding box of the given string from the produced and rendered GLRegion @@ -221,6 +223,11 @@ public class TextRegionUtil { res = new AABBox(); res.copy(region.getBounds()); } + if( !region.hasColorChannel() ) { + renderer.setColorStatic(rgbaColor); + } else { + renderer.setColorStatic(1, 1, 1, 1); + } region.draw(gl, renderer, sampleCount); return res; } @@ -258,7 +265,9 @@ public class TextRegionUtil { * @param renderModes TODO * @param font {@link Font} to be used * @param str text to be rendered - * @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored. + * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used + * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. + * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only. * @param sampleCount desired multisampling sample count for msaa-rendering. * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched. * @param tmp1 temp {@link AffineTransform} to be reused @@ -274,6 +283,11 @@ public class TextRegionUtil { } final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null, font, str); final AABBox res = addStringToRegion(false /* preGrowRegion */, region, font, null, str, rgbaColor, tmp1, tmp2); + if( !region.hasColorChannel() ) { + renderer.setColorStatic(rgbaColor); + } else { + renderer.setColorStatic(1, 1, 1, 1); + } region.draw(gl, renderer, sampleCount); region.destroy(gl); return res; @@ -309,7 +323,9 @@ public class TextRegionUtil { * @param renderer * @param font {@link Font} to be used * @param str text to be rendered - * @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored. + * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used + * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. + * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only. * @param sampleCount desired multisampling sample count for msaa-rendering. * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched. * @param tmp1 temp {@link AffineTransform} to be reused @@ -324,6 +340,11 @@ public class TextRegionUtil { throw new GLException("TextRendererImpl01: not initialized!"); } final AABBox res = addStringToRegion(true /* preGrowRegion */, region, font, null, str, rgbaColor, tmp1, tmp2); + if( !region.hasColorChannel() ) { + renderer.setColorStatic(rgbaColor); + } else { + renderer.setColorStatic(1, 1, 1, 1); + } region.draw(gl, renderer, sampleCount); return res; } |