I have a problem with SOIL in C++. The problem is when i try to load am image from a path given, it only show white.
First i load it into the memory as follows:
_t = SOIL_load_OGL_texture(_texture.c_str(),
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y);
Afterwards i use it like this:
glBindTexture(GL_TEXTURE_2D, _t);
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f (0, 0); glVertex3f(-1 + (_p.X)/(App::WinSize().X / 2), 1 - (_p.Y)/(App::WinSize().Y / 2), 0.0f);
glTexCoord2f (1, 0); glVertex3f(-1 + (_p.X + _s.X)/(App::WinSize().X / 2), 1 - (_p.Y)/(App::WinSize().Y / 2), 0.0f);
glTexCoord2f (1, 1); glVertex3f(-1 + (_p.X + _s.X)/(App::WinSize().X / 2), 1 - (_p.Y + _s.Y)/(App::WinSize().Y / 2), 0.0f);
glTexCoord2f (0, 1); glVertex3f(-1 + (_p.X)/(App::WinSize().X / 2), 1 - (_p.Y + _s.Y)/(App::WinSize().Y / 2), 0.0f);
glEnd();
glPopMatrix();
I use Visual Studio 2012. I placed the folder with the images in the folder where the .exe file ends when it is being debugged.
I'm not sure if it is relevant, but here is the OpenGL setup the program runs when it is being executed:
glutInit(&argc, &argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE | GLUT_BORDERLESS);
glEnable(GLUT_MULTISAMPLE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 1.0);
glLoadIdentity();
glOrtho(0.0, size.X, 0.0, size.Y, -1.0, 1.0);
glutInitWindowPosition(position.X, position.Y);
glutInitWindowSize(size.X, size.Y);
Are you checking for error during the loading process?
Add
right after you load the texture using
SOIL_load_OGL_texture
to check if your texture has been loaded without any errors.