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

相关内容

热门资讯

7分钟透视!wpk透视挂最怕三... 7分钟透视!wpk透视挂最怕三个东西,wejoker透视方法(透视)教你教程(详细教程)1、7分钟透...
黑科技计算!wpk有机器人,红... 黑科技计算!wpk有机器人,红龙扑克辅助器,爆料教程(有挂秘笈)-哔哩哔哩;1、不需要AI权限,帮助...
第七分钟领会!wepoker怎... 第七分钟领会!wepoker怎么设置盖牌,aapoker辅助是真的吗(透视)必赢教程(的确有挂)we...
黑科技app!wepoke算法... 黑科技app!wepoke算法,德扑之星的发牌是有问题,软件教程(有挂详细)-哔哩哔哩;亲真的是有正...
第十分钟透明挂!wpk辅助器是... 第十分钟透明挂!wpk辅助器是真的吗,uupoker透视(透视)揭秘攻略(新版有挂)亲,关键说明,w...
一分钟了解!德州微扑克辅助神器... 一分钟了解!德州微扑克辅助神器app,微扑克ai辅助器下载,技巧教程(有挂秘笈)-哔哩哔哩;1.德州...
第五分钟了解!hhpoker透... 第五分钟了解!hhpoker透视功能如何下载,拱趴大菠萝开挂方法(透视)新2025教程(证实有挂)1...
辅助黑科技!wepoke用模拟... 辅助黑科技!wepoke用模拟器,德州AI智能辅助机器人,教你攻略(有挂方略)-哔哩哔哩;超受欢迎的...
两分钟发现!wepoker免费... 两分钟发现!wepoker免费脚本弱密码,aapoker脚本怎么用(透视)攻略教程(确实有挂)1、全...
科普常识!微扑克软件的规律,德... 科普常识!微扑克软件的规律,德州之星有辅助挂,必备教程(有挂总结)-哔哩哔哩;大家肯定在之前德州之星...