mac osx中使用CodeLite的OpenGL,GLFW编译环境配置
来源:互联网 发布:java中cipher用法 编辑:程序博客网 时间:2024/05/22 09:43
配完openCV配openGL,历史真是惊人的相似……CodeLite的OpenCV环境配置
mac系统自带OpenGL,本来想用glut,然而编译报错说glut已经被osx10.9的系统弃用了。搜索了一下,推荐较多的是glfw,看了下代码也和glut差不多。
首先,为了预防日后不时之需,先存一下网上找的glut版本的代码:
#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(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char ** argv) { glutInit(&argc, argv); glutCreateWindow("Glut Demo"); glutDisplayFunc(display); glutMainLoop(); }
接下来是glfw的配置。
1.使用homebrew安装glfw(真的超方便!)
brew install glfw
2.GLFW的示例代码
#include <GLFW/glfw3.h> int main(int argc, char ** argv){ GLFWwindow* window; /* Initialize the library */ if (!glfwInit()) return -1; /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(480, 320, "Hello World", NULL, NULL); if (!window) { glfwTerminate(); return -1; } /* Make the window's context current */ glfwMakeContextCurrent(window); /* Loop until the user closes the window */ while (!glfwWindowShouldClose(window)) { /* Draw a triangle */ glBegin(GL_TRIANGLES); glColor3f(1.0, 0.0, 0.0); // Red glVertex3f(0.0, 1.0, 0.0); glColor3f(0.0, 1.0, 0.0); // Green glVertex3f(-1.0, -1.0, 0.0); glColor3f(0.0, 0.0, 1.0); // Blue glVertex3f(1.0, -1.0, 0.0); glEnd(); /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); } glfwTerminate(); return 0;}
3.编译与链接
编译选项
gcc main.c -framework OpenGL -I/usr/local/include/ -L/usr/local/lib/ -lglfw
有四项必须的内容:
-framework用来链接mac自带的OpenGL
-I的路径为头文件目录(I即为Include的缩写)
-L的路径为动态链接库目录(L即为Linker的缩写)
-lxxx表示链接libxxx.dylib的文件,比如libglfw.dylib,就写-lglfw
Codelite的设置
在IDE里进行compiler和linker的相应设置。依然坚持不用Xcode,用的是CodeLite。
右键某个project,点击settings,如图。
编译器头文件设置(即-I),在Include Paths一栏添加路径↓
链接库设置(-L,-l和-framework),更改的是第2、3、4栏↓
0 0
- mac osx中使用CodeLite的OpenGL,GLFW编译环境配置
- mac osx中使用CodeLite的openCV环境配置
- 使用glew、glfw配置OpenGL开发环境
- 使用glew、glfw配置OpenGL开发环境
- Xcode + glfw 配置openGL环境
- macOS下基于GLFW+GLAD的OpenGL环境配置
- Mac OSX 中java7 java8环境的配置
- Mac OSX 中java7 java8环境的配置
- codelite link mac osx framework
- VS2013+GLFW+GLEW 配置OpenGL开发环境
- Golang glfw中使用opengl库的问题
- 【OpenGL】GLFW配置
- 在mac下使用glfw进行OpenGL编程
- openGL编程-环境配置(glfw;glew;glm相关 )
- VS2015 OpenGL开发环境简单配置 glfw + glad
- Cmake 编译opengl开源库glfw工程及使用
- Window平台OpenGL渲染环境之使用GLFW搭建
- MAC OSX环境下cordova+Ionic的安装配置
- Codevs 2602 最短路径问题
- mysql的exists与inner join 和 not exists与 left join 性能差别惊人
- OI 数论整理
- 字符型图片验证码识别完整过程及Python实现
- Codevs 2989 寻找somebody
- mac osx中使用CodeLite的OpenGL,GLFW编译环境配置
- 两台服务器之间拷贝文件-scp方法
- 初步尝试windowsServer程序
- Codevs 2801 LOL盖伦的蹲草计划
- liquibase入门实战
- 16.1112 模拟考试 T1
- React + webpack 快速搭建项目
- 16.1113 模拟考试T3
- URLDecoder和URLEncoder的使用总结