Posted by
xghost on
Mar 10, 2017; 7:59am
URL: https://forum.jogamp.org/Understanding-issue-with-automatic-buffer-swapping-tp4037728p4037760.html
I was finally able to test a bit on my Windows 7 x64 environment, with the same 2GB GTX-770 card on driver 373.06.
The MultiViewportTest shows severe flickering when JOGL's default auto-swapping is enabled. If I revert my original workaround and go back to manual swapping, then the test looks correct (i.e. the severe flickering is gone).
My guess is that it's related to my previous question regarding how to properly render to multiple viewports on a single frame/pass, and that JOGL's auto-buffer swapping is swapping 4 times per "frame".
I'd still like to hear comments on the proper way to work on the multiple viewports. Currently, the contents of each viewport are rendered on separate calls to canvas.display() -i.e. if there're 4 viewports on a window, then 4 display(GLAutoDrawable) invocations will be made to draw only to the viewport's section (see later).
Xerxes Rånby wrote
When you do manual buffer swapping I recommend looking into how to correctly handle framebuffers.
* make sure that you glClear to clear the buffers before rendering // clear depth/stencil/color contents
In both cases (auto/manual swapping), I've had calls to glClearBufferfv(...) for GL_COLOR and GL_DEPTH from very early in development. See
GL4RenderSystem.java:194-195
Xerxes Rånby wrote
* make sure that you call glInvalidateFramebuffer after rendering before swapbuffers to improve performance and to prevent dirty buffers to presistent before the next frame // avoid storing the depth/stencil contents
I was not familiar with glFramebuffer/glInvalidateFramebuffer, so I'll look into it in more detail soon.
Read the article. While I still need to process some of the framebuffer-related stuff and check more references (OpenGL SB6, though I've been burned by errors there before...), there's something that caught my attention: the article recommends that you should always clear all the buffers -i.e. call glClear(/*color | depth | stencil | ...*/).
As mentioned at first, my window can have multiple viewports, each with its own clear color, etc. If I just call glClear at the beginning of the frame, instead of trying to use a stencil to clear only a section of the window (i.e. the viewport) then, when multiple viewports are used, the entire thing gets messed up.
From what I understood, the article says that trying to clear only a section of the framebuffer with a stencil (i.e. what I've been doing) is a common mistake. So, if someone can offer recommendations regarding how to properly handle multiple viewports in the same window, that'd be helpful.
Thanks in advance,
-r
PS: I hope to get to test in Windows 10 soon, depending on whether it's still relevant.