【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透明黑科技!wep... wepoke透明黑科技!wepoke的确有挂(WePoKe黑科技)都是是真的有挂(果真有挂)-哔哩哔...
玩家必备科普!微扑克ai机器人... 玩家必备科普!微扑克ai机器人,微扑克有挂么(微扑克)果然真的是有挂(有挂方法)-哔哩哔哩;1、微扑...
玩家爆料"aapok... 玩家爆料"aapoker辅助工具ai"aapoker挂(切实真的有挂)-哔哩哔哩1、下载好aapok...
WPk最新黑科技!wpk德州辅... WPk最新黑科技!wpk德州辅助(WPK ai辅助)一贯是有挂(2022已更新)(哔哩哔哩)1、系统...
传递经验!微扑克辅助工具怎么下... 传递经验!微扑克辅助工具怎么下载,微扑克如何让系统发好牌(微扑克)竟然是有挂(有挂方法)-哔哩哔哩微...
wepoke真的有挂!wepo... wepoke真的有挂!wepoke软件透明挂价格(WePoKe黑科技)其实是真的有挂(有挂教学)-哔...
推荐一款"aapok... 推荐一款"aapoker辅助工具ai"aapoker辅助工具ai(果然存在有挂)-哔哩哔哩一、aap...
WpK最新黑科技!wpk辅助器... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加威信【136704302】很多玩家在这款游戏中打牌...
每日必备!微扑克ai辅助神器,... 每日必备!微扑克ai辅助神器,微扑克有挂么(微扑克)竟然是有挂(的确有挂)-哔哩哔哩;1、微扑克ai...
wepoke辅助插件!wepo... 您好,wepoke辅助插件这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很...