Reply – Understanding issue with automatic buffer swapping
Your Name
Subject
Message
or Cancel
In Reply To
Understanding issue with automatic buffer swapping
— by xghost xghost
Hi,

I've been using JOGL for a while and things have been working as expected. However, I recently observed an issue that I eventually tracked down to automatic buffer swapping, but that based on the javadocs, should not have occurred as far as I understand.

This is part of the setup code:

    final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL4));
    caps.setBackgroundOpaque(true);
    caps.setDoubleBuffered(true);
    caps.setRedBits(8);
    caps.setGreenBits(8);
    caps.setBlueBits(8);
    caps.setAlphaBits(8);
    canvas = new GLCanvas(caps);
    canvas.addGLEventListener(this);
    canvas.setAutoSwapBufferMode(false);    // <-- note this one

According to the docs, when auto buffer swapping is disabled, it's the client's responsibility to manually invoke the swapBuffers() method, which my application did after the scene had been rendered into a viewport from the camera's PoV.

    canvas.swapBuffers();

The expected result was that the scene would be rendered, but the actual result was that the entire screen was black. Not only that, but this problem is only present when the application runs on my desktop, using NVIDIA GTX-770 w/ driver 375.26 on Kubuntu 16.10 x64. The problem has never been observed on my laptop, using NVIDIA GTX-960M w/ driver 367.57.

I tried several drivers on the desktop, including one that was known to work before I started updating drivers to see if the problem would go away; can't remember which version, but it was older than 367 on the laptop.

I've worked around the problem by eliminating manual buffer-swapping from the client (i.e. left the auto-buffer swapping behavior enabled by default and removed the manual call to swapBuffers).

I'd appreciate if someone could shed some light on whether there's really a JOGL issue here somewhere, or whether you think I my understanding of the javadoc was incorrect.

Thanks in advance,
-r

---

PS: If interested, I chose to swap buffers manually because a scene may have several cameras with each one drawing into a different viewport and I wanted to make sure the buffers would be swapped only once, after every camera had finished rendering from its own PoV, rather than it getting swapped automatically for each camera in a single pass. (Please let me know if this is not really a good way to go about this.)