title: Sampling unsigned integer texture data in a shader
body: <p>I want to render a unsigned integer texture with fragment shader using following code:</p>
  
  <pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, data);
  </code></pre>
  
  <p>and part of the fragment shader code:</p>
  
  <pre><code>#version 330
  uniform usampler2D tex;
  void main(void){
      vec3 vec_tex;
      vec_tex = (texture(tex), TexCoordOut).r
  }
  </code></pre>
  
  <p>It is written in <strong><em>OpenGL Programming Guide</em></strong>, that if I want to receive integers in shader, then I should use an integer sampler type, an integer internal format, and an integer external format and type. Here is us <code>GL_R8UI</code> as internal format, <code>GL_RED_INTEGER</code> as external format, <code>GL_UNSIGNED_BYTE</code> as data type. I also use <code>usampler2D</code> in shader. But when the program starts to render the file, always got error <strong><em>implicit cast from "int" to "uint"</em></strong>. It seems that the texture data is stored as int, and the unsigned sampler can not convert that. But I did use <code>GL_R8UI</code> as internal format, so the texture data should be stored as unsigned. why the unsigned sampler only get signed int? How can I solve this problem?</p>