I'm working on an .obj file loader for an opengl project I'm doing and I don't understand something that is happening. I made the class to load the object file in to certain vectors depending on the vertices, face, vertice normals, so on. But my problem comes from when I try to declare the class. I don't use any functions, all I do is declare it. I made two different projects, one an opengl and one a console so I could test it on both. For some reason it works just fine on the console program, but freezes and stops responding on the opengl project. The code for the class is kind of long so I'll just post what is needed, if anyone needs any more code just say so. And also, the two projects are using the exact same header file. Any help is appreciated!
EDIT: Ok wow... I'm an idiot *SLAMS HEAD ON DESK* I was declaring the class inside the load for the opengl render. It should have been inside the main window or global. It's better now.
/*INSIDE THE OPENGL PROGRAM*/
LOADOBJ obj; //this line is the problem, i comment it out and it works fine
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the screen to the specified color.
// Set up the information for the first light and set it in GL_LIGHT0.
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 130.0f);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 75.0f);
// Enable the first light.
// Set up the material information for our objects.
glMaterialfv(GL_FRONT, GL_SPECULAR, specularLight);
glMateriali(GL_FRONT, GL_SHININESS, 128);
// If all went well we return true.
/*INSIDE THE CONSOLE PROGRAM*/
using namespace std;
LOADOBJ obj; //this works without a problem, but I have no idea why
//if(obj.LoadObjFromFile("box.obj")) //this function also works, it's been tested
//cout<<"Object file loaded"<<endl;
/*FUNCTIONS FOR THE CLASS*/
ObjectList *head; //head ptr in linked list of loaded object files
int obj_load_count; //number of loaded object files
void Destroy(); //destroys first link in the list
ObjectList* GetNextSpace(); //get next available space in the linked list
bool LoadObjFromFile(char*); //load object file
int GetFileCount(); //get number of object files that have been loaded
bool isEmpty(); //determines if the linked list is empty
bool RenderAllObjects(); //render all the objects loaded in the linked list
}; //end LOADOBJ class
obj_load_count = 0; //nothing is loaded so zero
head = NULL; //pointer points to nothing
//almost 100% sure this functions works since I tested the loading function in
//a console window and it can correctly store all the points, faces, etc.
if(head == NULL) return head;
ObjectList *temp = head;
while(temp != NULL)
temp = temp->next;