Advertisement Jump to content
Sign in to follow this  

3D Game Engine Design Souce Code Problem

This topic is 4746 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

I was trying to comple some souce code from this book and I got the following runtime error: Unhandled exception at 0x004d5724 in Pandoras Legacy.exe: 0xC0000005: Access violation reading location 0x04974308. The error points to a line of code that says - m_NumPolys = m_NumPolys + 1; Any ideas on what the problem is and how to fix it.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Well that is definately not enough information to solve the problem. Most of the times these things are caused by out of bounds memory is an example:

char array[200];
int index;
char data;

index = 199;
data = array[index]; // no error
index = 200;
data = array[index]; // error (off by one.. must be 0-199)
index = -1;
data = array[index]; // error, must be positive

the snippet you provide is increasing your global (m_ prefix) variable for a poly count by one. Since this is a global variable it could be affecting many possible peices of data calculation. Basically look for anything that uses this variable and double check the code logic. The easiest way would probably bug the author of the book with the error report. They might even have a website, that already contains a bugfix. But one line of code for a program failure is not really going to help us identify your problem.

Share this post

Link to post
Share on other sites
If you call into a deleted or clobbered object, or with a bad object pointer, then an access to a member variable may cause a crash.

For example:

class Foo {
Foo() : mem_( 4 ) {}
int func() {
return 3;
int crash() {
return mem_;
int mem_;

void main() {
Foo * f = NULL;
std::cout << f->func() << std::endl; // works (!)
std::cout << f->crash() << std::endl; // crashes

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!