资源简介
opengl——爆炸,粒子系统,对初学OPENGL者有益
代码片段和文件信息
// LoadOBJ.cpp: implementation of the CLoadOBJ class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “MyExplosion.h“
#include “LoadOBJ.h“
#include
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
const float pi = 3.1415926;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
static char *NormalizeString(char *s)
{
while (*s == ‘ ‘) s++;
ULONG l = strlen(s);
for (ULONG i=(l-1); i>0; i--)
if (s[i] < 33) s[i] = 0;
else break;
return s;
}
static void ParseFloat(char *s float *a float *b float *c)
{
int i j;
int x y z;
s = NormalizeString(s);
x = 0; y = -1; z = -1;
j = (int)strlen(s);
for (i=0; i {
if ((s[i] == ‘ ‘) || (s[i] == ‘\n‘))
{
s[i] = 0;
if (y == -1) y = i+1;
else
if (z == -1) z = i+1;
}
}
*a = (float)atof(&s[x]);
*b = (float)atof(&s[y]);
*c = (float)atof(&s[z]);
}
static int Parse3(char *s int *a int *b int *c)
{
int i j;
char *sp;
int stage=0;
j = (int)strlen(s);
sp = s;
for (i=0; i {
if ((s[i] == ‘/‘) || (i == j-1))
{
if (i != j-1) s[i] = 0;
switch (stage)
{
case 0: *a = atoi(sp); break;
case 1: *b = atoi(sp); break;
case 2: *c = atoi(sp); break;
}
stage++;
sp = &s[i+1];
}
}
return stage;
}
static int ParseFace(char *s int *a int *ta int *na int *b int *tb int *nb int *c int *tc int *nc)
{
int i j stage=0 total;
char *sp;
s = NormalizeString(s);
j = (int)strlen(s);
sp = s;
for (i=0; i {
if ((s[i] == ‘ ‘) || (i == j-1))
{
if (i != j-1) s[i] = 0;
switch (stage)
{
case 0: total = Parse3(sp a ta na); break;
case 1: total = Parse3(sp b tb nb); break;
case 2: total = Parse3(sp c tc nc); break;
}
stage++;
sp = &s[i+1];
}
}
return total;
}
CTexture::CTexture()
{
cur_texture = 0;
}
CTexture::~CTexture()
{
// 删除所有纹理
if (cur_texture > 0) glDeleteTextures(cur_texture &textures[0]);
}
void CTexture::Init()
{
glGenTextures(MAX_TEXTURES textures);
}
GLuint CTexture::AddNewTexture(char *lpszName)
{
unsigned *teximage;
int texwid texht;
int texcomps;
teximage = m_Texture->read_texture(lpszName &texwid &texht &texcomps);
if (!teximage) return -1;
glBindTexture(GL_TEXTURE_2D textures[cur_texture]);
cur_texture++;
glPixelStorei(GL_UNPACK_ALIGNMENT 1);
glTexImage2D(GL_TEXTURE_2D 0 3 texwid texht 0 GL_RGBA GL_UNSIGNED_BYTE teximage);
gluBuild2DMipmaps(GL_TEXTURE_2D 3 texwid texht GL_RGBA GL_UNSIGNED_BYTE teximage);
glTexParameterf(GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR_MIPMAP_L
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 347 2005-10-19 15:32 MyExplosion\DATA\SHIP.MTL
文件 93614 2005-10-19 15:32 MyExplosion\DATA\SHIP.OBJ
文件 15050 2005-10-19 15:32 MyExplosion\DATA\SHIP.RGB
文件 11768 2005-10-19 15:32 MyExplosion\DATA\VZR.RGB
文件 347 2005-10-19 15:32 MyExplosion\Debug\DATA\SHIP.MTL
文件 93614 2005-10-19 15:32 MyExplosion\Debug\DATA\SHIP.OBJ
文件 15050 2005-10-19 15:32 MyExplosion\Debug\DATA\SHIP.RGB
文件 11768 2005-10-19 15:32 MyExplosion\Debug\DATA\VZR.RGB
文件 143464 2005-10-19 15:32 MyExplosion\Debug\MyExplosion.exe
文件 15950 2005-10-19 15:32 MyExplosion\LoadOBJ.cpp
文件 2457 2005-10-19 15:32 MyExplosion\LoadOBJ.h
文件 2512 2005-10-19 15:32 MyExplosion\MainFrm.cpp
文件 1581 2005-10-19 15:32 MyExplosion\MainFrm.h
文件 29088 2005-10-19 15:32 MyExplosion\MyExplosion.aps
文件 2359 2005-10-19 15:32 MyExplosion\MyExplosion.clw
文件 4299 2005-10-19 15:32 MyExplosion\MyExplosion.cpp
文件 4916 2005-10-19 15:32 MyExplosion\MyExplosion.dsp
文件 547 2005-10-19 15:32 MyExplosion\MyExplosion.dsw
文件 1408 2005-10-19 15:32 MyExplosion\MyExplosion.h
文件 82944 2005-10-19 15:32 MyExplosion\MyExplosion.ncb
文件 49664 2005-10-19 15:32 MyExplosion\MyExplosion.opt
文件 1528 2005-10-19 15:32 MyExplosion\MyExplosion.plg
文件 10610 2005-10-19 15:32 MyExplosion\MyExplosion.rc
文件 1842 2005-10-19 15:32 MyExplosion\MyExplosionDoc.cpp
文件 1527 2005-10-19 15:32 MyExplosion\MyExplosionDoc.h
文件 10610 2005-10-19 15:32 MyExplosion\MyExplosionView.cpp
文件 2741 2005-10-19 15:32 MyExplosion\MyExplosionView.h
文件 6624 2005-10-19 15:32 MyExplosion\MyTexture.cpp
文件 1614 2005-10-19 15:32 MyExplosion\MyTexture.h
文件 4430 2005-10-19 15:32 MyExplosion\ReadMe.txt
............此处省略15个文件信息
- 上一篇:政府大数据公司设立意义及运营策略
- 下一篇:midi格式音乐大合集
评论
共有 条评论