Jump to content
  • Advertisement

Tim Stoddard

Member
  • Content Count

    8
  • Joined

  • Last visited

Everything posted by Tim Stoddard

  1. Tim Stoddard

    #define doesn't work

    Also changing "#if define(HELLO)" to "#ifdef HELLO" might help.
  2. Tim Stoddard

    Visual Studio C++ Release Build Issue

    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!
  3. I'm working on an OpenGL game, but I'm guessing this is mostly a C++ issue. It loads in models in a class from files, storing the values of both the model and the corresponding material for each object in vectors and arrays. When I run the debug version, it runs and displays what I expect to display if I write the code correctly, however when I build a release version, the values of some of the material files get read funny because it displays the wrong colours and shading values. This is the issue below: I'm running the professional/ultimate/paid-for version of Visual Studio 2010, I've repeatedly cleaned the solution, project and the release builds, I've also modified the files where the issue is notable and it has no effect. Why does this happen and what can I do to fix it?
  4. Tim Stoddard

    Visual Studio C++ Release Build Issue

    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, ' ');} //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, ' ');} //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, ' ');} //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, ' ');} //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, ' ');} //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.
  5. Tim Stoddard

    GLUT to freeglut

    So I'm currently working on a project in GLUT using Visual Studio 2010 C++. I want to make it run on freeglut because 1. From what I've read it's similar to GLUT 2. It's better because it's more updated to include features such as control of the main loop and closing windows. So I download the package from TransmissionZero and add the correct header and dll files and changed my class definitions to include freeglut.h, assuming that freeglut will still process glut functions and variables. Obviously I was assuming wrong because as soon as I made the switch, I get 500+ warnings and 10+ errors on my program when I try to build it. Every warning refers to a macro redefinition of GLUT specific variables (most of which aren't used in my program) and each error consist of "'<glut function name>_ATEXIT_HACK' : redefinition, different linkage". Switching the freeglut.h include back to glut.h loses all the errors and the program works normally. So I'm aware that transferring from GLUT to freeglut isn't easy, but I can't find many tutorials specifically for freeglut and those I do find are similar to standard GLUT. Is there anything I should check or do? I've tried both methods of including freeglut (both adding the file locations as additional include and link directories and by adding the files in the project's folder) and I get the same result.
  6. Tim Stoddard

    GLUT to freeglut

    Ah I didn't notice that, I'll have a look at SDL then.
  • Advertisement
×

Important Information

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

GameDev.net 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!