glBegin(GL_POLYGON);
glVertex2f(0.0,0.0);
glVertex2f(0.0,3.0);
glVertex2f(3.0,3.0);
glVertex2f(4.0,1.5);
glVertex2f(3.0,0.0);
glEnd();
glVertex2f(2.0f,3.0f);//二维坐标定义顶点;
void glPointSize(GLfloat size);
void line2i(GLint x1,GLint y1,GLint x2,GLint y2)
{
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glEnd();
}
glLineStipple (1, 0x1C47); /* 虚点线 */
glEnable(GL_LINE_STIPPLE);
glColor3f(0.0,1.0,0.0);
line2i (450 , 250 , 600 , 250 );
photoshop教程 数据结构 五笔输入法专题 QQ病毒专题 共享上网专题 Google工具和服务专题 void glEdgeFlag(GLboolean flag);
void glEdgeFlag(PGLboolean pflag);
void glPolygonMode(GLenum face,GLenum mode);
void glPolygonStipple(const GLubyte *mask);
void CALLBACK display(void)
{
/* 填充模式定义 (32x32) */
GLubyte pattern[]= {
0x00, 0x01, 0x80, 0x00,
0x00, 0x03, 0xc0, 0x00,
0x00, 0x07, 0xe0, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x00, 0x1f, 0xf8, 0x00,
0x00, 0x3f, 0xfc, 0x00,
0x00, 0x7f, 0xfe, 0x00,
0x00, 0xff, 0xff, 0x00,
0x01, 0xff, 0xff, 0x80,
0x03, 0xff, 0xff, 0xc0,
0x07, 0xff, 0xff, 0xe0,
0x0f, 0xff, 0xff, 0xf0,
0x1f, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xfc,
0x7f, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0x7f, 0xff, 0xff, 0xfe,
0x3f, 0xff, 0xff, 0xfc,
0x1f, 0xff, 0xff, 0xf8,
0x0f, 0xff, 0xff, 0xf0,
0x07, 0xff, 0xff, 0xe0,
0x03, 0xff, 0xff, 0xc0,
0x01, 0xff, 0xff, 0x80,
0x00, 0xff, 0xff, 0x00,
0x00, 0x7f, 0xfe, 0x00,
0x00, 0x3f, 0xfc, 0x00,
0x00, 0x1f, 0xf8, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x00, 0x07, 0xe0, 0x00,
0x00, 0x03, 0xc0, 0x00,
0x00, 0x01, 0x80, 0x00
};
glClear (GL_COLOR_BUFFER_BIT);
/* 绘制一个指定图案填充的三角形 */
glColor3f(0.9,0.86,0.4);
glPolygonStipple (pattern);
glBegin(GL_TRIANGLES);
glVertex2i(310,310);
glVertex2i(220,80);
glVertex2i(405,80);
glEnd();
glDisable (GL_POLYGON_STIPPLE);
glFlush ();
}
void glFrontFace(GLenum mode);
void getNormal(GLfloat gx[3],GLfloat gy[3],
GLfloat gz[3],GLfloat *ddnv)
{
GLfloat w0,w1,w2,v0,v1,v2,nr,nx,ny,nz;
w0=gx[0]-gx[1]; w1=gy[0]-gy[1];w2=gz[0]-gz[1];
v0=gx[2]-gx[1]; v1=gy[2]-gy[1];v2=gz[2]-gz[1];
nx=(w1*v2-w2*v1);ny=(w2*v0-w0*v2);nz=(w0*v1-w1*v0);
nr=sqrt(nx*nx+ny*ny+nz*nz); //向量单位化。
ddnv[0]=nx/nr; ddnv[1]=ny/nr;ddnv[2]=nz/nr;
}
void glNormal3{bsifd}(TYPE nx,TYPE ny,TYPE nz);
void glNormal3{bsifd}v(const TYPE *v);
void glNewList(GLuint list,GLenum mode);
void glEndList(void);
glDeleteLists() glIsEnable()
glFeedbackBuffer() glIsList()
glFinish() glPixelStore()
glGenLists() glRenderMode()
glGet*() glSelectBuffer()
glNewList(1,GL_COMPILE);
glVertex3fv(v1);
glEndList();
glNewList(2,GL_COMPILE);
glVertex3fv(v2);
glEndList();
glNewList(3,GL_COMPILE);
glVertex3fv(v3);
glEndList();
glNewList(4,GL_COMPILE);
glBegin(GL_POLYGON);
glCallList(1);
glCallList(2);
glCallList(3);
glEnd();
glEndList();
新闻热点
疑难解答