I am trying to load a file using a string as a file name. This is the class that uses the string to load in the file.
Code:
class Texture
{
int m_width; //width of the image
int m_height; //height of the image
unsigned char* m_pixels; //pixel data
public:
Texture(std::string fileName);
~Texture();
int getWidth();
int getHeight();
unsigned char* getPixels();
};
In the fuction for the drawer class, I create a new Texture, and supply a string for the file to load in. (only related code posted). m_currentLevel is a Level class.
getFloorTexName() simply returns the string of the filename used for the floor texture.
Code:
std::string texName = m_currentLevel->getFloorTexName();
Texture* texture = new Texture(texName);
GLuint ID = loadTexture(texture);
Using this code, the program compiles just fine, but I get this error when I run it.
Access violation reading location 0x00000018.
The compiler is pointing to this function in the <xstring> header file.
Code:
size_type size() const
{ // return length of sequence
return (this->_Mysize);
}
Am I not using the string class correctly? What is causing this error?