title: opengl 3d texture issue
body: <p>I'm trying to use a 3d texture in opengl to implement volume rendering. Each voxel has an rgba colour value and is currently rendered as a screen facing quad.(for testing purposes). I just can't seem to get the sampler to give me a colour value in the shader. The quads always end up black. When I change the shader to generate a colour (based on xyz coords) then it works fine. I'm loading the texture with the following code:</p>
  
  <pre><code>glGenTextures(1, &amp;tex3D);
  glBindTexture(GL_TEXTURE_3D, tex3D);
  unsigned int colours[8];
  
  colours[0] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Blue);
  colours[1] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Red);
  colours[2] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Green);
  colours[3] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Magenta);
  colours[4] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Cyan);
  colours[5] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Yellow);
  colours[6] = Colour::AsBytes&lt;unsigned int&gt;(Colour::White);
  colours[7] = Colour::AsBytes&lt;unsigned int&gt;(Colour::Black);
  
  glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, colours);
  </code></pre>
  
  <p>The colours array contains the correct data, i.e. the first four bytes have values 0, 0, 255, 255 for blue. Before rendering I bind the texture to the 2nd texture unit like so:</p>
  
  <pre><code>glActiveTexture(GL_TEXTURE1);
  glBindTexture(GL_TEXTURE_3D, tex3D);
  </code></pre>
  
  <p>And render with the following code:</p>
  
  <pre><code>shaders["DVR"]-&gt;Use();
  shaders["DVR"]-&gt;Uniforms["volTex"].SetValue(1); 
  shaders["DVR"]-&gt;Uniforms["World"].SetValue(Mat4(vl_one));
  shaders["DVR"]-&gt;Uniforms["viewProj"].SetValue(cam-&gt;GetViewTransform() * cam-&gt;GetProjectionMatrix());
  
  QuadDrawer::DrawQuads(8);
  </code></pre>
  
  <p>I have used these classes for setting shader params before and they work fine. The quaddrawer draws eight instanced quads. The vertex shader code looks like this:</p>
  
  <pre><code>#version 330
  
  layout(location = 0) in vec2 position;
  layout(location = 1) in vec2 texCoord;
  
  uniform sampler3D volTex;
  ivec3 size = ivec3(2, 2, 2);
  uniform mat4 World; 
  uniform mat4 viewProj;
  
  smooth out vec4 colour;
  
  void main()
  {
      vec3 texCoord3D;
  
      int num = gl_InstanceID;
  
      texCoord3D.x = num % size.x;
      texCoord3D.y = (num / size.x) % size.y;
      texCoord3D.z = (num / (size.x * size.y));
  
      texCoord3D /= size;
      texCoord3D *= 2.0;
      texCoord3D -= 1.0;
  
      colour = texture(volTex, texCoord3D);
      //colour = vec4(texCoord3D, 1.0);   
  
      gl_Position = viewProj * World * vec4(texCoord3D, 1.0) + (vec4(position.x, position.y, 0.0, 0.0) * 0.05);
  
  }
  </code></pre>
  
  <p>uncommenting the line where I set the colour value equal to the texcoord works fine, and makes the quads coloured. The fragment shader is simply:</p>
  
  <pre><code>#version 330
  
  smooth in vec4 colour;
  out vec4 outColour;
  
  void main()
  {
      outColour = colour;
  }
  </code></pre>
  
  <p>So my question is, what am I doing wrong, why is the sampler not getting any colour values from the 3d texture?</p>
  
  <p>[EDIT] 
  Figured it out but can't self answer (new user):</p>
  
  <p>As soon as I posted this I figured it out, I'll put the answer up to help anyone else (it's not specifically a 3d texture issue, and i've also fallen afoul of it before, D'oh!). I didn't generate mipmaps for the texture, and the default magnification/minification filters weren't set to either GL_LINEAR, or GL_NEAREST. Boom! no textures. Same thing happens with 2d textures.</p>