Al Grant

07-05-2006, 07:13 PM

Hi Guys,

I am getting a unhandled exception : access violation.

Have been remarking things out...

Still havent fixed it, but this is where I am at:

My program runs for a little while, draws the graphics on screen, but after a few seconds throws the above error.

int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing

{

int i;

GLfloat radius_1=1.8f;

GLfloat radius_2=2.0f;

GLfloat radius_3=2.2f;

//////////XSENS STUFF //////////////

GetData();

///////////////////////////////////

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glLoadIdentity(); // Reset The Current Modelview Matrix

glTranslatef(0.0f,0.0f,-7.0f);

//**** Disable texturing

glDisable(GL_TEXTURE_2D);

// glPushMatrix(); //1 push

glRotatef(fOrientationData[0],0.0f,0.0f,1.0f);

glTranslatef(0.0f,(fOrientationData[1]/18.0)+0.0f,0.0f);

//**** Blue/Brown of Horizon

glBegin(GL_QUADS);

glColor3f(0.0f, 0.6f, 0.796f);

glVertex3f(-6.0f, 18.0f, 0.0f); // Top Left

glVertex3f( 6.0f, 18.0f, 0.0f); // Top Right

glVertex3f( 6.0, 0.0f, 0.0f); // Bottom Right

glVertex3f(-6.0f, 0.0f, 0.0f); // Bottom Left

glColor3f(0.694f, 0.4f, 0.0f);

glVertex3f(-6.0f, -18.0f, 0.0f); // Top Left

glVertex3f( 6.0f, -18.0f, 0.0f); // Top Right

glVertex3f( 6.0f, 0.0f, 0.0f); // Bottom Right

glVertex3f(-6.0f, 0.0f, 0.0f); // Bottom Left

glEnd();

//**** Horizon Lines

for (lines=-18; lines<19; lines++)

{

glBegin(GL_LINES);

glColor3f(1.0f, 1.0f, 1.0f); // Sets Color White

glVertex3f(-6.0f, 0.0f, 0.0f); //Level

glVertex3f(6.0f, 0.0f, 0.0f);

glVertex3f(-0.75f, lines+1.0f, 0.0f); //10 UP

glVertex3f(0.75f, lines+1.0f, 0.0f);

glVertex3f(-0.25f, lines+0.75f, 0.0f); // ---

glVertex3f(0.25f, lines+0.75f, 0.0f);

glVertex3f(-0.5f, lines+0.5f, 0.0f); //---===---

glVertex3f(0.5f, lines+0.5f, 0.0f);

glVertex3f(-0.25f, lines+0.25f, 0.0f); // ---

glVertex3f(0.25f, lines+0.25f, 0.0f);

glEnd();

}

/*

//***** Font Stuff ******

glPushMatrix(); // 2 push

glColor3f(1.0f,1.0f,1.0f);

glTranslatef(-1.1f,-0.1f,0.0f);

for (i=10;i<90;i=i+10)

{

stringstream ss;

ss << i;

glTranslatef(0.0f,1.0f,0.0f);

glPrint(ss.str().c_str());

}

glPopMatrix();

glTranslatef(0.8f,-0.1f,0.0f);

for (i=10;i<190;i=i+10)

{

stringstream ss;

ss << i;

glTranslatef(0.0f,1.0f,0.0f);

glPrint(ss.str().c_str());

}

glPopMatrix();

*/

/*

// WINGS

glBegin(GL_QUADS);

glColor3f(0.0f,0.0f,0.0f);

glVertex3f(-1.75f,0.075f,0.0f); //LEFT

glVertex3f(-0.75f,0.075f,0.0f);

glVertex3f(-0.75f,-0.075f,0.0f);

glVertex3f(-1.75f,-0.075f,0.0f);

glVertex3f(-0.75f,-0.075f,0.0f);

glVertex3f(-0.75f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.075f,0.0f);

glVertex3f(1.75f,0.075f,0.0f); //RIGHT

glVertex3f(0.75f,0.075f,0.0f);

glVertex3f(0.75f,-0.075f,0.0f);

glVertex3f(1.75f,-0.075f,0.0f);

glVertex3f(0.75f,-0.075f,0.0f);

glVertex3f(0.75f,-0.175f,0.0f);

glVertex3f(0.875f,-0.175f,0.0f);

glVertex3f(0.875f,-0.075f,0.0f);

glVertex3f(-0.075f,0.075f,0.0f); // MIDDLE DOT

glVertex3f(0.075f,0.075f,0.0f);

glVertex3f(0.075f,-0.075f,0.0f);

glVertex3f(-0.075f,-0.075f,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// OUTLINES IN WHITE

glBegin(GL_LINE_LOOP);

glColor3f(1.0f,1.0f,1.0f);

glVertex3f(-1.75f,0.075f,0.0f); //LEFT

glVertex3f(-0.75f,0.075f,0.0f);

glVertex3f(-0.75f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.075f,0.0f);

glVertex3f(-1.75f,-0.075f,0.0f);

glEnd();

glBegin(GL_LINE_LOOP);

glColor3f(1.0f,1.0f,1.0f);

glVertex3f(1.75f,0.075f,0.0f); //LEFT

glVertex3f(0.75f,0.075f,0.0f);

glVertex3f(0.75f,-0.175f,0.0f);

glVertex3f(0.875f,-0.175f,0.0f);

glVertex3f(0.875f,-0.075f,0.0f);

glVertex3f(1.75f,-0.075f,0.0f);

glEnd();

glBegin(GL_LINE_LOOP);

glVertex3f(-0.075f,0.075f,0.0f); // MIDDLE DOT

glVertex3f(0.075f,0.075f,0.0f);

glVertex3f(0.075f,-0.075f,0.0f);

glVertex3f(-0.075f,-0.075f,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// glPopMatrix(); // 1 pop

// MOVING NON FILLED BANK TRIANGLE

// glPushMatrix(); // 2 push

glRotatef(fOrientationData[0],0.0f,0.0f,1.0f);

glBegin(GL_LINE_LOOP);

glVertex3f(-0.15f,1.6f,0.0f);

glVertex3f(-0.15f,1.5f,0.0f);

glVertex3f(0.15f,1.5f,0.0f);

glVertex3f(0.15f,1.6f,0.0f);

glVertex3f(0.0f,1.8,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// glPopMatrix(); // 2 pop

glBegin(GL_TRIANGLES); // NON MOVING BANK TRIANGLE - R=1.8

glVertex3f(0.0f,1.8,0.0f);

glVertex3f(-0.15f,2.0f,0.0f);

glVertex3f(0.15f,2.0f,0.0f);

glEnd();

glRotatef(90,0.0f,0.0f,1.0f);

glBegin(GL_LINES);

glVertex3f(radius_1*cos(pi/18),radius_1*sin(pi/18),0.0f); //10 deg

glVertex3f(radius_2*cos(pi/18),radius_2*sin(pi/18),0.0f);

glVertex3f(radius_1*cos(pi/9),radius_1*sin(pi/9),0.0f); // 20 deg

glVertex3f(radius_2*cos(pi/9),radius_2*sin(pi/9),0.0f);

glVertex3f(radius_1*cos(pi/6),radius_1*sin(pi/6),0.0f); // 30 deg

glVertex3f(radius_3*cos(pi/6),radius_3*sin(pi/6),0.0f);

glVertex3f(radius_1*cos(pi/4),radius_1*sin(pi/4),0.0f); // 45 deg

glVertex3f(radius_2*cos(pi/4),radius_2*sin(pi/4),0.0f);

glVertex3f(radius_1*cos(pi/3),radius_1*sin(pi/3),0.0f); // 60 deg

glVertex3f(radius_3*cos(pi/3),radius_3*sin(pi/3),0.0f);

glEnd();

pi=pi*-1;

glBegin(GL_LINES);

glVertex3f(radius_1*cos(pi/18),radius_1*sin(pi/18),0.0f); //10 deg

glVertex3f(radius_2*cos(pi/18),radius_2*sin(pi/18),0.0f);

glVertex3f(radius_1*cos(pi/9),radius_1*sin(pi/9),0.0f); // 20 deg

glVertex3f(radius_2*cos(pi/9),radius_2*sin(pi/9),0.0f);

glVertex3f(radius_1*cos(pi/6),radius_1*sin(pi/6),0.0f); // 30 deg

glVertex3f(radius_3*cos(pi/6),radius_3*sin(pi/6),0.0f);

glVertex3f(radius_1*cos(pi/4),radius_1*sin(pi/4),0.0f); // 45 deg

glVertex3f(radius_2*cos(pi/4),radius_2*sin(pi/4),0.0f);

glVertex3f(radius_1*cos(pi/3),radius_1*sin(pi/3),0.0f); // 60 deg

glVertex3f(radius_3*cos(pi/3),radius_3*sin(pi/3),0.0f);

glEnd();

//**** Enable texturing

glEnable(GL_TEXTURE_2D);

glEnable(GL_BLEND);

glDisable(GL_DEPTH_TEST);

glBlendFunc(GL_DST_COLOR,GL_ZERO);

glBindTexture(GL_TEXTURE_2D, texture[1]);

glBegin(GL_QUADS); // Start Drawing A Textured Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f(-5.0f, 5.0f, 0.0f); // Bottom Left

glTexCoord2f(1.0f, 1.0f); glVertex3f(5.0f, 5.0f, 0.0f); // Bottom Right

glTexCoord2f(1.0f, 0.0f); glVertex3f(5.0f, -5.0f, 0.0f); // Top Right

glTexCoord2f(0.0f, 0.0f); glVertex3f(-5.0f, -5.0f, 0.0f); // Top Left

glEnd();

glDisable(GL_BLEND);

*/As you can see above I have remarked out a heap of stuff and it seems to be running ok without crashing.

I really think its some sort of stack error. I cant even see where the code is breaking because it says no source code available for the current location.

As soon as I unremark any of the remarked code, the error happens again.

Anyone please help.

Thanks

-Al

PS: Full code at http://www.hstuart.dk/paste/view.aspx?id=feddb667-fc12-4b6a-917d-68698f8ffa30

I am getting a unhandled exception : access violation.

Have been remarking things out...

Still havent fixed it, but this is where I am at:

My program runs for a little while, draws the graphics on screen, but after a few seconds throws the above error.

int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing

{

int i;

GLfloat radius_1=1.8f;

GLfloat radius_2=2.0f;

GLfloat radius_3=2.2f;

//////////XSENS STUFF //////////////

GetData();

///////////////////////////////////

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glLoadIdentity(); // Reset The Current Modelview Matrix

glTranslatef(0.0f,0.0f,-7.0f);

//**** Disable texturing

glDisable(GL_TEXTURE_2D);

// glPushMatrix(); //1 push

glRotatef(fOrientationData[0],0.0f,0.0f,1.0f);

glTranslatef(0.0f,(fOrientationData[1]/18.0)+0.0f,0.0f);

//**** Blue/Brown of Horizon

glBegin(GL_QUADS);

glColor3f(0.0f, 0.6f, 0.796f);

glVertex3f(-6.0f, 18.0f, 0.0f); // Top Left

glVertex3f( 6.0f, 18.0f, 0.0f); // Top Right

glVertex3f( 6.0, 0.0f, 0.0f); // Bottom Right

glVertex3f(-6.0f, 0.0f, 0.0f); // Bottom Left

glColor3f(0.694f, 0.4f, 0.0f);

glVertex3f(-6.0f, -18.0f, 0.0f); // Top Left

glVertex3f( 6.0f, -18.0f, 0.0f); // Top Right

glVertex3f( 6.0f, 0.0f, 0.0f); // Bottom Right

glVertex3f(-6.0f, 0.0f, 0.0f); // Bottom Left

glEnd();

//**** Horizon Lines

for (lines=-18; lines<19; lines++)

{

glBegin(GL_LINES);

glColor3f(1.0f, 1.0f, 1.0f); // Sets Color White

glVertex3f(-6.0f, 0.0f, 0.0f); //Level

glVertex3f(6.0f, 0.0f, 0.0f);

glVertex3f(-0.75f, lines+1.0f, 0.0f); //10 UP

glVertex3f(0.75f, lines+1.0f, 0.0f);

glVertex3f(-0.25f, lines+0.75f, 0.0f); // ---

glVertex3f(0.25f, lines+0.75f, 0.0f);

glVertex3f(-0.5f, lines+0.5f, 0.0f); //---===---

glVertex3f(0.5f, lines+0.5f, 0.0f);

glVertex3f(-0.25f, lines+0.25f, 0.0f); // ---

glVertex3f(0.25f, lines+0.25f, 0.0f);

glEnd();

}

/*

//***** Font Stuff ******

glPushMatrix(); // 2 push

glColor3f(1.0f,1.0f,1.0f);

glTranslatef(-1.1f,-0.1f,0.0f);

for (i=10;i<90;i=i+10)

{

stringstream ss;

ss << i;

glTranslatef(0.0f,1.0f,0.0f);

glPrint(ss.str().c_str());

}

glPopMatrix();

glTranslatef(0.8f,-0.1f,0.0f);

for (i=10;i<190;i=i+10)

{

stringstream ss;

ss << i;

glTranslatef(0.0f,1.0f,0.0f);

glPrint(ss.str().c_str());

}

glPopMatrix();

*/

/*

// WINGS

glBegin(GL_QUADS);

glColor3f(0.0f,0.0f,0.0f);

glVertex3f(-1.75f,0.075f,0.0f); //LEFT

glVertex3f(-0.75f,0.075f,0.0f);

glVertex3f(-0.75f,-0.075f,0.0f);

glVertex3f(-1.75f,-0.075f,0.0f);

glVertex3f(-0.75f,-0.075f,0.0f);

glVertex3f(-0.75f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.075f,0.0f);

glVertex3f(1.75f,0.075f,0.0f); //RIGHT

glVertex3f(0.75f,0.075f,0.0f);

glVertex3f(0.75f,-0.075f,0.0f);

glVertex3f(1.75f,-0.075f,0.0f);

glVertex3f(0.75f,-0.075f,0.0f);

glVertex3f(0.75f,-0.175f,0.0f);

glVertex3f(0.875f,-0.175f,0.0f);

glVertex3f(0.875f,-0.075f,0.0f);

glVertex3f(-0.075f,0.075f,0.0f); // MIDDLE DOT

glVertex3f(0.075f,0.075f,0.0f);

glVertex3f(0.075f,-0.075f,0.0f);

glVertex3f(-0.075f,-0.075f,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// OUTLINES IN WHITE

glBegin(GL_LINE_LOOP);

glColor3f(1.0f,1.0f,1.0f);

glVertex3f(-1.75f,0.075f,0.0f); //LEFT

glVertex3f(-0.75f,0.075f,0.0f);

glVertex3f(-0.75f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.175f,0.0f);

glVertex3f(-0.875f,-0.075f,0.0f);

glVertex3f(-1.75f,-0.075f,0.0f);

glEnd();

glBegin(GL_LINE_LOOP);

glColor3f(1.0f,1.0f,1.0f);

glVertex3f(1.75f,0.075f,0.0f); //LEFT

glVertex3f(0.75f,0.075f,0.0f);

glVertex3f(0.75f,-0.175f,0.0f);

glVertex3f(0.875f,-0.175f,0.0f);

glVertex3f(0.875f,-0.075f,0.0f);

glVertex3f(1.75f,-0.075f,0.0f);

glEnd();

glBegin(GL_LINE_LOOP);

glVertex3f(-0.075f,0.075f,0.0f); // MIDDLE DOT

glVertex3f(0.075f,0.075f,0.0f);

glVertex3f(0.075f,-0.075f,0.0f);

glVertex3f(-0.075f,-0.075f,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// glPopMatrix(); // 1 pop

// MOVING NON FILLED BANK TRIANGLE

// glPushMatrix(); // 2 push

glRotatef(fOrientationData[0],0.0f,0.0f,1.0f);

glBegin(GL_LINE_LOOP);

glVertex3f(-0.15f,1.6f,0.0f);

glVertex3f(-0.15f,1.5f,0.0f);

glVertex3f(0.15f,1.5f,0.0f);

glVertex3f(0.15f,1.6f,0.0f);

glVertex3f(0.0f,1.8,0.0f);

glColor3f(1.0f, 1.0f, 1.0f);

glEnd();

// glPopMatrix(); // 2 pop

glBegin(GL_TRIANGLES); // NON MOVING BANK TRIANGLE - R=1.8

glVertex3f(0.0f,1.8,0.0f);

glVertex3f(-0.15f,2.0f,0.0f);

glVertex3f(0.15f,2.0f,0.0f);

glEnd();

glRotatef(90,0.0f,0.0f,1.0f);

glBegin(GL_LINES);

glVertex3f(radius_1*cos(pi/18),radius_1*sin(pi/18),0.0f); //10 deg

glVertex3f(radius_2*cos(pi/18),radius_2*sin(pi/18),0.0f);

glVertex3f(radius_1*cos(pi/9),radius_1*sin(pi/9),0.0f); // 20 deg

glVertex3f(radius_2*cos(pi/9),radius_2*sin(pi/9),0.0f);

glVertex3f(radius_1*cos(pi/6),radius_1*sin(pi/6),0.0f); // 30 deg

glVertex3f(radius_3*cos(pi/6),radius_3*sin(pi/6),0.0f);

glVertex3f(radius_1*cos(pi/4),radius_1*sin(pi/4),0.0f); // 45 deg

glVertex3f(radius_2*cos(pi/4),radius_2*sin(pi/4),0.0f);

glVertex3f(radius_1*cos(pi/3),radius_1*sin(pi/3),0.0f); // 60 deg

glVertex3f(radius_3*cos(pi/3),radius_3*sin(pi/3),0.0f);

glEnd();

pi=pi*-1;

glBegin(GL_LINES);

glVertex3f(radius_1*cos(pi/18),radius_1*sin(pi/18),0.0f); //10 deg

glVertex3f(radius_2*cos(pi/18),radius_2*sin(pi/18),0.0f);

glVertex3f(radius_1*cos(pi/9),radius_1*sin(pi/9),0.0f); // 20 deg

glVertex3f(radius_2*cos(pi/9),radius_2*sin(pi/9),0.0f);

glVertex3f(radius_1*cos(pi/6),radius_1*sin(pi/6),0.0f); // 30 deg

glVertex3f(radius_3*cos(pi/6),radius_3*sin(pi/6),0.0f);

glVertex3f(radius_1*cos(pi/4),radius_1*sin(pi/4),0.0f); // 45 deg

glVertex3f(radius_2*cos(pi/4),radius_2*sin(pi/4),0.0f);

glVertex3f(radius_1*cos(pi/3),radius_1*sin(pi/3),0.0f); // 60 deg

glVertex3f(radius_3*cos(pi/3),radius_3*sin(pi/3),0.0f);

glEnd();

//**** Enable texturing

glEnable(GL_TEXTURE_2D);

glEnable(GL_BLEND);

glDisable(GL_DEPTH_TEST);

glBlendFunc(GL_DST_COLOR,GL_ZERO);

glBindTexture(GL_TEXTURE_2D, texture[1]);

glBegin(GL_QUADS); // Start Drawing A Textured Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f(-5.0f, 5.0f, 0.0f); // Bottom Left

glTexCoord2f(1.0f, 1.0f); glVertex3f(5.0f, 5.0f, 0.0f); // Bottom Right

glTexCoord2f(1.0f, 0.0f); glVertex3f(5.0f, -5.0f, 0.0f); // Top Right

glTexCoord2f(0.0f, 0.0f); glVertex3f(-5.0f, -5.0f, 0.0f); // Top Left

glEnd();

glDisable(GL_BLEND);

*/As you can see above I have remarked out a heap of stuff and it seems to be running ok without crashing.

I really think its some sort of stack error. I cant even see where the code is breaking because it says no source code available for the current location.

As soon as I unremark any of the remarked code, the error happens again.

Anyone please help.

Thanks

-Al

PS: Full code at http://www.hstuart.dk/paste/view.aspx?id=feddb667-fc12-4b6a-917d-68698f8ffa30