資源簡介
華科圖形學作業,正六面體平行投影,邊長為1的正六面體,進行平移、比例、旋轉后,向x,y平面進行平行投影,并繪出投影圖
代碼片段和文件信息
#include?
#include
int?ModeFlag=0;
int?ShadeFlag=0;
static?const?float?vertex_list1[][3]?=?
{?
-1.0f?-1.0f?-1.0f?
1.0f?-1.0f?-1.0f?
-1.0f?1.0f?-1.0f?
1.0f?1.0f?-1.0f?
-1.0f?-1.0f?1.0f?
1.0f?-1.0f?1.0f?
-1.0f?1.0f?1.0f?
1.0f?1.0f?1.0f?
};?
typedef?struct?ColorRGB
{
GLfloat?r;
GLfloat?g;
GLfloat?b;
};
const?ColorRGB?colors[4]=
{
{135.0226.056.0}
{175.0226.016.0}
{35.0216.026.0}
{115.076.0216.0}
};
static?const?GLint?index_list[][2]?=?
{?
{0?1}????
{2?3}????
{4?5}????
{6?7}????
{0?2}????
{1?3}????
{4?6}????
{5?7}
{0?4}
{1?5}
{7?3}
{2?6}
};?
void?DrawCube()
{
int?ij;
glBegin(GL_LINES);?
//gluPerspective(60.0f?aspect?1.0f?200.0f);?
for(i=0;?i<12;?++i)?
{
for(j=0;?j<2;?++j)?
{
glColor3ub(colors[i*j%3].rcolors[i*j%3].gcolors[i*j%3].b);//以255為最大
glVertex3fv(vertex_list1[index_list[i][j]]);?????
}
}
glEnd();
glPushMatrix();
glTranslatef(5.00.00.0);
glRotatef(45?0?0?1);
glBegin(GL_LINES);
for(i=0;?i<12;?++i)?
{
for(j=0;?j<2;?++j)?
{
glColor3ub(color
評論
共有 條評論