资源简介
计算机图形学,绘制一个宇宙的太阳系,要求有九大行星,有各自的公转,自转,以及月球绕地球等

代码片段和文件信息
// LoadTGA.c
// Loads a Targa file for OpenGL
// Richard S. Wright Jr.
// OpenGL SuperBible
// This really only works with 24/32/8 bit targas
#include “Tool.h“
#include
// Define targa header.
#pragma pack(1)
typedef struct
{
GLbyte identsize; // Size of ID field that follows header (0)
GLbyte colorMapType; // 0 = None 1 = paletted
GLbyte imageType; // 0 = none 1 = indexed 2 = rgb 3 = grey +8=rle
unsigned short colorMapStart; // First colour map entry
unsigned short colorMapLength; // Number of colors
unsigned char colorMapBits; // bits per palette entry
unsigned short xstart; // image x origin
unsigned short ystart; // image y origin
unsigned short width; // width in pixels
unsigned short height; // height in pixels
GLbyte bits; // bits per pixel (8 16 24 32)
GLbyte descriptor; // image descriptor
} TGAHEADER;
#pragma pack(8)
////////////////////////////////////////////////////////////////////
// Allocate memory and load targa bits. Returns pointer to new buffer
// height and width of texture and the OpenGL format of data.
// Call free() on buffer when finished!
// This only works on pretty vanilla targas... 8 24 or 32 bit color
// only no palettes no RLE encoding.
GLbyte *gltLoadTGA(const char *szFileName GLint *iWidth GLint *iHeight GLint *iComponents GLenum *eFormat)
{
FILE *pFile; // File pointer
TGAHEADER tgaHeader; // TGA file header
unsigned long lImageSize; // Size in bytes of image
short sDepth; // Pixel depth;
GLbyte *pBits = NULL; // Pointer to bits
// Default/Failed values
*iWidth = 0;
*iHeight = 0;
*eFormat = GL_BGR_EXT;
*iComponents = GL_RGB8;
// Attempt to open the fil
pFile = fopen(szFileName “rb“);
if(pFile == NULL)
return NULL;
// Read in header (binary)
fread(&tgaHeader 18/* sizeof(TGAHEADER)*/ 1 pFile);
// Do byte swap for big vs little endian
#ifdef __APPLE__
BYTE_SWAP(tgaHeader.colorMapStart);
BYTE_SWAP(tgaHeader.colorMapLength);
BYTE_SWAP(tgaHeader.xstart);
BYTE_SWAP(tgaHeader.ystart);
BYTE_SWAP(tgaHeader.width);
BYTE_SWAP(tgaHeader.height);
#endif
// Get width height and depth of texture
*iWidth = tgaHeader.width;
*iHeight = tgaHeader.height;
sDepth = tgaHeader.bits / 8;
// Put some validity checks here. Very simply I only understand
// or care about 8 24 or 32 bit targa‘s.
if(tgaHeader.bits != 8 && tgaHeader.bits != 24 && tgaHeader.bits != 32)
return NULL;
// Calculate size of image buffer
lImageSize = tgaHeader.width * tgaHeader.height * sDepth;
// Allocate memory and check for success
pBits
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 165376 2013-02-27 20:20 solar\Debug\glu32.dll
文件 169984 2013-02-27 20:20 solar\Debug\glut.dll
文件 169984 2013-02-27 20:20 solar\Debug\glut32.dll
文件 3646 2013-05-06 18:53 solar\Debug\LoadTGA.obj
文件 52981 2013-05-06 18:53 solar\Debug\LoadTGA.sbr
文件 3220480 2013-05-05 20:29 solar\Debug\Solar2.bsc
文件 217168 2013-05-07 22:37 solar\Debug\Solar2.exe
文件 272296 2013-05-07 22:37 solar\Debug\Solar2.ilk
文件 27570 2013-05-07 22:37 solar\Debug\Solar2.obj
I.A.... 2423452 2013-05-06 19:30 solar\Debug\Solar2.pch
文件 541696 2013-05-07 22:37 solar\Debug\Solar2.pdb
文件 629631 2013-05-07 22:37 solar\Debug\Solar2.sbr
文件 58368 2013-05-07 22:37 solar\Debug\vc60.idb
文件 53248 2013-05-07 22:37 solar\Debug\vc60.pdb
文件 1572908 2013-05-05 20:28 solar\Earth.tga
文件 302727 2013-05-05 20:24 solar\GLEXT.H
文件 3110444 2013-05-05 20:25 solar\Jupiter.tga
文件 3780 2013-05-05 20:24 solar\LoadTGA.c
文件 3110444 2013-05-05 20:25 solar\Mars.tga
文件 1572908 2013-05-05 20:26 solar\Mercury.tga
文件 1572908 2013-05-05 20:28 solar\Moon.tga
文件 777644 2013-05-05 20:24 solar\Neptune.tga
文件 777644 2013-05-05 20:24 solar\Pluto.tga
文件 777644 2013-05-05 20:24 solar\Saturn.tga
文件 13188 2013-05-07 22:37 solar\Solar2.c
文件 3583 2013-05-06 18:54 solar\Solar2.dsp
文件 520 2013-05-05 20:24 solar\Solar2.dsw
文件 107520 2013-05-07 22:37 solar\Solar2.ncb
文件 48640 2013-05-07 22:37 solar\Solar2.opt
文件 1218 2013-05-07 22:37 solar\Solar2.plg
............此处省略9个文件信息
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
评论
共有 条评论