title: How to DEBUG OpenGL a gray/black texture box?
body: <p>I'm altering someone else's code. They used PNG's which are loaded via BufferedImage. I need to load a TGA instead, which is just simply a 18 byte header and BGR codes. I have the textures loaded and running, but I get a gray box instead of the texture. I don't even know how to DEBUG this.</p>
  
  <p>Textures are loaded in a ByteBuffer:</p>
  
  <pre><code>final static int datasize = (WIDTH*HEIGHT*3) *2; // Double buffer size for OpenGL // not +18 no header
  static ByteBuffer buffer = ByteBuffer.allocateDirect(datasize);
  
  FileInputStream fin = new FileInputStream("/Volumes/RAMDisk/shot00021.tga");
  FileChannel inc = fin.getChannel();
  
  inc.position(18); // skip header
  
  buffer.clear(); // prepare for read
  int ret = inc.read(buffer);
  fin.close();
  </code></pre>
  
  <p>I've followed this: [how-to-manage-memory-with-texture-in-opengl][1] ... because I am updating the texture once per frame, like video.</p>
  
  <p>Called once:</p>
  
  <pre><code>GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
  GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
  GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
  GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
  GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
  
  GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
  assert(GL11.GL_NO_ERROR == GL11.glGetError());
  </code></pre>
  
  <p>Called repeatedly:</p>
  
  <pre><code>GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
  GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, byteBuffer);
  assert(GL11.GL_NO_ERROR == GL11.glGetError());
  
  return textureID;
  </code></pre>
  
  <p>The render code hasn't changed and is based on:</p>
  
  <pre><code>GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount);
  </code></pre>