Segmentation fault

M

Michael Sgier

Hello
i get the error:
Segmentation fault. The debugger stopped
at the last of the following lines:


// This stores the texture array for each of the textures assigned
to this model
unsigned int m_Textures[MAX_TEXTURES];

// This stores a list of all the names of the textures that have
been loaded.
// This was created so that we could check to see if a texture that
is assigned
// to a mesh has already been loaded. If so, then we don't need to
load it again
// and we can assign the textureID to the same textureID as the
first loaded texture.
// You could get rid of this variable by doing something tricky in
the texture loading
// function, but I didn't want to make it too confusing to load the
textures.
std::vector<std::string> strTextures;


I don't understand the above. Could this mess up with my imagefunction:
img = SDL_LoadBMP(filename);??
also the following: gluBuild2DMipmaps in the same function returns a
memory access fault if i don't
comment that.
THANKS and regards
Michael
 
J

John Harrison

Michael said:
Hello
i get the error:
Segmentation fault. The debugger stopped
at the last of the following lines:


// This stores the texture array for each of the textures assigned
to this model
unsigned int m_Textures[MAX_TEXTURES];

// This stores a list of all the names of the textures that have
been loaded.
// This was created so that we could check to see if a texture that
is assigned
// to a mesh has already been loaded. If so, then we don't need to
load it again
// and we can assign the textureID to the same textureID as the
first loaded texture.
// You could get rid of this variable by doing something tricky in
the texture loading
// function, but I didn't want to make it too confusing to load the
textures.
std::vector<std::string> strTextures;


I don't understand the above. Could this mess up with my imagefunction:
img = SDL_LoadBMP(filename);??
also the following: gluBuild2DMipmaps in the same function returns a
memory access fault if i don't
comment that.
THANKS and regards
Michael

It sounds like you've corrupted the heap. The two lines you quoted are
perfectly fine, they are not the problem. The problem could be in any of
the code before those two lines.

I could be you imagefunction that is messing up, I wouldn't mind betting
on it, but who can say for certain.

The point is though that you've got to find where the real problem is.
It isn't in those two lines and if you remove them the same segmentation
fault will just appear somewhere else. Somewhere in your code you are
trashing your computer memory and you've got to track that down and fix
that. This is difficult enough for an experienced programmer to do let
alone a newbie, so I suggest that you show your code to someone who is
expereinced at C++. Otherwise you could be trying to fix this for a long
time.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top