title: GLSL shader flickering
body: <p>I'm not so sure from what this problem is arising, I never had much experience with shaders so it might be unrelated to the actual shader (most probably the problem isn't in the shader)</p>
  
  <p>I have this result</p>
  
  <p><img src="https://i.stack.imgur.com/DYGMM.png" alt="enter image description here"></p>
  
  <p>Fragment shader</p>
  
  <pre><code>#version 120
  void main(void) {
    gl_FragColor[0] = 0.0;
    gl_FragColor[1] = 0.0;
    gl_FragColor[2] = 0.0;
  }
  </code></pre>
  
  <p>Vertex shader</p>
  
  <pre><code>#version 120
  attribute vec2 coord2d;
  
  void main(void) {
    gl_Position = vec4(coord2d, 0.0, 1.0);
  }
  </code></pre>
  
  <p>My render function</p>
  
  <pre><code>(define (renderFunc)
    (gl:Clear gl:COLOR_BUFFER_BIT)
  
    (gl:UseProgram program)
  
    (gl:EnableVertexAttribArray attribute_coord2d)
  
    (gl:Begin gl:TRIANGLES)
      (gl:Vertex3f 0.0 0.8 0)
      (gl:Vertex3f -0.8 -0.8 0)
      (gl:Vertex3f 0.8 -0.8 0)
    (gl:End)
  
    (gl:DisableVertexAttribArray attribute_coord2d)
  
    (glut:SwapBuffers))
  </code></pre>
  
  <p>And my Init function</p>
  
  <pre><code>(define (initFunc)
    (gl:ClearColor 1 1 1 1)
  
    (gl:Enable gl:TEXTURE_2D)
    (gl:Enable gl:LIGHTING)
  
    (gl:Enable gl:BLEND)
    (gl:BlendFunc gl:SRC_ALPHA gl:ONE_MINUS_SRC_ALPHA)
  
    (set! program (CreatePorgram (list
        (CreateShader gl:VERTEX_SHADER (LoadScript "vs.glsl"))
        (CreateShader gl:FRAGMENT_SHADER (LoadScript "vf.glsl")))))
  
    (set! attribute_coord2d (gl:GetAttribLocation program "coord2d"))
  
    (print "attribute_coord2d: " attribute_coord2d)
    (print "vbo_triangle: " vbo_triangle)
    (print "program: " program)
  
    (print (gl:GetError)))
  </code></pre>
  
  <p>Not sure exactly why but the shader gets loaded correctly and so on. <code>glGetError</code> doesn't return any error and everything seems to work fine.</p>
  
  <p>I based my code on this tutorial which compile and work fine on my machine:</p>
  
  <p><a href="http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction" rel="nofollow noreferrer">http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction</a></p>
  
  <p>I have the feeling that this error my be related to my scheme bindings. When a shader is binded into memory, can we free the source sent to opengl. I'm pretty sure that the source code for the shader gets freed once the shader is generated. </p>
  
  <p>I'm pretty lost at finding what is different in my code, I heard about glUniform but I believe that in my case it shouldn't really matter much.</p>
  
  <p>I used <code>glBegin</code> and <code>glEnd</code> because I had some problems creating VBOs. If vbos are a requirement, then I'll make sure it works first.</p>
  
  <p>By the way, we should see a black triangle instead of a triangle of black dots.</p>
  
  <p>Here is what it looks like when superposing a hundread triangles. The pixels that are rendered black aren't completely random. They actually form some sort of pattern while pixels that are still white are always white most of the time. </p>
  
  <p><img src="https://i.stack.imgur.com/XuX6m.png" alt="enter image description here"></p>