【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私人局可以透视(透视)底牌透视挂辅助神器(可靠开挂辅助大神讲解)-哔哩哔哩;...
透视免费!wepokerplu... 透视免费!wepokerplus开挂,武陵游辅助器,2025新版总结(有挂助手)-哔哩哔哩1)武陵游...
第9分钟了解!微信多乐跑得快能... 第9分钟了解!微信多乐跑得快能不能开挂(辅助挂)竟然有挂(专业辅助黑科技教程)-哔哩哔哩;第9分钟了...
黑科技辅助!来玩app辅助工具... 您好:来玩app辅助工具这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的...
透视讲解!hhpoker一直输... 您好,hhpoker一直输有挂这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很...
2分钟了解!哈狗13道有外挂(... 2分钟了解!哈狗13道有外挂(辅助挂)其实是真的有挂(专业辅助玩家教程)-哔哩哔哩;作为哈狗13道有...
透视辅助!wepoker破解器... 透视辅助!wepoker破解器,创乐源辅助软件,可靠技巧(果真有挂)-哔哩哔哩进入游戏-大厅左侧-新...
黑科技辅助!德扑之星真的太假了... 您好,德扑之星真的太假了这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家...
透视新版!hhpoker辅助挂... 透视新版!hhpoker辅助挂是真的(透视)底牌透视挂辅助app(可靠开挂辅助普及教程)-哔哩哔哩;...
透视教程!hhpoker有透视... 透视教程!hhpoker有透视功能,广东老友辅助,可靠教程(详细教程)-哔哩哔哩1、起透看视 广东老...