I'm trying to use SOIL (Simple OpenGL Image Library) to load images in my project. However, it is crashing whenever I call SOIL_load_image, from an unhandled exception writing location 0x00000014. (I'm following this tutorial, btw: http://open.gl/textures).
I'm unsure of what I can do to fix this issue, but I think its something related to how I'm setting up the library. Yesterday, I was trying to do something similar with libPNG and was running into a similar crash when the library attempted to do some file IO. At the time, I thought it was probably an issue with the library, but now that I'm getting another crash with a different library, I think it might be me.
For the SOIL library, I built the project and copied the debug SOIL.lib to my VC/lib directory, and SOIL.h to the VC/include directory. It seems to be building fine, but is crashing. I tried it with the release .lib as well and the same thing happens.
Where I'm trying to load the image (GLTextureFactory.cpp):
#include "GLTextureFactory.h"
#pragma comment(lib, "SOIL")
#include <SOIL.h>
#include "GLTexture.h"
GLTextureFactory::GLTextureFactory(void)
{
}
GLTextureFactory::~GLTextureFactory(void)
{
}
GLTexture *GLTextureFactory::createTextureForImage(const char *imageFilename)
{
int width, height;
//CRASHING ON THIS LINE
unsigned char* image = SOIL_load_image(imageFilename, &width, &height, 0, SOIL_LOAD_RGB);
//glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image );
return new GLTexture(0);
}
#pragma comment(lib, "GLFW")
#pragma comment(lib, "opengl32")
#pragma comment(lib, "glu32")
#pragma comment(lib, "glew32")