void Graphics::show_splash_screen(){ if (!splash_loaded_) { glGenTextures( 1, &splash_ ); glBindTexture(GL_TEXTURE_2D, splash_); RgbImage theTexMap( "graphics/splash.bmp" ); // instantiation // Set the interpolation settings to best quality. 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_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, theTexMap.GetNumCols(), theTexMap.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE, theTexMap.ImageData() ); splash_loaded_ = true; } show_splash_ = true; }
// Loads a texture from a file, must be in bmp format GLuint Disc::loadTextureFromFile( const char * filename ){ GLuint texture; glGenTextures( 1, &texture ); glBindTexture(GL_TEXTURE_2D, texture); RgbImage theTexMap( filename ); // instantiation // Set the interpolation settings to best quality. 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_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, theTexMap.GetNumCols(), theTexMap.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE, theTexMap.ImageData() ); return texture; }
void loadTextureFromFile(char *filename, int i) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); RgbImage theTexMap(filename); // Pixel alignment: each row is word aligned (aligned to a 4 byte boundary) // Therefore, no need to call glPixelStore( GL_UNPACK_ALIGNMENT, ... ); glGenTextures(1, &texture[i]); // Create The Texture glBindTexture(GL_TEXTURE_2D, texture[i]); 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); // Typical Texture Generation Using Data From The Bitmap glTexImage2D(GL_TEXTURE_2D, 0, 3, theTexMap.GetNumCols(), theTexMap.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE, theTexMap.ImageData()); }