【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透明挂(透视)we... WePoKe透明挂(透视)wepoke软件透明挂下载(详细辅助大神讲解)竟然存在有挂(可靠透明挂)1...
WPK透视辅助!wpk ai检... WPK透视辅助!wpk ai检测(透视)外挂透明挂辅助插件(一贯存在有挂)1、玩家可以在软件透明挂俱...
微扑克ai机器人(微扑克)微扑... 微扑克ai机器人(微扑克)微扑克到底有没有辅助器(透视)切实是有挂(详细辅助解密教程)亲,关键说明,...
aapoker发牌机制!aap... aapoker发牌机制!aapoker有手游版吗,(aa扑克有外挂)切实真的有挂(详细辅助必胜教程)...
科技新动态!手机德州app辅助... 您好,微扑克ai机器人这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在...
wpk俱乐部!wpk俱乐部开挂... wpk俱乐部!wpk俱乐部开挂实锤(透视)外挂透视挂辅助挂(固有真的是有挂);实战中需综合运用上述技...
微扑克系统发牌规律(微扑克)微... 微扑克系统发牌规律(微扑克)微扑克怎么用ai辅助(透视)真是是有挂(详细辅助透明教程)1、实时微扑克...
WePoKe外 挂(透视)we... WePoKe外 挂(透视)wepoke app系统规律(详细辅助详细教程)果然是有挂(玩家是真的有挂...
aapoker发牌机制!aap... aapoker发牌机制!aapoker用外挂会被封号吗,(aapoker后台)素来是真的有挂(详细辅...
重大通报!wpk德州ai机器人... 重大通报!wpk德州ai机器人,德州ai辅助,我来教教你(本然是有挂)德州ai机器人辅助器中分为三种...