Msn web hosting - Page 442 OpenGL Super Bible! bits = LoadDIBitmap(’textures/sky.bmp ,
Page 442 OpenGL Super Bible! bits = LoadDIBitmap(’textures/sky.bmp , &info); if (bits == NULL) return; rgb = ConvertRGB(info, bits); if (rgb == NULL) { free(info); free(bits); return; }; glNewList(SkyTexture = glGenLists(1), GL_COMPILE); 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_LINE AR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); /* * Define the 2D texture image. */ glPixelStorei(GL_UNPACK_ALIGNMENT, 4); /* Force 4-byte alignment */ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glTexImage2D(GL_TEXTURE_2D, 0, 3, info->bmiHeader.biWidth, info- >bmiHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, rgb); glEndList(); /* * Free the bitmap and RGB images, then return 0 (no errors). */ free(rgb); free(info); free(bits); } A Note About Textures: You ll notice that all the examples presented in this chapter use display lists to store texture images. Display lists generally speed up the drawing of static graphics commands, and texture images are no exception. In addition, the forthcoming OpenGL 1.1 API includes texture object support that optimizes texture images stored in display lists by keeping them loaded in the graphics hardware texture memory if available.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.