Bug 1228 - Allow setting other glBlendFunc in GLRegion renderer
Summary: Allow setting other glBlendFunc in GLRegion renderer
Status: UNCONFIRMED
Alias: None
Product: Jogl
Classification: JogAmp
Component: graph (show other bugs)
Version: 2.4.0
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on:
Blocks: 1064
  Show dependency treegraph
 
Reported: 2015-09-23 13:30 CEST by Alan Sambol
Modified: 2015-10-01 10:00 CEST (History)
4 users (show)

See Also:
Type: FEATURE
SCM Refs:
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Sambol 2015-09-23 13:30:01 CEST
For RegionRenderer, blending can currently be set by renderState.setHintMask(RenderState.BITHINT_BLENDING_ENABLED). This always uses gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) under the hood (hardcoded).

It would be nice to allow setting other blending functions for RenderState / TextRendererUtil, as we use different blending function in our framework - gl.glBlendFunc(GL.ONE, GL.GL_ONE_MINUS_SRC_ALPHA), for premultiplied alpha, which is de facto standard: http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx

Currently, I found it hardcoded in the following classes (it even mentions possibility of other functions in comments):

VBORegionSPES2, line 234:
        if( renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
            gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        }

VBORegion2PVBAAES2, line 607:
VBORegion2PMSAAES2, line 493:

        if( blendingEnabled ) {
            gl.glClearColor(0f, 0f, 0f, 0.0f);
            gl.glClear(GL.GL_COLOR_BUFFER_BIT); // no depth-buffer w/ blending
            // For already pre-multiplied alpha values, use:
            // gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);

            // Multiply RGB w/ Alpha, preserve alpha for renderFBO(..)
            gl.glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
        } else {
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        }