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

相关内容

热门资讯

推荐几款新版!(红龙软件德州扑... 【福星临门,好运相随】;推荐几款新版!(红龙软件德州扑克)外挂辅助透视app!(aapoker讲解)...
2分钟辅助!红龙扑克记牌器(透... 您好,红龙扑克记牌器这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这...
总算清楚!wpk透视辅助哪里下... 总算清楚!wpk透视辅助哪里下载,微扑克使用方法,2025新版教程(证实有挂)-哔哩哔哩;wpk透视...
第8分钟体悟!wepoker有... 第8分钟体悟!wepoker有透视底牌吗,pokerworld修改器(透视)曝光教程(确实有挂)1)...
一分钟秒懂!(德扑给好牌)外挂... 一分钟秒懂!(德扑给好牌)外挂辅助透视下载!(EV扑克)2025新版教程(2022已更新)(哔哩哔哩...
6分钟辅助挂!微扑克ai技术(... 6分钟辅助挂!微扑克ai技术(透明挂黑科技)外挂透明挂辅助安装(2020已更新)(哔哩哔哩);大家肯...
四分钟黑科技!德州hhpoke... 四分钟黑科技!德州hhpoker是真的吗,wepoker私局代打(透视)wpk教程(有挂解惑)1、在...
重大通报!wepoke有挂,a... 重大通报!wepoke有挂,aapoker插件,新2025版(有挂实锤)-哔哩哔哩;1、这是跨平台的...
2分钟精通!wpk有辅助挂吗(... 2分钟精通!wpk有辅助挂吗(透明挂黑科技)外挂透明挂辅助透视(2021已更新)(哔哩哔哩);wpk...
透视有挂!(aapoker辅助... 透视有挂!(aapoker辅助工具)外挂辅助黑科技!(德扑之星代打)分享教程(2025已更新)(哔哩...