OpenGL window shows stuff from background windows instead of blank window
<p>I am using Linux and trying to learn OpenGL. I am refering to the website learnopengl.com and have compiled the first program <a href="http://learnopengl.com/code_viewer.php?code=getting-started/hellowindow" rel="nofollow noreferrer">available here</a>.</p>

<p>I seem to compile the program without problem with he command</p>

<pre><code>g++ -Wall -lGLEW -lglfw -lGL -lX11 -lpthread -lXrandr -lXi ./foo.cpp
</code></pre>

<p>But when I run the program it shows stuff from behind, instead of blank window, like this</p>

<p><a href="https://i.stack.imgur.com/6k2D2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6k2D2.png" alt="enter image description here"></a></p>

<p>Note however, that this window is not transparent, as in if I move the window, the background is same. But if I minimize and reopen the window, the background is newly created. This happens for both dedicated and integrated GPU.</p>

<p>What do I need to do to make it work properly?</p>

<p>Here is some info</p>

<pre><code>System:    Host: aditya-pc Kernel: 4.4.13-1-MANJARO x86_64 (64 bit gcc: 6.1.1)
           Desktop: KDE Plasma 5.6.4 (Qt 5.6.0) Distro: Manjaro Linux
Machine:   System: HP (portable) product: HP Notebook v: Type1ProductConfigId
           Mobo: HP model: 8136 v: 31.36
           Bios: Insyde v: F.1F date: 01/18/2016
CPU:       Dual core Intel Core i5-6200U (-HT-MCP-) cache: 3072 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 9603
           clock speeds: max: 2800 MHz 1: 583 MHz 2: 510 MHz 3: 670 MHz 4: 683 MHz
Graphics:  Card-1: Intel Skylake Integrated Graphics bus-ID: 00:02.0
           Card-2: Advanced Micro Devices [AMD/ATI] Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330]
           bus-ID: 01:00.0
           Display Server: X.Org 1.17.4 drivers: ati,radeon,intel
           Resolution: 1920x1080@60.06hz
           GLX Renderer: Mesa DRI Intel HD Graphics 520 (Skylake GT2)
           GLX Version: 3.0 Mesa 11.2.2 Direct Rendering: Yes
</code></pre>

<p>The two graphics card's info</p>

<p>Amd card</p>

<pre><code>$ DRI_PRIME=1 glxinfo|grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD HAINAN (DRM 2.43.0, LLVM 3.8.0)
OpenGL core profile version string: 4.1 (Core Profile) Mesa 11.2.2
OpenGL core profile shading language version string: 4.10
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.2.2
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.2.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
</code></pre>

<p>Intel integrated</p>

<pre><code>$ DRI_PRIME=0 glxinfo|grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.2
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.2.2
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 11.2.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
</code></pre>