您的位置:首页 > 运维架构

mac OpenGL 开发环境搭建

2016-06-27 09:06 381 查看
1 OpenGL需要搭配一些窗口库来做,比如Qt、MFC等,或者用跨平台的GLUT。mac自带GLUT和opengl。

2 创建os x的Application。选择command line tool。

3 在target的build phases里面将GLUT.framework和OpenGL.framework添加进来。

4测试代码(绘制一个三角形):

#include <iostream>

#include <GLUT/GLUT.h>

void display()

{

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_TRIANGLES);

glColor3f(1,0,0);

glVertex2f(-0.5, -0.5);

glColor3f(0,1,0);

glVertex2f(-0.5, 0.5);

glColor3f(0,0,1);

glVertex2f(0.5, 0.5);

glEnd();

glFlush();

}

int main(int argc, char ** argv)

{

std::cout << "Hello, World!\n";

glutInit(&argc, argv);

glutCreateWindow("hello world opengl");

glutDisplayFunc(display);

glutMainLoop();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: