Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

reading binary -> C++ structs

Name: Anonymous 2006-06-10 21:03

I'm writing a program in C++ to read in .geo format binary 3d graphic files.  I have a file spec that gives me plainly the struct of the various data blocks.  As a result, I can do this:

tPolygonObject getObjectEntry (ifstream& geoFile, udword address)
{  tPolygonObject tmpobj;
   geoFile.seekg(address);
   geoFile.read((char*)&tmpobj, sizeObjectEntry);
   return tmpobj; }

// function call
polyObject[i] = getObjectEntry(geoFile, memFinger);

Meaning, I can simply read a chunk and plunk it down into my struct variable, and all the data members will be what they're supposed to be without me worrying about them lining up.

The problem is, what if I alter the structs, by adding more member variables? If I put them at the end, will it fill up the original ones in the same way, and leave the new members empty? Or will it just FUBAR everything?

Name: Anonymous 2006-06-15 12:30

Hmm, well im thinking of sorting sprites according to the y-axis to get them painted in the correct order, so im going to have a almost sorted list, only minor changes.
However from what i have understood, sorting can be quiet a time-consuming process, and since im trying to create a game, time is of the essence.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List