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

相关内容

热门资讯

让我来分享经验(德州ai辅助软... 让我来分享经验(德州ai辅助软件)德州之星透牌器(原先存在有挂)-哔哩哔哩1、这是跨平台的德州之星透...
黑科技了解“wepoke智能a... 黑科技了解“wepoke智能ai”wepoke软件免费版(透明黑科技)确实真的有挂(发现有挂)-哔哩...
六分钟了解“wpk最新黑科技”... 六分钟了解“wpk最新黑科技”wpk透视外挂(Wpk)原先真的是有挂(有挂细节)-哔哩哔哩1、每个玩...
热点推荐"aapok... 热点推荐"aapoker发牌机制"aapoker外挂购买(总是是有挂)-哔哩哔哩1、这是跨平台的aa...
玩家必备科普(德州ai辅助)德... 玩家必备科普(德州ai辅助)德州ai辅助神器软件怎么使用(固有有挂)-哔哩哔哩;(需添加指定威信13...
黑科技规律“wepoke智能a... 黑科技规律“wepoke智能ai”wepoke有没有挂(软件透明挂)切实有挂(有挂透明挂)-哔哩哔哩...
重大通报!“wpk最新黑科技”... 重大通报!“wpk最新黑科技”微扑克ai辅助(WpK)最初存在有挂(确实有挂)-哔哩哔哩,亲,有的,...
玩家爆料"aapok... 玩家爆料"aapoker辅助工具ai"aapoker有外挂(总是是真的有挂)-哔哩哔哩1、aapok...
交流学习经验(德州ai辅助神器... 交流学习经验(德州ai辅助神器软件)德州ai人工智能(原来真的有挂)-哔哩哔哩;德州ai辅助神器软件...
黑科技美元局“wepoke黑科... 黑科技美元局“wepoke黑科技”wepoke小技巧(透明黑科技)切实真的有挂(有挂细节)-哔哩哔哩...