#22142·wxWidgets

Double buffer of wxGLCanvas is always active with EGL

Author: gsxrukCreated Feb 19, 2022Updated Sep 20, 2026
LabelsGTKOpenGL

Describe the bug In v3.1.5, the double buffer of wxGLCanvas always appears to be active even when it hasn't been requested. This behaviour is certainly different to that of v3.1.4.

Both v3.1.4 and v3.1.5 show signs of lag when double buffer is used. This is observed when resizing the window.

Expected vs observed behaviour I admit I'm assuming I'm correct when I state the expected behaviour but I'm not 100% sure. One thing is for certain, the behaviour between v3.1.4 and v3.1.5 is different.

Expected:

  1. When double buffering is not requested, double buffering is not used and there is no need to call SwapBuffers of the wxGLCanvas to display the scene. The glFlush() command is all that is required.
  2. Double buffering does not show signs of lag during resize (at least when displaying a simple scene).

Note: v3.1.4 provides the expected behaviour described in (1) but both v3.1.4 and v3.1.5 show the lag in (2).

Observed:

  1. The call to SwapBuffers is required to display the scene even when double buffering is not requested.
  2. Double buffering shows signs of lag during resize and this is apparent even when double buffering is not requested. This is what led me to believe double buffering is always active.

Patch or snippet allowing to reproduce the problem This problem can be reproduced using the OpenGL "Cube" sample with a few small incremental changes as follows:

Test 1 Changes (adds red background to the scene to show lag):

  1. Add the line glClearColor(1.0f, 0.0f, 0.0f, 1.0f); to the TestGLContext constructor just before the CheckGLError(); statement.

Test 2 Changes (disables DoubleBuffer):

  1. Add int attribList[] = { WX_GL_RGBA, 0 }; under the int stereoAttribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO, 0 }; statement of MyFrame constructor.
  2. Amend the statement new TestGLCanvas(this, stereoWindow ? stereoAttribList : NULL); to read new TestGLCanvas(this, stereoWindow ? stereoAttribList : attribList); of the MyFrame constructor.

Test 3 Changes (removes SwapBuffers):

  1. Comment out SwapBuffers() from the TestGLCanvas::OnPaint function.

To Reproduce Test 1 (shows lag in both v3.1.4 and v3.1.5):

  1. Make the changes described in "Test 1 Changes".
  2. Build the sample using v3.1.5.
  3. Launch the sample and resize the window.
  4. Observe the right and bottom edges of the background lag behind the window resize.
  5. Clean and build the sample using v3.1.4.
  6. Observe the right and bottom edges of the background lag behind the window resize.

Test 2 (shows lag in v3.1.5 only and that double buffer still seems to be active/v3.1.4 is not effected by this issue):

  1. Make the changes described in "Test 1 Changes" and "Test 2 Changes".
  2. Build the sample using v3.1.5.
  3. Launch the sample and resize the window.
  4. Observe the right and bottom edges of the background lag behind the window resize.
  5. Clean and build the sample using v3.1.4.
  6. Launch the sample and resize the window.
  7. Observe the scene is displayed and there is no lag during the resize.

Test 3 (shows SwapBuffers is required when double buffer is disabled in v3.1.5 and not v3.1.4):

  1. Make the changes described in "Test 1 Changes" and "Test 2 Changes" and "Test 3 Changes".
  2. Build the sample using v3.1.4.
  3. Launch the sample and resize the window.
  4. Observe the scene is displayed.
  5. Clean and build the sample using v3.1.5.
  6. Launch the sample.
  7. Observe the scene is not displayed.

Platform and version information

  • wxWidgets version you use: 3.1.5
  • wxWidgets port you use: wxGTK
  • OS and its version: Ubuntu 21.10
  • For wxGTK only, please specify GTK version: 3.24.30

Additional information I ran a git bisect between v3.1.4 and v3.1.5 and the result is shown below.

7cd12a2bd6566b36be5579a370b52ac18f986863 is the first bad commit commit 7cd12a2bd6566b36be5579a370b52ac18f986863 Author: Scott Talbert <[email protected]> Date: Fri Aug 28 11:59:27 2020 -0400