enum FaceType { ColorFace, TextureFace }; class FaceProperty{ public: Color color[3]; // 0:front 1:back 2:border GLuint texture[2]; FaceType type[2]; FaceProperty(){ color[0].set(255, 0, 0); color[1].set(0, 255, 255); color[2].set(255, 255, 255); type[0]=type[1]=ColorFace; glGenTextures(2, texture); } void loadColor( FILE *fp, int n ){ if( !fscanf_s( fp, "%u%u%u", &color[n].r, &color[n].g, &color[n].b ) ){ printf( "Error in file read\n" ); exit(1); } if( n < 2 ) type[n]=ColorFace; } void loadTexture( FILE *fp, int n ){ char filename[256]; if( !fscanf_s( fp, "%s", filename, 256 ) ){ printf( "Error in file read\n" ); exit(1); } Image image( filename, 512, 512, 3 ); glBindTexture( GL_TEXTURE_2D, texture[n] ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, image.width, image.height, 0, GL_RGB, GL_UNSIGNED_BYTE, image.pv ); type[n] = TextureFace; } void glColor( int n ){ glColor3ub( color[n].r, color[n].g, color[n].b ); } void glTexture( int n ){ glBindTexture( GL_TEXTURE_2D , texture[n] ); } };