wordshooter.cpp
void RegisterTextures_Write()
//Function is used to load the textures from the
// files and display
{
	// allocate a texture name
	glGenTextures(nalphabets, tid);
	vector<unsigned char> data;
	ofstream ofile("image-data.bin", ios::binary | ios::out);
	// now load each cookies data...

	for (int i = 0; i < nalphabets; ++i) {

		// Read current cookie

		ReadImage(tnames[i], data);
		if (i == 0) {
			int length = data.size();
			ofile.write((char*)&length, sizeof(int));
		}
		ofile.write((char*)&data[0], sizeof(char) * data.size());

		mtid[i] = tid[i];
		// select our current texture
		glBindTexture(GL_TEXTURE_2D, tid[i]);

		// select modulate to mix texture with color for shading
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

		// when texture area is small, bilinear filter the closest MIP map
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
			GL_LINEAR_MIPMAP_NEAREST);
		// when texture area is large, bilinear filter the first MIP map
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

		// if wrap is true, the texture wraps over at the edges (repeat)
		//       ... false, the texture ends at the edges (clamp)
		bool wrap = true;
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
			wrap ? GL_REPEAT : GL_CLAMP);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
			wrap ? GL_REPEAT : GL_CLAMP);

		// build our texture MIP maps
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, awidth, aheight, GL_RGB,
			GL_UNSIGNED_BYTE, &data[0]);
	}
	ofile.close();

}
//USED THIS CODE FOR WRITING THE IMAGES TO .bin FILE
USED THIS CODE FOR WRITING THE IMAGES TO .bin FILE
USED THIS CODE FOR WRITING THE IMAGES TO . bin FILE
void RegisterTextures_Write()
{
	glGenTextures(nalphabets, tid);
	vector<unsigned char> data;
	ofstream ofile("image-data.bin", ios::binary | ios::out);
	for (int i = 0; i < nalphabets; ++i) {
		ReadImage(tnames[i], data);
		if (i == 0) {
			int length = data.size();
			ofile.write((char*)&length, sizeof(int));
		}
		ofile.write((char*)&data[0], sizeof(char) * data.size());
		mtid[i] = tid[i];
		glBindTexture(GL_TEXTURE_2D, tid[i]);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
			GL_LINEAR_MIPMAP_NEAREST);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		bool wrap = true;
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
			wrap ? GL_REPEAT : GL_CLAMP);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
			wrap ? GL_REPEAT : GL_CLAMP);
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, awidth, aheight, GL_RGB,
			GL_UNSIGNED_BYTE, &data[0]);
	}
	ofile.close();
}
void RegisterTextures_Write ( ) { glGenTextures ( nalphabets , tid ) ; vector < unsigned char > data ; ofstream ofile ( " " , ios :: binary | ios :: out ) ; for ( int i = 0 ; i < nalphabets ; ++ i ) { ReadImage ( tnames [ i ] , data ) ; if ( i == 0 ) { int length = data . size ( ) ; ofile . write ( ( char * ) & length , sizeof ( int ) ) ; } ofile . write ( ( char * ) & data [ 0 ] , sizeof ( char ) * data . size ( ) ) ; mtid [ i ] = tid [ i ] ; glBindTexture ( GL_TEXTURE_2D , tid [ i ] ) ; glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_MODULATE ) ; glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR_MIPMAP_NEAREST ) ; glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ; bool wrap = true ; glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , wrap ? GL_REPEAT : GL_CLAMP ) ; glTexParameterf ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , wrap ? GL_REPEAT : GL_CLAMP ) ; gluBuild2DMipmaps ( GL_TEXTURE_2D , 3 , awidth , aheight , GL_RGB , GL_UNSIGNED_BYTE , & data [ 0 ] ) ; } ofile . close ( ) ; }
USED THIS CODE FOR WRITING THE IMAGES TO .bin FILE
USED THIS CODE FOR WRITING THE IMAGES TO . bin FILE
//Function is used to load the textures from the // files and display // allocate a texture name // now load each cookies data... // Read current cookie // select our current texture // select modulate to mix texture with color for shading // when texture area is small, bilinear filter the closest MIP map // when texture area is large, bilinear filter the first MIP map // if wrap is true, the texture wraps over at the edges (repeat) //       ... false, the texture ends at the edges (clamp) // build our texture MIP maps