【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解决方法:

相关内容

热门资讯

黑科技系统"微扑克系... 黑科技系统"微扑克系统发牌规律!外挂透明挂辅助神器(黑科技)必胜教程"总是是有挂1、让任何用户在无需...
安装辅助挂(德扑)ai代打可靠... 安装辅助挂(德扑)ai代打可靠(AI)ai代打可靠(本来真的是有挂);进入游戏-大厅左侧-新手福利-...
黑科技中牌率"德州之... 黑科技中牌率"德州之星有没有外挂!外挂透明挂辅助挂(黑科技)玩家教你"果然真的有挂德州之星有没有外挂...
好牌辅助挂(德州)ai软件购买... 好牌辅助挂(德州)ai软件购买(Ai)线上外挂(好像是真的有挂)是一种具有地方特色的麻将游戏,要想赢...
黑科技总结"wepo... 黑科技总结"wepoke辅助多久会检测到!外挂透明挂辅助工具(黑科技)2025版教程"果然是有挂;1...
教程辅助挂(德州)外挂(Ai)... 教程辅助挂(德州)外挂(Ai)有透视外挂(果然真的有挂)一、软件透明挂的定义与意义1、系统规律的概念...
黑科技能赢"wepo... 黑科技能赢"wepoke有挂!外挂透明挂辅助工具(黑科技)揭秘教程"切实是真的有挂1、完成wepok...
真的辅助挂(德扑)ai代打(A... 真的辅助挂(德扑)ai代打(AI)ai代打怎么弄(一贯真的是有挂);1、系统规律教程、辅助透视等服务...
黑科技肯定"wepo... 黑科技肯定"wepoke辅助从哪里下载!外挂透明挂辅助系统(黑科技)新2025版"果然是真的有挂1、...
规律辅助挂(德州ai)app辅... 规律辅助挂(德州ai)app辅助器怎么用(Ai)ai辅助(原来存在有挂)1、实时开挂更新:用户可以随...