I've been trying to display an image using FreeImage in C++ and have been having a lot of trouble in doing this.The load function seems to load the image, but it doesn't seem to bind the image. Here is what i've got so far:
GLuint Load(){
string imgdir = "Path to my file";
FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(imgdir.c_str());
FIBITMAP *bitmap = FreeImage_Load(fif,imgdir.c_str(),0);
int height, width;
height = FreeImage_GetHeight(bitmap);
width = FreeImage_GetWidth(bitmap);
GLuint textureid;
glGenTextures(1, &textureid);
glBindTexture(GL_TEXTURE_2D, textureid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
FreeImage_Unload(bitmap);
return textureid;}
void Square(){
glBindTexture(GL_TEXTURE_2D, tex);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);glVertex3f(0.0, 0.0, 0.0);
glTexCoord2f(1.0, 0.0);glVertex3f(3.0, 0.0, 0.0);
glTexCoord2f(1.0, 1.0);glVertex3f(3.0, 5.0, 0.0);
glTexCoord2f(0.0, 1.0);glVertex3f(0.0, 5.0, 0.0);
glEnd();}
Using this all I am getting is just a white rectangle. Any point in the right direction would be appreciated.