title: GLSL passing texture coordinates from vertex shader
body: <p>What I'm trying to accomplish: Drawing the depth map of my scene on top of my scene (so that objects closer are darker, and further away are lighter)</p>
  
  <p>Problem: I don't seem to understand how to pass the right texture coordinates from my vertex shader to my fragment shader.</p>
  
  <p>So I created my FBO, and the texture that the depth map gets drawn to... not that I'm entirely sure what I was doing, but whatever, it works. I tested drawing the texture using the fixed functionality pipeline, and it looks just like it's supposed to (the depth map that is).</p>
  
  <p>But trying to use it in my shaders just isn't working...</p>
  
  <p>Here's the part from my render method that binds the texture:</p>
  
  <pre><code>glActiveTexture(GL_TEXTURE7);
  glBindTexture(GL_TEXTURE_2D, depthTextureId);
  glUniform1i(depthMapUniform, 7);
  glUseProgram(shaderProgram);
  look();  //updates my viewing matrix
  box.render();   //renders box VBO
  </code></pre>
  
  <p>So... I think that's sort of right? Maybe? No clue why texture 7, that was just something that was in a tutorial I was checking...</p>
  
  <p>And here's the important stuff from my vertex shader:</p>
  
  <pre><code>out vec4 ShadowCoord;
  
  void main() {
      gl_Position = PMatrix * (VMatrix * MMatrix) * gl_Vertex;  //projection, view and model matrices
      ShadowCoord = gl_MultiTexCoord0;    //something I kept seeing in examples, was hoping it would work.
  }
  </code></pre>
  
  <p>Aaand, fragment shader:</p>
  
  <pre><code>in vec4 ShadowCoord;
  in vec3 Color;  //passed from vertex shader, didn't include the code for it though. Just the vertex color.
  
  out vec4 FragColor;
  
  void main(
      FragColor = vec4(texture2D(ShadowMap,shadowCoord.st).x * vec3(Color), 1.0);
  </code></pre>
  
  <p>Now the problem is that the coordinate that the fragment shader receives for the texture is always (0,0), or the bottom-left corner. I tried changing it to ShadowCoord = gl_MultiTexCoord7, because I figured maybe it had something to do with me putting the texture in slot number 7... but alas, the problem persisted. When the color of (0, 0) changes, so does the color of the entire scene, rather than being a change in color for only the appropriate pixel/fragment.</p>
  
  <p>And that's what I'm hoping to get some insight on... how to pass the correct coordinates (I'd like for the corners of the texture to be the same coordinates as the corners of my screen). And yes, this is a beginners question... but I have been looking in the Orange Book, and the problem with it is that it's great on the GLSL side of things, but the OpenGL side of things is severely lacking in the examples that I could really use...</p>