title: Is GL_R8 and GL_R8UI different in OpenGL?
body: <p>I created a module, <a href="https://github.com/cprogrammer1994/ModernGL" rel="nofollow noreferrer">ModernGL</a> to simplify the use of OpenGL in python3.</p>
  
  <p>This is how I choose the proper format for a renderbuffer with 1, 2, 3 or 4 components:</p>
  
  <pre><code>const int int_formats[] = {0, GL_R8, GL_RG8, GL_RGB8, GL_RGBA8};
  const int float_formats[] = {0, GL_R32F, GL_RG32F, GL_RGB32F, GL_RGBA32F};
  
  int format = floats ? float_formats[components] : int_formats[components];
  
  ...
  
  gl.RenderbufferStorage(GL_RENDERBUFFER, format, width, height);
  </code></pre>
  
  <p>For example a renderbuffer with <code>components=1</code> and <code>floats=False</code> will choose the <code>format=GL_R8</code></p>
  
  <p>Previusly (before this <a href="https://github.com/cprogrammer1994/ModernGL/commit/90063b1c1e553de48748788b1a68c26d6b2a5fa4" rel="nofollow noreferrer">commit</a>) I had:</p>
  
  <pre><code>const int int_formats[] = {0, GL_R8UI, GL_RG8UI, GL_RGB8UI, GL_RGBA8UI};
  </code></pre>
  
  <blockquote>
    <p>According to <a href="https://www.khronos.org/opengl/wiki/Image_Format" rel="nofollow noreferrer">this documentation</a>:
     If you want a 3-component unsigned integral format, with 8 bits per component, you use GL_RGB8UI. A 1-component floating-point format that uses 16-bits per component is GL_R16F.</p>
  </blockquote>
  
  <p><strong>However</strong></p>
  
  <p>When I choose <code>GL_R8UI</code> the glReadPixels() will fail with <code>GL_INVALID_OPERATION</code>
  When I choose <code>GL_R8</code> the glReadPixels() will read the pixels as <code>unsigned chars</code></p>
  
  <p>I have a <a href="https://github.com/cprogrammer1994/ModernGL/blob/master/tests/test_framebuffer.py" rel="nofollow noreferrer">test</a> that fails with the non supported format.</p>
  
  <ul>
  <li>What is the difference between <code>GL_R8</code> and <code>GL_R8UI</code></li>
  <li>Why am I able to create a Renderbuffer with <code>GL_R8UI</code>, but reading fails.</li>
  </ul>
  
  <p><strong>Note:</strong> I tested with <code>GL_R8UI</code>, <code>GL_RGB8UI</code> and <code>GL_RGBA8UI</code> none of them were working when <code>glReadPixels</code> was called.</p>