基于opengl的粒子系统——模拟火焰内容摘要:

t slowdown=。 float xspeed。 // X 轴速度 float yspeed。 // Y 轴速度 float zoom=。 int a。 float xg1。 float yg1=。 GLuint loop。 // 循环变量 GLuint col=5。 // 初始颜色 GLuint texture[1]。 // 创建数组存储纹理 typedef struct // 创建结构体 { bool active。 // float life。 // 粒子生命周期 float fade。 // 消失的速度 float r。 float g。 float b。 float x。 // 坐标 float y。 // 坐标 float z。 // 坐标 float xi。 float yi。 float zi。 float xg。 // X 轴加速度 float yg。 // Y 轴加速度 float zg。 // Z 轴加速度 } particles。 particles particle[MAX_PARTICLES]。 // 创建粒子数组 static GLfloat colors[8][3]= // 颜色数组 { {,},{,},{,},{,}, {,}, {,}, {,},{,}, }。 AUX_RGBImageRec *LoadBMP(char *Filename) // 载入位图图像 { FILE *File=NULL。 if (!Filename) { return NULL。 } File=fopen(Filename,r)。 if (File) { fclose(File)。 return auxDIBImageLoad(Filename)。 } return NULL。 } int LoadGLTextures() // 载入位图 (调用上面的代码 )并转换成纹理 { int Status=FALSE。 AUX_RGBImageRec *TextureImage[1]。 memset(TextureImage,0,sizeof(void *)*1)。 printf(q 键 xg1+=。 ( X 轴加速度) 荧光黄色 \n)。 printf(w 键 yg1+=。 ( X 轴加速度) 玫瑰粉 \n)。 printf(a 键 xg1=。 ( X 轴加速度) 荧光绿 \n)。 printf(s 键 yg1=。 ( X 轴加速度) 亮紫 \n)。 printf(z 键 yg1=。 ( X 轴加速度) 藕荷色 \n)。 printf(\n\n)。 printf(***Choose the number of the shape***\n)。 //选择纹理 printf(1. Circle\t2. Pentagram\t3. Triangle\n\n)。 printf(4. Flame\t5. fourpointed Star\t6. Hexagon\n\n)。 scanf(%d,amp。 a)。 if(a6) { printf(****Tip:Error!!!Please reenter after exit!!****\n\n)。 exit(0)。 } switch(a) { case 1: { if (TextureImage[0]=LoadBMP()) { Status=TRUE。 glGenTextures(1, amp。 texture[0])。 glBindTexture(GL_TEXTURE_2D, texture[0])。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)。 glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]sizeX, TextureImage[0]sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]data)。 } } break。 case 2: { if (TextureImage[0]=LoadBMP()) { Status=TRUE。 glGenTextures(1, amp。 texture[0])。 glBindTexture(GL_TEXTURE_2D, texture[0])。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)。 glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]sizeX, TextureImage[0]sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]data)。 } }break。 case 3: { if (TextureImage[0]=LoadBMP()) { Status=TRUE。 glGenTextures(1, amp。 texture[0])。 glBindTexture(GL_TEXTURE_2D, texture[0])。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)。 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)。 g。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。