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

相关内容

热门资讯

aapoker俱乐部(智星德州... aapoker俱乐部(智星德州扑克)wepoke德扑之星(透视辅助)总是真的有挂(有挂下载)-小红书...
一分钟掌握!微扑克有辅助插件(... 一分钟掌握!微扑克有辅助插件(黑科技)外挂透明挂辅助神器(2020已更新)(百度知乎)微扑克有辅助插...
透视辅助挂!德扑ai助手&qu... 透视辅助挂!德扑ai助手"wpk有"的确是有挂的(有挂代打)-知乎德扑ai助手软件透明挂微扑克wpk...
透明辅助(菠萝德州)外挂软件透... 透明辅助(菠萝德州)外挂软件透明插件(辅助挂)一贯真的有挂(2023已更新)(哔哩哔哩);1.菠萝德...
aapoker俱乐部(微扑克)... aapoker俱乐部(微扑克)德扑ai助手软件(黑科技)其实真的有挂(有挂打法)-百度1、任何微扑克...
黑科技辅助挂!德扑之星猫腻&q... 黑科技辅助挂!德扑之星猫腻"来玩德州app外挂"本来真的有挂(有挂私人房)-头条来玩德州app外挂辅...
3分钟普及!微扑克这软件有问题... 3分钟普及!微扑克这软件有问题(辅助挂)外挂透明挂辅助脚本(2024已更新)(知乎)1、完成微扑克这...
德州辅助(aApoker)外挂... 德州辅助(aApoker)外挂软件透明软件(智能ai代打)本来真的有挂(2021已更新)(知乎);1...
德扑之星有猫腻(德州竞技联盟)... 德扑之星有猫腻(德州竞技联盟)德州ai人工智能(透视)其实真的有挂(有挂俱乐部)-微博热搜1、让任何...
透视辅助!aapoker辅助工... 透视辅助!aapoker辅助工具"wpk辅助软件查得出来"果真真的有挂(有挂黑科技)-今日头条wpk...