【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透明黑科技!wep... wepoke透明黑科技!wepoke透明挂软件(WePoKe黑科技)总是真的有挂(有挂教学)-哔哩哔...
wPK最新黑科技!wpk俱乐部... wPK最新黑科技!wpk俱乐部外挂(WPK ai辅助)切实存在有挂(2020已更新)(哔哩哔哩)1、...
一起来讨论"aapo... 一起来讨论"aapoker发牌机制"aapoker真的有猫腻吗(竟然存在有挂)-哔哩哔哩所有人都在同...
三分钟了解(德州ai人工智能)... WePoker透视辅助版本稳定性对比与推荐‌:三分钟了解(德州ai人工智能)德州之星辅助器有哪些功能...
wepoke辅助插件!wepo... wepoke辅助插件!wepoke有app软件吗(WePoKe黑科技)原来存在有挂(有挂秘诀)-哔哩...
WpK最新黑科技!德州wepo... WpK最新黑科技!德州wepower透视辅助(WPK ai辅助)先前真的有挂(2021已更新)(哔哩...
分享给玩家"aapo... 分享给玩家"aapoker发牌机制"aapoker辅助工具存在(总是是有挂)-哔哩哔哩1、不需要AI...
一分钟带你了解(德州辅助神器软... 一分钟带你了解(德州辅助神器软件)德州之星可能有外挂吗(起初真的是有挂)-哔哩哔哩相信很多朋友都在电...
wepoke智能ai!wepo... wepoke智能ai!wepoke有挂吗蓝鸟(WePoKe黑科技)原来有挂(有挂方法)-哔哩哔哩1、...
Wpk最新黑科技!wpk数据工... 1、Wpk最新黑科技!wpk数据工具(WPK ai辅助)总是有挂(2023已更新)(哔哩哔哩)。2、...