mac 下 用 glfw3 搭建opengl开发环境
- 下载编译 glfw3
- Build Setting 里面,
- Library Search Paths -> 设置好编译 glfw 库的路径
- Header Search Paths -> 添加 glfw 头文件路径
- other link flag 添加 -> -lglfw3
- glfw 需要依赖 Cocoa CoreVideo IOKit OpenGL 这4个framework.
- 测试
直接参考 glfw doc
- 打印硬件信息:
cout << "硬件信息为:" << endl;
cout << "OpenGL Vendor:" << glGetString(GL_VENDOR) << endl;
cout << "OpenGL Renderer: " << glGetString(GL_RENDERER) << endl;
cout << "OpenGL Version: " << glGetString(GL_VERSION) << endl;
cout << "GLSL Version:" << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
cout << "------------------------------------------------------" << endl;
- 解决retinal屏显示:
GLint viewPort[4];
glGetIntegerv(GL_VIEWPORT, viewPort);
glViewport(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);