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

相关内容

热门资讯

透视脚本!wepoker透视脚... 透视脚本!wepoker透视脚本免费"wepoke真的有挂吗"(一贯真的有挂)1、任何wepoker...
9分钟分享!竞技联盟破解版最新... 9分钟分享!竞技联盟破解版最新版(都是真的有挂)详细教程(有挂方法)-哔哩哔哩1、让任何用户在无需竞...
一分钟了解!uupoker有透... 一分钟了解!uupoker有透视吗,hhpoker免费透视脚本,详细教程(有挂教学)1、完成hhpo...
透视脚本!wpk辅助插件&qu... 透视脚本!wpk辅助插件"扑克王有没有辅助软件"(果真真的有挂)1、下载好wpk辅助插件辅助软件之后...
七分钟解密!wpk官网下载链接... 七分钟解密!wpk官网下载链接(其实真的有挂)详细教程(有挂方法)-哔哩哔哩1、该软件可以轻松地帮助...
盘点一款!wepoker辅助分... 盘点一款!wepoker辅助分析器,wpk德州局透视,详细教程(有挂攻略)1、每一步都需要思考,不同...
透视脚本!佛手在线有挂吗&qu... 透视脚本!佛手在线有挂吗"wpk微扑克俱乐部"(就是真的有挂)佛手在线有挂吗辅助器中分为三种模型:佛...
推荐一款!wepoker俱乐部... 推荐一款!wepoker俱乐部辅助,德扑圈透视,详细教程(有挂教学)1、金币登录送、破产送、升级送、...
8分钟分析!hhpoker辅助... 8分钟分析!hhpoker辅助软件下载(的确真的有挂)详细教程(有挂教程)-哔哩哔哩;亲,关键说明,...
重磅来袭!来玩app破解版,w... 重磅来袭!来玩app破解版,wepoker手机版透视脚本,详细教程(有挂教程);1、wepoker手...