#include<windows.h>
#include<GL/glut.h>
#include<algorithm>
#include<wingdi.h>
void Display(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,1.0f,1.0f);
glRectf(-0.5f,-0.5f,0.5f,0.5f);
glBegin(GL_TRIANGLES);//指定画三角形
glColor3f(1.0f,0.0f,0.0f);//颜色
glVertex2f(0.0f,1.0f);//顶点
glColor3f(0.0f,1.0f,0.0f);//颜色
glVertex2f(0.8f,-0.5f);
glColor3f(0.0f,0.0f,1.0f);//颜色
glVertex2f(-0.8f,-0.5f);
glEnd();
glPointSize(3);//指定点占3个像素
glBegin(GL_POINTS);//指定画点
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-0.4f,-0.4f);
glColor3f(0.0f,1.0f,0.0f);
glVertex2f(0.0f,0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex2f(0.4f,0.4f);
glEnd();
glFlush();
}
int main(int argc,char *argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow("myDEMO");
glutDisplayFunc(Display);//调用绘图函数
glutMainLoop();//进入循环
return 0;
}
实验2
最新推荐文章于 2022-09-01 18:41:50 发布