0

I have a program, using opengl and GLX. At the beginning I choose a framebuffer configuration with the following attributes:

const int attributes[] = {GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, True, None};
fb_configs = glXChooseFBConfig(display, screen_index, attributes, &fb_configs_count);

When I have to re-render the window, I clear the screen, render the content and then swap the buffers:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if_render();
glXSwapBuffers(display, drawable);

After I swap the buffers, instead of the contents of my window, I see what is behind the window. My guess is that the swapped buffer is in some initial state and nothing was actually rendered into it. If I trigger the buffer swapping for a second time, the content in my window is visualized properly.

Am I missing something?


EDIT

This happens with fluxbox 1.3.7 and mesa 11.0.6. I use a direct rendering context.

martinkunev
  • 1,364
  • 18
  • 39
  • 1
    What system is this? I've seen this happen on a newer Ubuntu system, where the first redraw seems to get lost, and the window content only shows up on the second redraw. – Reto Koradi Sep 10 '16 at 02:27
  • 2
    If the window system is flipping through buffers on each refresh instead of copying the application's front-buffer, this is normal behavior. Buffer count is implicitly 3 at minimum in these situations if a compositing window manager is in use due to locking behavior. I really do not know what governs flip/copy behavior in GLX to properly answer this question. – Andon M. Coleman Sep 10 '16 at 05:57
  • @AndonM.Coleman: It's actually not specified and implementors are left to their own devices. There are a number of vendor specific GLX extensions that allow to fine tune that behavior, but none of them considers the effects of compositing. – datenwolf Sep 10 '16 at 08:14
  • Are you using a direct or in-direct rendering context? How do you "stop" between the first and second frame? – Andreas Sep 10 '16 at 09:20
  • @Andreas This happens with static content that I re-render after an event (expose or user input), so I don't need to "stop" between frames. I'm using direct rendering. – martinkunev Sep 10 '16 at 19:03

0 Answers0