【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辅助德之... 透视神器!wepoke辅助德之星,wepooke系统规律,详细透视规律教程1、下载好wepoke辅助...
透视工具(wEpOke)线上德... 透视工具(wEpOke)线上德州aapoker透明挂(透视)详细辅助微扑克教程是一款可以让一直输的玩...
透视系统!hhpoker辅助器... 透视系统!hhpoker辅助器(透视)详细辅助可靠教程(总是真的有挂)1、hhpoker辅助器机器人...
透视数据!wepoker透视脚... 透视数据!wepoker透视脚本免费app(透视)固有存在有挂(详细辅助大神讲解),支持语音通讯、好...
透视计算!WePoKe透明挂,... 透视计算!WePoKe透明挂,wepoke显示有,详细透视扑克教程;1、不需要AI权限,帮助你快速的...
透视脚本(WepOke)wep... 透视脚本(WepOke)wepower软件(透视)详细辅助辅助教程准备好在wepower软件 ia的...
透视辅助!wepoker透视脚... 透视辅助!wepoker透视脚本网页(透视)详细辅助揭秘攻略(真是存在有挂)1、wepoker透视脚...
透视挂透视!hhpoker开挂... 透视挂透视!hhpoker开挂教程(透视)都是是真的有挂(详细辅助必备教程)关于hhpoker开挂教...
透视黑科技!wepoke黑科技... 透视黑科技!wepoke黑科技,wepoke ai代打辅助,详细透视详细教程1、完成wepoke黑科...
透视计算(wEPoke)wpk... 透视计算(wEPoke)wpk辅助nzt(透视)详细辅助可靠教程1、许多玩家不知道wpk辅助nzt辅...