I try to load an image using FreeImage and then create an OpenGL texture. It loads an image and generates a texture, but there is a problem with the colors.
Here's the original image:

and here is the result:

Texture download code:
void TextureManager::LoadTexture(std::string id, std::string filePath){
Texture tex;
tex.TextureId = 0;
FIBITMAP* image = FreeImage_Load(FreeImage_GetFileType(filePath.c_str(), 0), filePath.c_str());
if (FreeImage_GetBPP(image) != 32) {
image = FreeImage_ConvertTo32Bits(image);
}
FreeImage_FlipVertical(image);
tex.Width = FreeImage_GetWidth(image);
tex.Height = FreeImage_GetHeight(image);
glGenTextures(1, &tex.TextureId);
glBindTexture(GL_TEXTURE_2D, tex.TextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,tex.Width, tex.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*)FreeImage_GetBits(image));
AddTextureToMap(id, tex);
FreeImage_Unload(image);
}
Here is the code that draws it:
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, TextureManager.TextureMap[textureSelector].TextureId);
glBegin(GL_TRIANGLES);
glTexCoord2d(0, 0);
glVertex3f(-0.75, 0.75, 0);
glTexCoord2d(1, 0);
glVertex3f(0.75, 0.75, 0);
glTexCoord2d(0, 1);
glVertex3f(-0.75, -0.75, 0);
glTexCoord2d(1, 0);
glVertex3f(0.75, 0.75, 0);
glTexCoord2d(1, 1);
glVertex3f(0.75, -0.75, 0);
glTexCoord2d(0, 1);
glVertex3f(-0.75, -0.75, 0);
glEnd();
glFinish();
I'm sure this is a problem with the internal format in glTexImage2D, but I'm not sure which format I will use if this happens. My question is: is this a format, if so, what should I use; or is there another problem that causes this?