Bug 1381 - GLReadBufferUtil/AWTReadBufferUtil: 'hasAlpha' usage is not functional
Summary: GLReadBufferUtil/AWTReadBufferUtil: 'hasAlpha' usage is not functional
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2.4.0
Hardware: All all
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2019-05-13 10:50 CEST by Sven Gothel
Modified: 2023-02-25 18:27 CET (History)
2 users (show)

See Also:
Type: DEFECT
SCM Refs:
jogl 154e91978498d8b6db9ce34a1f06b298bcf4c361
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2019-05-13 10:50:19 CEST
GLReadBufferUtil.readPixelsImpl(..) uses 'hasAlpha' to determine 
the 'PixelFormat.Composition hostPixelComp' and then modifies it 
based on the 'GLPixelAttributes pixelAttribs' composition.

Host and GL pixel composition could be different,
however, this implementation could potentially lead to a different host storage
on the second call w/ 'hasAlpha = true'.

Either (1) store the 'requestedAlpha' immutable and use it always,
or (2) determine 'hasAlpha' with construction.

(2) probably is desired anyways and (1) for better documentation (debugging).
Hence both options probably should be implemented and (2) will also lead to proper host PixelFormat. 

This erroneous behavior is now visible using AWTGLReadBufferUtil,
which can be mitigated using 'hasAlpha = true' in the construction.
Comment 1 Sven Gothel 2019-05-13 11:03:03 CEST
(In reply to Sven Gothel from comment #0)
> Either (1) store the 'requestedAlpha' immutable and use it always,
> or (2) determine 'hasAlpha' with construction.
> 
> (2) probably is desired anyways and (1) for better documentation (debugging).
> Hence both options probably should be implemented and (2) will also lead to
> proper host PixelFormat. 
> 
> This erroneous behavior is now visible using AWTGLReadBufferUtil,
> which can be mitigated using 'hasAlpha = true' in the construction.

(2) 'hasAlpha' cannot be determined w/o a valid GL instance or at least GLProfile at construction,
since none is currently passed in the constructor, 
we need to keep 'hasAlpha' being lazily evaluated by the first readPixel call.

(1) immutable storage of requestedAlpha will resolve this issue

It is up to the AWTGLReadBufferUtil user to use different pixel formats for host and GL, i.e. RGB stored within 32bit INT on the host side being filled by OpenGL with RGBA or BGRA data.
Comment 2 Sven Gothel 2019-05-13 11:21:51 CEST
jogl 154e91978498d8b6db9ce34a1f06b298bcf4c361
Keep host PixelFormat functional using requested immutable alphaRequested + add appropriate API doc