资源简介
用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
- 下一篇:卡尔曼滤波与组合导航
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 如何实现bmp位图透明贴图
- 基于Gabor滤波器的图像纹理特征提取
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- 基于纹理的图像检索源代码
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 线性和反向跷跷板中的最大零纹理
- 反向跷跷板中具有破碎的循环对称性
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
评论
共有 条评论