Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

yckx

Help with a runtime error

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

In my camera class I have 4 vectors: pos, view, up, and right. In my camera''s movement function I can create and use local vectors all I want, but as soon as I try to access any of the 4 vectors owned by the class, my program crashes when I try to rum it. When I debug it I get a warning that reads: Access violation (Segmentation fault) raised in your program. and the debugger points to the line of code referring to the vector. I''m using Dev-C++. I''m fairly new to this, so I''m not real sure what the error is telling me, and even less sure how to solve it. Can somebody help me? Thanks. yckx

Share this post


Link to post
Share on other sites
Advertisement
Sounds like your code is trying to use uninitialised memory as though it were a camera instance. Can you show us the code where you create and use the camera?

Share this post


Link to post
Share on other sites
Ok, I fixed this problem in the camera with a hack, but I''ve now run into it again. Apparently I don''t know what I''m doing Here''s the code:


  
struct Color3
{
float r, g, b;
};

struct MazeSide
{
// other stuff

Color3 color;

MazeSide();
};

MazeSide::MazeSide()
{
color.r = 0;
color.g = 0;
color.b = 0;
}

Maze::Maze()
{
renderCube = true;

for(int i = 0; i < 6; ++i)
{
mazeArray[i] = new MazeSide;
mazeArray[1]->color.r = 0.2; //<- problem!

mazeArray[i]->color.g = 0.2;
mazeArray[i]->color.b = 1.0;
}
}


This code compiles, but I get the same Access Violation error I was getting before. I set the color components = 0 in the mazeSide constructor in an attempt to init the variable, but apparently that isn''t doing it?

How do I fix this properly?

Thanks

yckx

Share this post


Link to post
Share on other sites
There's no need to initialize r, g and b to zero as long as you set them to something before you use them.

A more likely problem is that your loop writes outside the bounds of mazeArray.

EDIT: Or perhaps mazeArray is an uninitialized or previously deleted pointer to some space on the heap?


[edited by - micepick on January 25, 2003 12:46:32 PM]

Share this post


Link to post
Share on other sites

  • 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!