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

相关内容

热门资讯

黑科技插件!wepokeai代... 黑科技插件!wepokeai代打,(wepoker)真是真的是有挂,我来教教你(有挂规律)1、不需要...
黑科技辅助挂!WEPoke软件... 黑科技辅助挂!WEPoke软件透明挂,wePOke透明挂软件价格,详细教程(有挂技巧);1、金币登录...
wpk有德州外挂吗(WPK)w... wpk有德州外挂吗(WPK)wpk发牌逻辑(透视)德州论坛(一直是真的有挂)1、wpk有德州外挂吗(...
黑科技辅助!微扑克wpk透视辅... 黑科技辅助!微扑克wpk透视辅助,微扑克算正规平台吗,新版2025教程(原先有挂);最新版2024是...
黑科技透明!wepoke调控参... 黑科技透明!wepoke调控参数,(wepoKE)原来真的是有挂,安装教程(有挂解密);1、这是跨平...
黑科技辅助挂!wopoker软... 黑科技辅助挂!wopoker软件透明挂,wePOke透明挂使用教程,科技教程(有挂工具)1、完成wo...
微扑克辅助器ios(微扑克)微... 微扑克辅助器ios(微扑克)微扑克俱乐部设置(辅助挂)揭秘攻略(总是真的是有挂)1、首先打开微扑克辅...
黑科技辅助!wpk有德州外挂吗... 黑科技辅助!wpk有德州外挂吗,wpk有吗,AI教程(一向真的有挂);亲真的是有正版授权,小编(透视...
智能ai辅助挂!德扑ai助手,... 智能ai辅助挂!德扑ai助手,(德扑ai)果然存在有挂,系统教程(有挂教程)智能ai辅助挂!德扑ai...
wpk透视外挂会怎么样(Wpk... wpk透视外挂会怎么样(Wpk)wpk线上德州俱乐部(透视)可靠技巧(确实是有挂);1、金币登录送、...