   Not showing polygons
  I have 2 functions in my code that saves the positions of all the polygons to binaryformat (map.fmr) and a load function that reads the coordinates of the polygons from map.fmr.The game shows the polygons if I have not used the load function.The game saves the file successfully and I think it also loads it successfully, BUT when I load the map the polygons does not appear. When I put a command to write polygon's coordinates to a file to check are they right after loading, it shows they are at the same positions as before, but for some reason the polygons are not showing on the screen.Any clues where's the problem, does it have something to do with OpenGL?PS. I'm using C++, SDL+OpenGL   
  1. They should be filled and they do have color saved with the binaryformat.2. "The normals are facing the wrong way." Hmm what do you mean with this?3. Btw, when I saved a boolean inside the map.fmr, after loading it all the coordinates showed -1059372 or something like that. So after that I removed the boolean from it and coordinates showed right, but not displaying.   ;  .fmr is my design, generated by the game.   ;  Test your loading system thoroughly - save some data, load it in as a copy, and compare the 2. Are they identical? If not, your problem's there.You may want to consider sharing some details about your format. I think some data's missing or you're writing things wrongly. For example, there's no reason why a boolean would come out so strangely.   ;  The .fmr format is very simple, function SaveMap saves the polygon data to file "map.fmr" and LoadMap loads the data from "map.fmr".But I'll post the code later when I get home, so maybe it'll make the bug search more easier.   ;  Here are the codes for SaveMap() and LoadMap()SaveMap(char *fileName)int CGame::SaveMap(char *fileName){    int i;    PolygonData pd;    FILE *pFile = fopen(fileName,"wb");    fwrite(&pd, sizeof(PolygonData), 1, pFile);    for (i=0;i&lt;MAX_POLYGON;i++)    {   if (Polygon.active)   {pd.id = i;  pd.pos1X = Polygon.pos1X;  pd.pos1Y = Polygon.pos1Y;  pd.pos2X = Polygon.pos2X;  pd.pos2Y = Polygon.pos2Y;  pd.pos3X = Polygon.pos3X;  pd.pos3Y = Polygon.pos3Y;pd.color1red = Polygon.color1red;pd.color1green = Polygon.color1green;pd.color1blue = Polygon.color1blue;pd.color2red = Polygon.color2red;pd.color2green = Polygon.color2green;pd.color2blue = Polygon.color2blue;pd.color3red = Polygon.color3red;pd.color3green = Polygon.color3green;pd.color3blue = Polygon.color3blue;   }   else   {   }    }    fclose(pFile);    return 1;}LoadMap(char *fileName)int CGame::LoadMap(char *fileName){    int i, j;    PolygonData pd;for (i=0;i&lt;MAX_POLYGON;i++)   Polygon.active = false;cameraVX = 0;    cameraVY = 0;    cameraX = 0;    cameraY = 0;viewX = 0;viewY = 0;    FILE *pFile = fopen(fileName, "rb");    if (pFile==NULL)   return 0;    fread(&pd, sizeof(PolygonData), 1, pFile);    for (i=0;i&lt;MAX_POLYGON;i++)    {   j = DrawPolygon(i,pd.pos1X,pd.pos1Y,pd.pos2X,pd.pos2Y,pd.pos3X,pd.pos3Y,pd.color1red,pd.color1green,pd.color1blue,pd.color2red,pd.color2green,pd.color2blue,pd.color3red,pd.color3green,pd.color3blue);    }    fclose (pFile);return 0;}PolygonDatastruct PolygonData{int id;float pos1X;float pos1Y;float pos2X;float pos2Y;float pos3X;float pos3Y;float color1red;float color1green;float color1blue;float color2red;float color2green;float color2blue;float color3red;float color3green;float color3blue;}; [Edited by - NukeCorr on September 19, 2007 8:13:29 AM];  Neither of those functions look like they are doing what you want them to.SaveMap just opens a file, writes out an uninitialized PolygonData to it, and then loops through all your polygons in the Polygon array, setting that PolygonData's members to values from each polygon, and then does nothing with it and just moves onto the next polygon, overwriting what you just set in the PolygonData, finally ending with closing the file.  In other words, SaveMap just writes a single (garbage) PolygonData to file and does nothing else.LoadMap tries to read a single PolygonData from a file, and then appears to draw that single polygon MAX_POLYGON times.  I don't think that's what you want to do, and drawing should probably be separate from loading.Writing/reading a class/struct directly like that isn't exactly a safe or portable method for saving/loading something.  Different compiler options may even change the output.  I suggest looking into proper serialization.And since you are writing this in C++, you should actually use C++.  Prefer std::string over char* and use C++ I/O streams instead of C's FILE routines.   ;  Woah!Thanks for help Kalidor, this was very helpful. I'm no coding-god, so I had to try some kind of saving method :PEDIT: I found the only problem that disappeared my polygons, it was:for (i=0;i<MAX_POLYGON;i++)   Polygon.active = false;And if Polygon.active is false it doesn't draw them on screen, what I was thinking when I wrote that code :SIt's working normally now.   