Jump to content
  • Advertisement
Sign in to follow this  
Ali_nz

Unhandled Exception : Access Violation...

This topic is 4491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys, I am getting a unhandled exception : access violation. Had a bit of a read on this site about it and read the article on debugging. Even had Superpig, try to help me on irc figure out what was going wrong. 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

Share this post


Link to post
Share on other sites
Advertisement
You appear to have an extra PopMatrix() in your font drawing code.

Edit: Ive gone through and found all your push() and pop() calls, and as you can see, they done line up ( you have one extra pop() ):

glPushMatrix();
glPushMatrix();
glPopMatrix(); <-- in FontStuff
glPopMatrix(); <-- in FontStuff
glPopMatrix(); <-- After "OUTLINES IN WHITE" comment
glPushMatrix();
glPopMatrix();

Share this post


Link to post
Share on other sites
True - however all that stuff is remarked out - and the error still happens. I accept that the error you pointed out is still not good tho!

Share this post


Link to post
Share on other sites
Could you give us the exact error message? Your code, minus the MotionTracker code, works fine, so I'm tempted to say that you need to look at how you are using MotionTracker.

Share this post


Link to post
Share on other sites
Yeah - you could be right about the motion tracker....

Will dig a bit deeper......

Cheers

-Al

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!