绘制矩形

简单的opengl程序入门:

#include"gl/glut.h"
void initial(void)
{
    glClearColor(1.0f,1.0f,1.0f,1.0f);
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(0.0,200.0,0.0,150.0);
}

void Display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0f,0.0f,0.0f);
    glRectf(50.0f,100.0f,150.0f,50.0f);
    glFlush();
}
int main(int argc,char *argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(400,300);
    glutInitWindowPosition(100,120);
    glutCreateWindow("╬ьпн");
    glutDisplayFunc(Display);
    initial();
    glutMainLoop();
    return 0;
}
View Code

 

posted @ 2015-03-28 17:33  Run_For_Love  阅读(200)  评论(0编辑  收藏  举报