title: Loading an image with FreeImage
body: <p>I'm trying to follow an OpenGL tutorial but the tutorial uses SOIL (which doesn't work for me) and I use FreeImage.</p>
  
  <p>Could you tell me why my code doesnt work?</p>
  
  <p>Tutorial code:</p>
  
  <pre><code>// Load texture
  GLuint tex;
  glGenTextures(1, &amp;tex);
  
  int width, height;
  unsigned char* image = SOIL_load_image("sample.png", &amp;width, &amp;height, 0, SOIL_LOAD_RGB);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
  SOIL_free_image_data(image);
  
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>// Load textures
  GLuint tex;
  glGenTextures(1, &amp;tex);
  
  int width, height;
  
  FREE_IMAGE_FORMAT formato = FreeImage_GetFileType("sample.png",0);
  FIBITMAP* imagen = FreeImage_Load(formato, "sample.png");
  FIBITMAP* temp = imagen;  
  imagen = FreeImage_ConvertTo32Bits(imagen);
  FreeImage_Unload(temp);
  
  width = FreeImage_GetWidth(imagen);
  height = FreeImage_GetHeight(imagen);
  
  GLubyte* textura = new GLubyte[4*width*height];
  char* pixeles = (char*)FreeImage_GetBits(imagen);
  
  for(int j= 0; j&lt;width*height; j++)
  {
      textura[j*4+0]= pixeles[j*4+2];
      textura[j*4+1]= pixeles[j*4+1];
      textura[j*4+2]= pixeles[j*4+0];
      textura[j*4+3]= pixeles[j*4+3];
  }
  
  glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, width, height, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textura );
  
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  </code></pre>
  
  <p>My "solution" simply results in a black window (no errors).</p>