title: Loading a tga/bmp file in C++/OpenGL
body: <p>I'm trying to load a tga/bmp file. This works fine, but the end result looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/2XcTz.png" alt="enter image description here"></p>
  
  <p>The image I'm trying to load looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/XMnH6.png" alt="enter image description here"></p>
  
  <p>Some of the code I'm using:</p>
  
  <pre><code>GLuint texture;
  const char* filename = "/Users/Admin/Documents/Visual Studio 2013/Projects/OpenGL/OpenGL/image.tga";
  
  unsigned char* data;
  data = (unsigned char *) malloc(128 * 128 * 3);
  FILE* f;
  fopen_s(&amp;f, filename, "rb");
  fread(data, 128 * 128 * 3, 1, f);
  
  glGenTextures(1, &amp;texture);
  glBindTexture(GL_TEXTURE_2D, texture);
  
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
  </code></pre>
  
  <p>Does anybody have an idea what I'm doing wrong?</p>