openGL 画四边形
glBegin(GL_QUAD_STRIP);//start to draw something // n/2-1 quad // 2n-1 2n 2n+2 2n+1 //1: 1 2 4 3 //2: 3 4 6 5 glColor4ub(255, 0, 0, 255);//每个颜色占8字节 set color: white glVertex3f(0.0f, 0.0f, -10.f); glColor4ub(0, 0, 255, 255);//每个颜色占8字节 set color: white glVertex3f(-5.0, -2.0f, -10.f); glColor4ub(0, 0, 255, 255);//每个颜色占8字节 set color: white glVertex3f(-1.0f, -2.0f, -10.f); glColor4ub(0, 255, 0,255);//每个颜色占8字节 set color: white glVertex3f(-3.0f, -3.0f, -10.f);依次连点,画四边形
glBegin(GL_POLYGON);//start to draw something // glColor4ub(255, 0, 0, 255);//每个颜色占8字节 set color: white glVertex3f(0.0f, 0.0f, -10.f); glColor4ub(0, 0, 255, 255);//每个颜色占8字节 set color: white glVertex3f(-5.0, -2.0f, -10.f); glColor4ub(0, 255, 0, 255);//每个颜色占8字节 set color: white glVertex3f(-3.0f, -3.0f, -10.f); glColor4ub(0, 255, 0, 255);//每个颜色占8字节 set color: white glVertex3f(0.0f, -3.0f, -10.f); glColor4ub(0, 0, 255, 255);//每个颜色占8字节 set color: white glVertex3f(-1.0f, -2.0f, -10.f);
线框模式
//线框模式,画所有图形都画线 glEnable(GL_CULL_FACE); glPolygonMode(GL_FRONT, GL_LINE);
画点模式
glEnable(GL_CULL_FACE); glPolygonMode(GL_FRONT, GL_POINT);
//默认为 glpolygonMode(GL_FRONT, GL_FULL); 填充模式
点变光滑
glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND);
glLoadIdentity();
每次确定为一个单位矩阵
旋转,移动
glScalef(1.0f,1.0f, 0.5f);//缩放,》1 变大, <1缩小 glRotatef(30.0f, 0.0f, 0.0f, 1.0f);//旋转方向判断: 右手握拳,大拇指指向旋转轴方向, 四指弯曲方向,即为旋转方向 glTranslated(1.0f, -1.0f, 0.0f);//移动方向