So I've got a major issue in my program. I'm working on building something in OpenGL (using glut), the problem is that I changed my TexureLoader from being just a function, that takes the storagevariable as reference and the name, to a class, which just takes the name (and got the storagevariable as private var).
The thing that tricks me, is that if I call my LoadBMP(char *Address) inside my constructor it wont return the texture, but if I'm calling my LoadBMP inside a function (for an example; the one returning the texture), then it works perfectly...
Any one got a clue why?
Code:
GLTexture::GLTexture(char *Filename)
{
TextureName = strlwr(strdup(Filename));
if(strstr(TextureName, ".bmp"))
LoadBMP(TextureName);
}
^^Wont load texture, when calling:
GLuint GLTexture::GetTexture()
{
return TextureStorage;
}
However:
GLuint GLTexture::GetTexture()
{
if(TextureNotLoadedYet){LoadBmp(TextureName);TextureNotLoadedYet=false;}
return TextureStorage;
}
Will load the texture on first run, and then return it perfectly, why?
Shouldn't those 2 examples yield same result?