【OpenGL】xcode+glfw画三角形
创始人
2024-09-25 07:26:54
0

环境搭建

1. 执行brew install glfw

2. 项目中Build Settings中header Search Paths中添加glfw的include路径(/opt/homebrew/Cellar/glfw/3.4/include)

3. 项目中Build Phases中的Link Binary With Libraries中添加glfw的lib文件(路径/opt/homebrew/Cellar/glfw/3.4/lib/libglfw.3.4.dylib)及opengl.framework

代码实现

#include   int main(void) {     GLFWwindow* window;      /* Initialize the library */     if (!glfwInit())         return -1;      /* Create a windowed mode window and its OpenGL context */     window = glfwCreateWindow(640, 480, "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))     {         /* Render here */         glClear(GL_COLOR_BUFFER_BIT);          glBegin(GL_TRIANGLES);         glVertex2f(0, 0.5f);         glVertex2f(-0.5f, -0.5f);         glVertex2f(0.5f, -0.5f);         glEnd();                  /* Swap front and back buffers */         glfwSwapBuffers(window);          /* Poll for and process events */         glfwPollEvents();     }      glfwTerminate();     return 0; } 

[错误]

在一个电脑遇到错误 dyld: Library not loaded: /usr/local/opt/glfw/lib/libglfw.3.dylib

根据c++ - Trying to setup Xcode with OpenGL - Stack Overflow解决方法:

相关内容

热门资讯

黑科技肯定(wepoke真的有... 黑科技肯定(wepoke真的有挂)wepoke软件太假了(wepoker)原生真的有挂(果真有挂)-...
黑科技辅助(wepoke智能a... 黑科技辅助(wepoke智能ai)德扑之星可以带出记分牌(透视)细节揭秘(2025已更新)(哔哩哔哩...
总算了解!wopoker辅助(... 总算了解!wopoker辅助(透视)外挂透明挂辅助工具(2022已更新)(哔哩哔哩)1、wopoke...
玩家必看科普!(pokenow... 玩家必看科普!(pokenow)德扑之星怎么设置埋牌(2025已更新)(哔哩哔哩)是一款可以让一直输...
黑科技最新!wpk数据统计软件... 黑科技最新!wpk数据统计软件(透视)一直是有挂(2021已更新)(哔哩哔哩)运wpk数据统计软件辅...
黑科技辅助(wepoke智能a... 1、黑科技辅助(wepoke智能ai)德扑之星软件透明软件(透视)2025新版教程(2023已更新)...
黑科技模拟器(wepoke智能... 黑科技模拟器(wepoke智能ai)wepoke透视挂靠谱吗(WepOke)总是真的有挂(有挂技巧)...
黑科技规律!微扑克辅助机器人(... 黑科技规律!微扑克辅助机器人(透视)外挂透明挂辅助插件(2024已更新)(哔哩哔哩)微扑克辅助机器人...
玩家必看科普!(wpk线上)德... 玩家必看科普!(wpk线上)德扑ai智能机器人线上代打(2025已更新)(哔哩哔哩);人气非常高,a...
黑科技挂!wepoke辅助技巧... 黑科技挂!wepoke辅助技巧(透视)确实真的有挂(2025已更新)(哔哩哔哩);所有人都在同一条线...