Also changing "#if define(HELLO)" to "#ifdef HELLO" might help.
- Viewing Profile: Posts: gamepopper
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 8
- Profile Views 461
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
99
Poor
User Tools
Contacts
gamepopper hasn't added any contacts yet.
Latest Visitors
Posts I've Made
In Topic: #define doesn't work
07 May 2012 - 06:13 AM
In Topic: Visual Studio C++ Release Build Issue
07 May 2012 - 06:09 AM
Problem has been resolved! Now all those floats are initialised to NULL and I modified the if statement to prevent it passing on the first go. Thanks to both of you!
In Topic: Visual Studio C++ Release Build Issue
06 May 2012 - 08:20 PM
Without seeing the code there is only so much other people can do to help you. Such as pointing out common causes to this issue.
- not defining default values for variables
- putting functions into debug only macros, such as asserts
- memory trampling
OK well since from comparing the images the issue involves loading material files, so for any more help I'll paste the code for loading in the material library file:
int MultiObjectModel::read_MaterialFile(string fileName) // reads in a textfile containing the relevent material data.
{
ifstream inFile;
inFile.open(fileName.c_str());
if (!inFile.good())
{
cerr << "Can't open material file" << endl;
return 1;
}
float ambiant[4];
float diffuse[4];
float specular[4];
float shininess;
int matCount = 0;
while (!inFile.eof())
{
string line;
getline(inFile, line);
if (line.length() > 2)
{
if (line.substr(0,6)=="newmtl" && specular[2] >= 0)
{
material mat = {{ambiant[0],ambiant[1],ambiant[2],ambiant[3]},{diffuse[0],diffuse[1],diffuse[2],diffuse[3]},{specular[0],specular[1],specular[2],specular[3]},shininess};
Mat.push_back(mat);
}
else if (line.substr(0,3)==" Ka")
{
int w = 0;
stringstream ss(line);
string space[5];
for (int i = 0; i < 5; i++)
{getline(ss,space[i], ' ');} //This getline function extracts each character from the stringstream up until a space is found.
w = sscanf_s(space[1].c_str(), "%f", &ambiant[0]);
w = sscanf_s(space[2].c_str(), "%f", &ambiant[1]);
w = sscanf_s(space[3].c_str(), "%f", &ambiant[2]);
}
else if (line.substr(0,3)==" Kd")
{
int w = 0;
stringstream ss(line);
string space[5];
for (int i = 0; i < 5; i++)
{getline(ss,space[i], ' ');} //This getline function extracts each character from the stringstream up until a space is found.
w = sscanf_s(space[1].c_str(), "%f", &diffuse[0]);
w = sscanf_s(space[2].c_str(), "%f", &diffuse[1]);
w = sscanf_s(space[3].c_str(), "%f", &diffuse[2]);
}
else if (line.substr(0,3)==" Ks")
{
int w = 0;
stringstream ss(line);
string space[5];
for (int i = 0; i < 5; i++)
{getline(ss,space[i], ' ');} //This getline function extracts each character from the stringstream up until a space is found.
w = sscanf_s(space[1].c_str(), "%f", &specular[0]);
w = sscanf_s(space[2].c_str(), "%f", &specular[1]);
w = sscanf_s(space[3].c_str(), "%f", &specular[2]);
}
else if (line.substr(0,3)==" Ns")
{
int w = 0;
stringstream ss(line);
string space[2];
for (int i = 0; i < 2; i++)
{getline(ss,space[i], ' ');} //This getline function extracts each character from the stringstream up until a space is found.
w = sscanf_s(space[1].c_str(), "%f", &shininess);
}
else if (line.substr(0,2)==" d")
{
int w = 0;
stringstream ss(line);
string space[2];
for (int i = 0; i < 2; i++)
{getline(ss,space[i], ' ');} //This getline function extracts each character from the stringstream up until a space is found.
w = sscanf_s(space[1].c_str(), "%f", &ambiant[3]);
w = sscanf_s(space[1].c_str(), "%f", &diffuse[3]);
w = sscanf_s(space[1].c_str(), "%f", &specular[3]);
}
}
}
material mat = {{ambiant[0],ambiant[1],ambiant[2],ambiant[3]},{diffuse[0],diffuse[1],diffuse[2],diffuse[3]},{specular[0],specular[1],specular[2],specular[3]},shininess};
Mat.push_back(mat);
cout << "Material Loaded\n" << endl;
inFile.close();
return 0;
}What I'll also say is that I had this issue with another program I was working on, except it was the wrong texture being applied to the wrong file, however I was able to resolve this by changing the file names of the texture files. That could mean memory trampling is most likely, but changing the file names of the material files had no effect here.
In Topic: GLUT to freeglut
04 May 2012 - 12:12 PM
Ah I didn't notice that, I'll have a look at SDL then.
- Home
- » Viewing Profile: Posts: gamepopper

Find content