• 大小: 20.48MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-05
  • 语言: 其他
  • 标签: opengl  粒子系统  

资源简介

基于opengl做的一个粒子系统作业,包括雪景,花瓣,流星和粒子字母,代码清晰,适合初学者学习. ps:dlut的就不要下了

资源截图

代码片段和文件信息

#include “particle.h“
#include “word.h“
#include “Tree.h“
#include “Snow.h“
#include “Star.h“
GLuint texture[15];//用于装纹理名称的数组
float angle = 0;
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[15];//用于装位图资源的数组 

memset(TextureImage 0 sizeof(void *) * 2);//初始化指针数组

char *pictures[] = {// 创建一个位图名称数组
“Debug/wall.bmp“
“Debug/snowball.bmp“
“Debug/ground.bmp“
“Debug/tree.bmp“
“Debug/flower.bmp“
“Debug/flower1.bmp“
“Debug/flower2.bmp“
“Debug/flower3.bmp“
“Debug/flower4.bmp“
“Debug/sky.bmp“
“Debug/wall_2.bmp“
“Debug/snow.bmp“
“Debug/tree_2.bmp“
“Debug/stone.bmp“
“Debug/moon.bmp“
};

for (int i = 0; i < 15; i++)
{
if (TextureImage[i] = LoadBMP(pictures[i]))// 加载位图i成功,修改状态标志变量Status为TRUE
{
Status = TRUE;

glGenTextures(1 &texture[i]);     // 为第i个位图创建纹理
glBindTexture(GL_TEXTURE_2D texture[i]);// 将生成的纹理的名称绑定到指定的纹理上
glTexImage2D(GL_TEXTURE_2D 0 3 TextureImage[i]->sizeX TextureImage[i]->sizeY 0 GL_RGB GL_UNSIGNED_BYTE TextureImage[i]->data);
glTexParameteri(GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR);
}

if (TextureImage[i])         // 释放位图数组占用的内存空间
{
if (TextureImage[i]->data)
{
free(TextureImage[i]->data);
}

free(TextureImage[i]);
}
}
return Status;
}
void UpdateDown()
{
x += vx;
y += vy;
z += vz;

/** 更新速度 */
vy += ay;
}

void Tree_DrawGround()
{
glPushMatrix();
glTranslatef(0.0f 0.0f -6.0f);
glRotatef(0 0.0f 1.0f 0.0f);

/** 指定纹理 */
glBindTexture(GL_TEXTURE_2D texture[2]);
glColor4ub(255 255 255 255);
glNormal3f(0.0f 1.0f 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f 0.0f); glVertex3f(-5 -1.0f 5);
glTexCoord2f(1.0f 0.0f); glVertex3f(5 -1.0f 5);
glTexCoord2f(1.0f 1.0f); glVertex3f(5 -1.0f -5);
glTexCoord2f(0.0f 1.0f); glVertex3f(-5 -1.0f -5);
glEnd();

//树的绘制
glBindTexture(GL_TEXTURE_2D texture[3]);
glColor4ub(255 255 255 255);
glNormal3f(0.0f 1.0f 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f 0.0f); glVertex3f(-2 -1.0 -1);
glTexCoord2f(1.0f 0.0f); glVertex3f(2 -1.0 -1);
glTexCoord2f(1.0f 1.0f); glVertex3f(2 2.15f -1);
glTexCoord2f(0.0f 1.0f); glVertex3f(-2 2.15f -1);
glEnd();

glBindTexture(GL_TEXTURE_2D texture[3]);
glColor4ub(255 255 255 255);
glNormal3f(0.0f 1.0f 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f 0.0f); glVertex3f(1 -1.0 1);
glTexCoord2f(1.0f 0.0f); glVertex3f(4 -1.0 1);
glTexCoord2f(1.0f 1.0f); glVertex3f(4 2.15f 1);
glTexCoord2f(0.0f 1.0f); glVertex3f(1 2.15f 1);
glEnd();

glBindTexture(GL_TEXTURE_2D texture[3

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     77312  2018-05-05 14:48  大作业——最终修订版\ConsoleApplication1\.vs\ConsoleApplication1\v14\.suo

     文件       7905  2018-05-05 14:05  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.vcxproj

     文件       1854  2018-05-05 14:05  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.vcxproj.filters

     文件       4734  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\CL.command.1.tlog

     文件     199964  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\CL.read.1.tlog

     文件       4426  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\CL.write.1.tlog

     文件        237  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\ConsoleApplication1.lastbuildstate

     文件       2502  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\link.command.1.tlog

     文件       6046  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\link.read.1.tlog

     文件       1538  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleA.E4FB0AA3.tlog\link.write.1.tlog

     文件       2412  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleApplication1.Build.CppClean.log

     文件        385  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ConsoleApplication1.log

     文件     380044  2018-05-02 21:22  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\flower.bmp

     文件     750056  2018-05-02 21:31  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\flower1.bmp

     文件     750056  2018-05-02 21:32  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\flower2.bmp

     文件     750056  2018-05-02 21:32  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\flower3.bmp

     文件     750056  2018-05-02 21:32  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\flower4.bmp

     文件    1545272  2018-05-03 12:07  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\ground.bmp

     文件     182737  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\main.obj

     文件     602096  2018-05-04 00:29  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\moon.bmp

     文件      64005  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\particle.obj

     文件     484064  2018-05-03 18:23  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\sky.bmp

     文件     591032  2018-05-02 21:06  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\snow.bmp

     文件      57786  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\Snow.obj

     文件      49206  2018-04-24 19:49  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\snowball.bmp

     文件      66390  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\Star.obj

     文件     196662  2018-05-03 13:27  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\stone.bmp

     文件    6725048  2018-05-02 21:54  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\tree.bmp

     文件      55709  2018-05-05 14:47  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\Tree.obj

     文件     691256  2018-05-02 20:31  大作业——最终修订版\ConsoleApplication1\ConsoleApplication1\Debug\tree_2.bmp

............此处省略49个文件信息

评论

共有 条评论