Bug 649 - Clear FBO layer at creation
Summary: Clear FBO layer at creation
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: opengl (show other bugs)
Version: 2
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on:
Blocks: 1206
  Show dependency treegraph
 
Reported: 2012-12-03 16:02 CET by ac
Modified: 2015-10-04 02:46 CEST (History)
2 users (show)

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


Attachments
Clears the FBO texture (966 bytes, application/octet-stream)
2013-02-05 17:51 CET, ac
Details
Patch that adds a default color field to GLCapabilities (1.98 KB, application/zip)
2013-02-12 22:49 CET, ac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ac 2012-12-03 16:02:12 CET
When using NEWT and the new FBO layered mechanism (https://jogamp.org/bugzilla/show_bug.cgi?id=634) the window shows garbage left in the framebuffer. The garbage appears right at the moment when the NewtCanvasAWT is attached to the parent frame during surface initialization (frame.add(canvas, BorderLayout.CENTER)), and cleared at the end of the fist frame when the fb is swapped. But the garbage shouldn't be displayed in the first place. Some relevant discussion in the forum:

http://forum.jogamp.org/Clearing-NewtCanvasAWT-td4026943.html
Comment 1 ac 2013-01-22 23:41:41 CET
I think I found a potential solution for this issue. In the TextureAttachment.initialize() function in FBObject.java, I replaced

gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, format, getWidth(), getHeight(), 0, dataFormat, dataType, null);

with:

int[] blank = new int[getWidth() * getHeight()];
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, format, getWidth(), getHeight(), 0, dataFormat, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(blank));

to make sure that the FBO texture is filled out with zeros.

This appears to solve the garbage issue when creating the surface using NEWT.
Comment 2 ac 2013-02-05 17:49:10 CET
In case it is useful, I'm attaching a patch with the changes I mentioned earlier.
Comment 3 ac 2013-02-05 17:51:08 CET
Created attachment 409 [details]
Clears the FBO texture
Comment 4 ac 2013-02-12 22:47:30 CET
I added a defaultColor field to GLCapabilities so that a custom color can be passed to JOGL in order to initialize drawing surfaces (i.e.: texture attachements in FBObject). The patches for FBObject.java. GLCapabilites.java and GLCapabilitesImmutable.java are added below.
Comment 5 ac 2013-02-12 22:49:23 CET
Created attachment 410 [details]
Patch that adds a default color field to GLCapabilities
Comment 6 Sven Gothel 2013-03-20 11:04:42 CET
Updated the [manual] tests:
  http://jogamp.org/git/?p=jogl.git;a=commit;h=30b2490eef5069214eb6cc0c1b18ddb62c15123b

Invoking:
  java com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT \
     -time 10000 -noanim -layeredFBO -layout BorderCenter

I don't see no more artifacts, which is due to cleaning up the main-thread CALayer initialization
and waiting for the rendering result _before_ passing the texture to the CALayer.

Please validate .. 

If the artifact (dirty FBO texture) is still visible, please give me instructions how to reproduce.
In such case I would favor better synchronization and maybe an extra display after init
then exploding GLCapabilities and adding a dummy FBO-tex 'clear'
Comment 7 Sven Gothel 2013-03-20 11:05:49 CET
This aggregated build is pretty recent:
  http://jogamp.org/deployment/archive/master/gluegen_652-joal_413-jogl_936-jocl_761/

.. but doesn't contain the mentioned unit test tweak to disable animation.
Comment 8 ac 2013-03-27 14:26:02 CET
Thanks for the recent updates, I will take a look at the latest builds in the next few days and will let you know how it goes.

(In reply to comment #7)
> This aggregated build is pretty recent:
>  
> http://jogamp.org/deployment/archive/master/gluegen_652-joal_413-jogl_936-
> jocl_761/
> 
> .. but doesn't contain the mentioned unit test tweak to disable animation.
Comment 9 Sven Gothel 2013-04-05 02:01:16 CEST
(In reply to comment #8)
> Thanks for the recent updates, I will take a look at the latest builds in
> the next few days and will let you know how it goes.
> 
> (In reply to comment #7)
> > This aggregated build is pretty recent:
> >  
> > http://jogamp.org/deployment/archive/master/gluegen_652-joal_413-jogl_936-
> > jocl_761/
> > 
> > .. but doesn't contain the mentioned unit test tweak to disable animation.

Version 2.0.2-rc-20130404
  - Maven 2.0.2-rc20130404
  - http://jogamp.org/deployment/archive/master/gluegen_656-joal_420-jogl_951-jocl_773/

- OSX CALayer / Java7 issues should be fixed w/ this version 'once and for all'
  - repaint() component after CALAyer attachment, 
    to avoid garbage and to have rendering result w/o animator
  - run root CALayer ops on main-thread to avoid late GC
  - NewtCanvasAWT/CALayer position fix: Force re-layout via resize
Comment 10 Sven Gothel 2014-09-18 05:32:34 CEST
Note: Clearing framebuffer of newly created GLFBODrawable instances 
using the current clear color is now implemented due to 
workaround Bug 1020.