【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辅助购买,wp... 透视代打!wpk辅助购买,wpk有没有脚本,如何分辨真伪(有挂规律);wpk有没有脚本辅助插件是一个...
aapoker辅助工具!德州微... aapoker辅助工具!德州微扑克辅助(透视)一贯存在有挂(详细辅助一起来讨论);致您一封信;亲爱德...
透视规律!德普之星透视辅助io... 透视规律!德普之星透视辅助ios,德朴之星脚本,细节揭秘(有挂黑科技)1、德普之星透视辅助ios系统...
wepoker辅助透视软件!w... wepoker辅助透视软件!wepoker怎么挂飞机(透视)一直是有挂(玩家教你);1、不需要AI权...
透视新版!wepoker透视脚... 透视新版!wepoker透视脚本下载,wepoker辅助器是真的的吗,玩家必看科普(有挂规律)是一款...
德扑ai智能机器人!aapok... 德扑ai智能机器人!aapoker俱乐部(透视)真是有挂(详细辅助分享实测)1、许多玩家不知道德扑a...
透视新版!aapoker辅助包... 透视新版!aapoker辅助包,智星德州菠萝插件官网,必赢教程(有挂详情)智星德州菠萝插件官网是一种...
红龙poker作弊指令!德州局... 红龙poker作弊指令!德州局hhpoker(透视)确实真的有挂(新2025版)1、完成红龙poke...
透视线上!wepoker透视脚... 透视线上!wepoker透视脚本免费下载,德普之星透视辅助软件下载,热门推荐(有挂总结)1.德普之星...
aapoker辅助!wepok... aapoker辅助!wepok软件透明挂(透视)原本真的有挂(详细辅助分享给玩家);一、wepok软...