纹理滤波(Texture Filter)
生活随笔
收集整理的這篇文章主要介紹了
纹理滤波(Texture Filter)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
0 原始貼圖
1 Nearest濾波紋理
2 線性濾波紋理
3 MipMapped紋理
int LoadGLTextures() // 載入位圖(調用上面的代碼)并轉換成紋理 {int Status=FALSE; // 狀態指示器AUX_RGBImageRec *TextureImage[1]; // 創建紋理的存儲空間memset(TextureImage,0,sizeof(void *)*1); // 將指針設為 NULL// 載入位圖,檢查有錯,或位圖不存在的話退出if (TextureImage[0]=LoadBMP("E:/OpenSource/Nehe/code/07_FilterAndLight/Debug/Data/Crate.bmp")){Status=TRUE; // 狀態設為 TRUEglGenTextures(3, &texture[0]); // 創建紋理// 創建 Nearest 濾波貼圖glBindTexture(GL_TEXTURE_2D, texture[0]);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, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);// 創建線性濾波紋理glBindTexture(GL_TEXTURE_2D, texture[1]);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);// 創建 MipMapped 紋理glBindTexture(GL_TEXTURE_2D, texture[2]);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); }if (TextureImage[0]) // 紋理是否存在{if (TextureImage[0]->data) // 紋理圖像是否存在{free(TextureImage[0]->data); // 釋放紋理圖像占用的內存}free(TextureImage[0]); // 釋放圖像結構}return Status; // 返回 Status }更多請參考:http://www.owlei.com/DancingWind/Course/Tutorial_07.htm
轉載于:https://www.cnblogs.com/kekec/archive/2012/01/21/2328711.html
總結
以上是生活随笔為你收集整理的纹理滤波(Texture Filter)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 福特野马多少钱 探究福特野马的价格和配置
- 下一篇: [projectEuler.net]12