Saving the matrix

How can I save an object into a file. I made the Rubik cube and now I want to sacve the position of the matrix an the position of every little cube. IS there a function as glSaveMatrix?

NewROmancer

You can use

glGetDoublev(GL_MODELVIEW_MATRIX, PointerToArrayWith16GLdouble)

to save the modelview matrix to a variable (use GL_PROJECTION_MATRIX for the projection matrix…)

A double is a bit hefty.

A float array would do the trick here.

I making an assumption that you are basically asking how to save your game.

How is your object set up?
Does it store all data like rotations and translatrions in it?

Like if I copied the object while the program was running, then I have 2 seperate instances of the object to maniplate seperately.

If this is the case just open an output stream and dump the object into a binary file.

As for saving the matrix do what the guys said above. (Tho i dont know if this would work with just one call to get the matrix cause you are probably pushing and poping a lot). With the saving matrix method everytime you altered an individual matrix (between push and pop), you would have to save that matrix as well. (at least I think it would have to happen this way)

Chris

[This message has been edited by Whittick (edited 07-26-2000).]

Just another note, if you arent good with i/o streams (like me), there was a GREAT article on http://www.gamedev.net on the basics of them.

Chris

[This message has been edited by Whittick (edited 07-26-2000).]

Yes, I don’t know how to save the position of the little cubes. And I don’t know how to get their position. So how can I get it?

NewROmancer

To Whittic…
I don’t save the position because I have to save a lot (x,y,z and the vector from the center of image) for every image i post (and at 50 FPS are 50 images), and this for a lot of cubes . Make the multiply and you’ll see that there are a lot of operation every second. In fact I think that this method sucks and I try to find another one.

Anyway thaks for the help you provided. I REALLY appreciate it.

NewROmancer