本文出自:点击打开链接
绘制一个红色填充色的矩形(Windows_glut)
#include <gl\glut.h> #include <windows.h> #include <gl\GL.h> #include <gl\GLU.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.f, 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; }
原文地址:http://blog.csdn.net/svitter/article/details/39319865