创建command line 工程,保存。
主要是要添加OpenGL.framework和GLUT.framework到工程中。添加方式,单击工程名,找到build phases-Link Binary with libraries即可添加两个framework了。
#include <iostream>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(