Hello,
I have been having some trouble with the glClear command randomly altering some model data I have stored in a class (I know its the glClear command from debugging to pinpoint the problem). This has puzzled me for a bit as the data being altered is private and the command should not interact with the model at all anyway. I’m not sure how anyone can help me much without some code, so here is my displayFunc so far:
[b] {
/**
*This line seems to alter the code, in my debugger I put breakpoints
*before, on and after this line. The debugger indicated that the data was
*normal preceding the line, being defined on the line, and was corrupted
*after it.
*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(xPos, yPos, zPos);
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glPushMatrix();
GLfloat light1Pos[] = {0.0f, 0.0f, 10.0f, 1.0f};
GLfloat light1Diff[] = {1.0f, 1.0f, 1.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, light1Diff);
glLightfv(GL_LIGHT0, GL_POSITION, light1Pos);
tank->draw(0.0f, 0.0f, 0.0f);
glPopMatrix();
glutSwapBuffers();
}
[/b]
and the only thing being altered is the model data, so here is the .h for that class as well.
[b]struct material {
P3Sys materialColor;//gets altered at glClear
char* materialName;//gets altered at glClear
};
struct face {
int numOfVerts;//number of verticies used by the face
P3Sys* Vert;//gets altered at glClear
P3Sys* Normal;//gets altered at glClear
material mat;//gets altered at glClear
};
class model {
public:
//Material and Face fields
int numOfFaces;//gets altered at glClear()
face* faces;//gets altered at glClear()
model();//private constructor: called in factory classes
~model();
void draw(float x, float y, float z);//draws the model at the given x, y, and z coord
static model* objModel(char* objFile, char* mtlFile);//static object model factory
};[/b]
I would appreciate any help or advice on how to get the model data to be left alone