This topic is now archived and is closed to further replies.


fstream io problems with GLUT

Recommended Posts

Hi I''m reading pixel data with glReadPixels while using glut, I want to save the array of pixel data in a text format in a file using fstream. fstream will create the file but will not actually write the data to a file from within glutmainloop do you know why? and how to fix it? code: /*the func below is called from glutKeyboardFunc*/ void send_image_data_to_text(void) { RGB value; int x,y; fstream examplefile ("pmg.txt",ios::out); if (examplefile.is_open()) { examplefile << "This is a line2.\n"; examplefile << "This is another line.\n"; examplefile.close(); cout << "ha"; for(x=0; x<70; x++) for(y=0; y<70; y++) { value = pic[0].getPixel(x, y); examplefile << value.r << value.g << value.b; examplefile << "fuck!"; cout << value.r << value.g << value.b; } examplefile.close(); } } this function works fine in a normal VC++ project or in main before glutmainloop is called. This is how I know there is a problem between fstream and glut. If you have any info I would love to here from you.

Share this post

Link to post
Share on other sites