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

相关内容

热门资讯

揭秘真相“wpk最新黑科技”w... 揭秘真相“wpk最新黑科技”wpk透手牌测试(WpK)好像存在有挂(有挂教学)-哔哩哔哩1、金币登录...
黑科技脚本“wepokeai代... 黑科技脚本“wepokeai代打”wepoke黑科技靠谱吗(透明黑科技)原来是有挂(有挂工具)-哔哩...
揭秘"aapoker... 揭秘"aapokerai辅助"aapoker有外挂吗(一直是有挂)-哔哩哔哩1、点击下载安装,aap...
我来分享“wpk ai辅助”w... 我来分享“wpk ai辅助”wpkai辅助软件推荐(WPK)从前是真的有挂(有挂猫腻)-哔哩哔哩;我...
黑科技教程“wepoke有没有... 黑科技教程“wepoke有没有挂”wepoke有规律吗(黑科技ai)其实是真的有挂(确实有挂)-哔哩...
玩家必看科普"aap... 玩家必看科普"aapoker发牌机制"AApoker辅助(都是真的是有挂)-哔哩哔哩;1、aapok...
玩家必备攻略“wpk ai辅助... 玩家必备攻略“wpk ai辅助”wpk辅助Dppoker(wPk)都是真的有挂(真是有挂)-哔哩哔哩...
黑科技总结“wepoke黑科技... 黑科技总结“wepoke黑科技”wepoke有透视挂吗(ai辅助)总是是真的有挂(有挂分析)-哔哩哔...
玩家必看攻略"aap... 玩家必看攻略"aapokerai辅助"aapokerai辅助(切实真的是有挂)-哔哩哔哩;1、点击下...
发现一款!“wpk ai辅助”... 发现一款!“wpk ai辅助”wpk德州ai机器人(wpK)一直是真的有挂(有挂解惑)-哔哩哔哩;一...