資源簡介
用opengl實現的正六面體貼圖,每面的圖形都不一樣,圖像文件存放在Data文件夾下。
使用vs2005及以上版本編譯。
按鍵盤上的上、下、左、右可實現六面體旋轉的方向及速度。

代碼片段和文件信息
/*
?* This?Code?Was?Created?By?Jeff?Molofee?2000
?* A?HUGE?Thanks?To?Fredric?Echols?For?Cleaning?Up
?* And?Optimizing?The?base?Code?Making?It?More?Flexible!
?* If?You‘ve?Found?This?Code?Useful?Please?Let?Me?Know.
?* Visit?My?Site?At?nehe.gamedev.net
?*/
#include? //?Header?File?For?Windows
#include? //?Header?File?For?Standard?Input/Output
#include? //?Header?File?For?The?OpenGL32?Library
#include? //?Header?File?For?The?GLu32?Library
#include? //?Header?File?For?The?Glaux?Library
HDC hDC=NULL; //?Private?GDI?Device?Context
HGLRC hRC=NULL; //?Permanent?Rendering?Context
HWND hWnd=NULL; //?Holds?Our?Window?Handle
HINSTANCE hInstance; //?Holds?The?Instance?Of?The?Application
bool keys[256]; //?Array?Used?For?The?Keyboard?Routine
bool active=TRUE; //?Window?Active?Flag?Set?To?TRUE?By?Default
bool fullscreen=TRUE; //?Fullscreen?Flag?Set?To?Fullscreen?Mode?By?Default
GLfloat xrot; //?X?Rotation?(?NEW?)
GLfloat yrot; //?Y?Rotation?(?NEW?)
GLfloat zrot; //?Z?Rotation?(?NEW?)
GLuint texture[6]; //?Storage?For?One?Texture?(?NEW?)
LRESULT CALLBACK?WndProc(HWND?UINT?WPARAM?LPARAM); //?Declaration?For?WndProc
AUX_RGBImageRec?*LoadBMP(char?*Filename) //?Loads?A?Bitmap?Image
{
FILE?*File=NULL; //?File?Handle
if?(!Filename) //?Make?Sure?A?Filename?Was?Given
{
return?NULL; //?If?Not?Return?NULL
}
File=fopen(Filename“r“); //?Check?To?See?If?The?File?Exists
if?(File) //?Does?The?File?Exist?
{
fclose(File); //?Close?The?Handle
return?auxDIBImageLoad(Filename); //?Load?The?Bitmap?And?Return?A?Pointer
}
return?NULL; //?If?Load?Failed?Return?NULL
}
int?LoadGLTextures() //?Load?Bitmaps?And?Convert?To?Textures
{
int?Status=FALSE; //?Status?Indicator
????int?i;
AUX_RGBImageRec?*TextureImage[1]; //?Create?Storage?Space?For?The?Texture
memset(TextureImage0sizeof(void?*)*1);??????????? //?Set?The?Pointer?To?NULL
????glGenTextures(6&texture[0]);?
//?Load?The?Bitmap?Check?For?Errors?If?Bitmap‘s?Not?Found?Quit
????char?*Imagename[6]={“Data/1.bmp““Data/2.bmp““Data/3.bmp““Data/4.bmp““Data/5.bmp““Data/6.bmp“};
for(i=0;i<6;i++)
{
???? if?(TextureImage[0]=LoadBMP(*(Imagename+i)))
{
Status=TRUE; //?Set?The?Status?To?TRUE
// glGenTextures(1?&texture[0]); //?Create?The?Texture
//?Typical?Texture?Generation?Using?Data?From?The?Bitmap
glBindTexture(GL_TEXTURE_2D?texture[i]);
glTexImage2D(GL_TEXTURE_2D?0?3?TextureImage[0]->sizeX?TextureImage[0]->sizeY?0?GL_RGB?GL_UNSIGNED_BYTE?TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
}
??if?(TextureImage[0]) //?If?Texture?Exists
??{
if?(TextureImage[0]->data) //?If?Texture?Image?Exists
{
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????9620480??2010-09-22?14:49??Lesson6.ncb
?????文件??????48640??2009-09-06?10:44??Lesson6.opt
?????文件????????878??2010-09-22?14:45??Lesson6.sln
????..A..H.??????8192??2010-09-22?14:49??Lesson6.suo
?????文件???????5552??2010-09-22?14:45??lesson6.vcproj
?????文件???????1407??2010-09-22?14:49??lesson6.vcproj.WANZY.love.user
?????文件????????530??2000-02-02?20:50??NeHe‘s?Readme.txt
?????文件?????786486??2008-12-08?16:25??Data\1.bmp
?????文件?????786486??2008-12-08?16:25??Data\2.bmp
?????文件?????786486??2008-12-08?16:26??Data\3.bmp
?????文件?????786486??2008-12-08?15:38??Data\4.bmp
?????文件?????786486??2008-12-08?15:34??Data\5.bmp
?????文件?????196664??2000-03-06?02:10??Data\6.bmp
????..A.SHR?????????9??2009-08-12?17:29??Data\Desktop_.ini
????..A.SH.?????30208??2009-09-06?10:39??Data\Thumbs.db
?????文件??????19825??2008-12-08?18:57??Lesson6.cpp
?????目錄??????????0??2010-09-22?14:48??Data
-----------?---------??----------?-----??----
?????????????13864815????????????????????17
- 上一篇:la-9911P聯想的G405主板bios
- 下一篇:卡爾曼濾波與組合導航
評論
共有 條評論