資源簡介
自己為圖形學課程寫的大作業,是在vc6.0的環境下用OPENGL實現一個簡易的保齡球小程序。

代碼片段和文件信息
//最后修改2010-07-10
//ye020510625@126.com
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#pragma?comment(?lib?“winmm.lib“)
#pragma?comment(?lib?“opengl32.lib“) //?OpenGL32連接庫
#pragma?comment(?lib?“glu32.lib“) //?GLu32連接庫
#pragma?comment(?lib?“glaux.lib“) //?GLaux連接庫
float?x=0.0;
float?distance?=?2.0;
float?angle?=?0.0;
float?speed?=?2.0;
float?ye=0.0fall=-0.02;
float?rate?=1.0;
float?choose1=0.0?alpha=0.0;
int?flag?=0i=0status=0delay=0direction=1?flag_out=0;
int?down_flag[10]={0?0?0?0?0?0?0?0?0?0};
float?down_angle_dir[10]?down_angle_step[10]={0.0?0.0?0.0?0.0?0.0?0.0?0.0?0.0?0.0?0.0}?down_bottom_add[10];
float?random[10];
struct?point
{
float?xz;
};
struct?point?bottle_position[10]={{0.0-17.14}{-0.13-17.365}{0.13-17.365}{-0.26-17.59}{0.0-17.59}{0.26-17.59}{-0.39-17.815}{-0.13-17.815}{0.13-17.815}{0.39-17.815}};
UINT?g_cactus[16];
bool?LoadT8(char?*filename?GLuint?&texture)
{ AUX_RGBImageRec?*pImage?=?NULL;
pImage?=?auxDIBImageLoad(filename);
if(pImage?==?NULL) return?false;
glGenTextures(1?&texture);
glBindTexture????(GL_TEXTURE_2Dtexture);
gluBuild2DMipmaps(GL_TEXTURE_2D4?pImage->sizeX?
??pImage->sizeYGL_RGB?GL_UNSIGNED_BYTEpImage->data);
free(pImage->data);
free(pImage);
return?true;
}
void?my_random()
{
int?ni;
srand(time(NULL));
for(i=0;i<10;i++)
{
n=rand()%2000;
random[i]=(float)(n-1000)/(float)100.0;
printf(“random?n?=?%f?\n“random[i]);
}
}
void?circle(float?radious)
{
float?step?=0.1;
float?anglexy;
glBegin(GL_POLYGON);
for(angle?=?0.0?;?angle?<=(2.0?*?3.14159)?;?angle?+=step?)
{
x=radious?*?sin(angle);
y=radious?*?cos(angle);
glVertex3f(xy0.0);
}
glEnd();
}
void?bottle()
{
static?GLfloat?whiteAmbient[]={0.1?0.1?0.3?1.0};
static?GLfloat?redAmbient[]={1.0?0.05?0.05?1.0};
static?GLfloat?greenAmbient[]={0.1?0.3?0.1?1.0};
static?GLfloat?blueAmbient[]={0.1?0.1?0.3?1.0};
static?GLfloat?whiteDiffuse[]={1.0?1.0?1.0?1.0};
static?GLfloat?redDiffuse[]={1.0?0.0?0.0?1.0};
static?GLfloat?greenDiffuse[]={0.0?1.0?0.0?1.0};
static?GLfloat?blueDiffuse[]={0.0?0.0?1.0?1.0};
static?GLfloat?whiteSpecular[]={1.0?1.0?1.0?1.0};
static?GLfloat?redSpecular[]={1.0?0.0?0.0?1.0};
static?GLfloat?greenSpecular[]={0.0?1.0?0.0?1.0};
static?GLfloat?blueSpecular[]={0.0?0.0?1.0?1.0};
glPushMatrix();
glPushAttrib(GL_LIGHTING_BIT);
glMaterialfv(GL_FRONT_AND_BACK?GL_AMBIENT?whiteAmbient);
glMaterialfv(GL_FRONT_AND_BACK?GL_DIFFUSE?whiteDiffuse);
glMaterialfv(GL_FRONT_AND_BACK?GL_SPECULAR?whiteSpecular);
//auxSolidCylinder(0.06?0.1);
glRotatef(-90?1.0?0.0?0.0);//測試
circle(0.05);
glRotatef(90?1.0?0.0?0.0);//測試
glTranslatef(0.0?-0.9?0.0);
auxSolidCylinder(0.05?0
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????27852??2010-07-10?22:27??OpenGL小程序\work.cpp
?????文件?????282738??2010-07-10?22:25??OpenGL小程序\work.exe
?????文件?????960054??2010-06-22?22:46??OpenGL小程序\floor.bmp
?????文件????1880118??2010-06-23?15:58??OpenGL小程序\ceiling.bmp
?????文件?????????13??2010-07-10?22:28??OpenGL小程序\readme.txt
?????目錄??????????0??2010-07-10?22:27??OpenGL小程序
-----------?---------??----------?-----??----
??????????????3150775????????????????????6
評論
共有 條評論