READING TEXT FILES WITH OPENGL

For the game I am making, I need to save game state information to a file (so the user can continue where they left off). Is it possible to use functions such as ifstream with OPENGL?

OpenGL has nothing to do with file input/output, it is a graphics library. You can use any file handling functions as you want. I would still wish for you to hear to mine and not only advice, and redesign your application completely. The way you write your code is a complete mess.

http://www.catb.org/~esr/faqs/smart-questions.html

Please really read it this time.

Since this thread is dead, I would like to go on record with something.

While I appreciate the purpose of that FAQ, I have to say that it is somewhat counterproductive. Why?

Because it makes programmers seem like colossal jerks. I mean, it’s one thing to say that your question is bad in some way, but the beginning of that document (for people who aren’t programmers) make us all sound like grand, great, flaming jerks.

If I weren’t actually a programmer, and I asked a question, and someone directed me to that faq, I’d immediately think, “These people are jerks, and I don’t want to waste my time dealing with them.” It basically makes the programmer community look bad to anyone who might want help from them.

Agreed, Korval. I think the message is a good one, but the tone of conveyance leaves a lot to be desired (it’s reminiscent of SNL’s “Nick Burns, your company’s computer guy” … MOV!) :smiley:

Perhaps age is a factor here.

Yes, that page is a bit harsh. “don’t ask stupid questions, we’ll ignore you!”

It’s best to give some tips

fopen
fwrite
fread
fclose

Just search for those and you will find plenty of info. There are other functions to do file I/O as well, but I prefer these low level ones.

It’s called a win-win situation when you help someone and tell them the Q is off topic.

for text files, fgets is probably better than fread (and fprintf better than fwrite).