首页 > 代码库 > 学习opengl(起步)

学习opengl(起步)

库可以在这里下载

第一个程序:

#ifndef GLUT_DISABLE_ATEXIT_HACK  #define GLUT_DISABLE_ATEXIT_HACK #endif  #include <stdio.h>#include <gl/glut.h>void init(){    glClearColor(1.0,1.0,1.0,0.0);    glMatrixMode(GL_PROJECTION);    gluOrtho2D(0.0,200.0,0.0,150.0);}void lineSegment(){    glClear(GL_COLOR_BUFFER_BIT);    glColor3f(1.0,0.0,0.0);    glBegin(GL_LINES);        glVertex2i(180,15);        glVertex2i(10,145);    glEnd();    glFlush();}void main(int argc,char **argv){    glutInit(&argc,argv);    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);    glutInitWindowPosition(50,100);    glutInitWindowSize(400,300);    glutCreateWindow("第一个程序");    init();    glutDisplayFunc(lineSegment);    glutMainLoop();}

 

学习opengl(起步)