资源简介
VC++ MFC OpenGL OpenGL纹理贴图源程序示例.rar,简单易懂学习交流

代码片段和文件信息
// EP7-4.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
GLuint texture[5]; // Storage For One Texture
GLUquadricObj *pSphere = NULL;
GLfloat param1[]={1001};
GLfloat param2[]={0011};
int angle = 0;
int nAngleY=0; // 沿Y轴旋转的角度
int nAngleX=0; // 沿X轴旋转的角度
int nAngleZ=0; // 沿Z轴旋转的角度
// 装入位图文件Loads A Bitmap Image
// 装入位图文件Loads A Bitmap Image
AUX_RGBImageRec *LoadBitmap(char *Filename)
{
// 声明一个文件句柄用于打开文件
FILE *File=NULL; // File Handle
// 文件名不能空
if (!Filename) // Make Sure A Filename Was Given
{
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
}
// 文件装入失败,返回NULL
return NULL; // If Load Failed Return NULL
}
// 装入位图文件并作为纹理贴图
int LoadTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage=0; // Create Storage Space For The Texture
// 生成纹理对象名称,共5个
glGenTextures(5 &texture[0]); // Create The Texture
if (TextureImage=LoadBitmap(“Images\\CoffeeBean.bmp“))
{
Status=TRUE; // Set The Status To TRUE
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D texture[0]);
glTexImage2D(GL_TEXTURE_2D 0 GL_RGB TextureImage->sizeX TextureImage->sizeY 0 GL_RGB GL_UNSIGNED_BYTE TextureImage->data);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
// 释放资源
if (TextureImage) // If Texture Exists
{
if (TextureImage->data) // If Texture Image Exists
{
free (TextureImage->data); // Free The Texture Image Memory
}
free(TextureImage); // Free The Image Structure
}
}
if (TextureImage=LoadBitmap(“Images\\木纹2.bmp“))
{
Status=TRUE; // Set The Status To TRUE
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D texture[1]);
glTexImage2D(GL_TEXTURE_2D 0 GL_RGB TextureImage->sizeX TextureImage->sizeY 0 GL_RGB GL_UNSIGNED_BYTE TextureImage->data);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
// 释放资源
if (TextureImage) // If Texture Exists
{
if (TextureImage->data) // If Texture Image Exists
{
free (TextureImage->data); // Free The Texture Image Memory
}
free(TextureImage); // Free The Image Structure
}
}
if (TextureImage=LoadBitmap(“Images\\Earth.bmp“))
{
Status=TRUE; // Set The Status To TRUE
// Typical Texture Generation Us
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-04-15 07:07 EP7-4
目录 0 2011-04-13 08:26 EP7-4\EP7-4
文件 16679 2011-04-13 08:26 EP7-4\EP7-4\EP7-4.cpp
文件 4480 2011-04-10 22:48 EP7-4\EP7-4\EP7-4.vcproj
文件 1411 2011-04-14 10:27 EP7-4\EP7-4\EP7-4.vcproj.VFSIGHT.lichangling.user
目录 0 2011-04-10 23:36 EP7-4\EP7-4\Images
文件 196662 2006-05-06 23:40 EP7-4\EP7-4\Images\CoffeeBean.bmp
文件 393272 1999-09-26 03:24 EP7-4\EP7-4\Images\EARTH.BMP
文件 196662 2006-10-19 17:29 EP7-4\EP7-4\Images\Greenstone.bmp
文件 196664 2000-03-06 02:10 EP7-4\EP7-4\Images\NeHe.bmp
文件 393270 2006-05-06 01:22 EP7-4\EP7-4\Images\outlook.bmp
..A.SH. 36352 2011-04-10 23:36 EP7-4\EP7-4\Images\Thumbs.db
文件 196662 2011-04-10 23:36 EP7-4\EP7-4\Images\木纹1.bmp
文件 49208 2011-04-10 23:19 EP7-4\EP7-4\Images\木纹2.bmp
文件 938 2011-04-10 22:47 EP7-4\EP7-4\ReadMe.txt
文件 210 2011-04-10 22:47 EP7-4\EP7-4\stdafx.cpp
文件 525 2011-04-11 22:11 EP7-4\EP7-4\stdafx.h
文件 880 2011-04-10 22:47 EP7-4\EP7-4.sln
..A..H. 16384 2011-04-14 10:27 EP7-4\EP7-4.suo
----------- --------- ---------- ----- ----
1700259 19
相关资源
- VC++ 多线程文件读写操作
- 移木块游戏,可以自编自玩,vc6.0编写
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC++实现CMD命令执行与获得返回信息
- 安卓c语言开发SDL2+opengles
- 交互式计算机图形学 第六版 OpenGL源代
- VC++基于OpenGL模拟的一个3维空间模型
- 基于VC++的SolidWorks二次开发SolidWorks
- 派克变换VC++源码(附文档)
- VC++ 串口
- VC++ 大富翁4_大富翁游戏源码
- VC++ 摄像头视频采集与回放源程序
- 转 VC++ 实现电子邮件(Email)发送
- opengl绘制汽车.cpp
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- VC++ 服务程序编写及安装与卸载
- VC++6.0番茄西红柿VAXvirsual assist X完美破
- 基于改进的fcm算法的图像分割vc++
- VC++6.0 绿色版,免安装,非常好用。
- Microsoft Visual C++ 2005 Redistributable Pack
- VC++MFC课程设计的学生成绩管理系统
- 大智慧365DLL插件设计
- VC++6.0汉化包
- VC++完整商业界面源码(再上传)
- VC++编程技术600个大型项目源码.rar
- VC++实现RSA加密算法
- VC++ 中国象棋经典游戏源代码
- 郁金香VC++游戏辅助视频教程
- C语言进阶源码---基于graphics实现图书
- 摄影测量相对定向VC++程序
评论
共有 条评论