tailieunhanh - beginning opengl game programming 2004 phần 6

Tham khảo tài liệu 'beginning opengl game programming 2004 phần 6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Mipmaps 167 Figure Mipmaps help control the level of detail for textured objects. By default you have to specify all levels starting from level 0 to the level at which the texture becomes 1 X 1 which is equivalent to log2 of the largest dimension of the base texture . You can however change these limits by using the glTexParameter function with its pname parameter set to GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL respectively. The value passed to either of these parameters must be a positive integer. Mipmapping is first enabled by specifying one of the mipmapping values for texture minification. Once the texture minification filter has been set you then only need to specify the texture mipmap levels with one of the glTexImage3D glTexImage2D or glTexIm-age1D functions depending on your texture dimensionality. The following example code sets up a seven-level mipmap with a minification filter of GL_NEAREST_MIPMAP_LINEAR and starting at a 64 X 64 base texture glTexParameteri GL_TEXTURE_2D GL_TEXTURE_ glTexParameteri GL_TEXTURE_2D GL_TEXTURE glTexImage2D GL_TEXTURE_2D 0 GL_RGB 64 glTexImage2D GL_TEXTURE_2D 1 GL_RGB 32 glTexImage2D GL_TEXTURE_2D 2 GL_RGB 16 glTexImage2D GL_TEXTURE_2D 3 GL_RGB 8 glTexImage2D GL_TEXTURE_2D 4 GL_RGB 4 glTexImage2D GL_TEXTURE_2D 5 GL_RGB 2 glTexImage2D GL_TEXTURE_2D 6 GL_RGB 1 MAG_FILTER GL_LINEAR MIN_FILTER GL_NEAREST_MIPMAP_LINEAR 64 0 GL_RGB GL_UNSIGNED_BYTE texImage0 32 0 GL_RGB GL_UNSIGNED_BYTE texImage1 16 0 GL_RGB GL_UNSIGNED_BYTE texImage2 8 0 GL_RGB GL_UNSIGNED_BYTE texImage3 4 0 GL_RGB GL_UNSIGNED_BYTE texImage4 2 0 GL_RGB GL_UNSIGNED_BYTE texImage5 1 0 GL_RGB GL_UNSIGNED_BYTE texImage6 Mipmaps and the OpenGL Utility Library The GLU library provides the gluBuild2DMipmaps and gluBuild1DMipmaps functions to build mipmaps automatically for two- and one-dimensional textures respectively. These TLFeBOOK 168 Chapter 7 Texture Mapping functions replace the set of function calls you would normally make to the glTexImage2D and .