【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辅助软件价格(透视)wepoker能不能透视(切实真的有挂)wepoker辅...
透视计算!德州透视脚本(透视)... 透视计算!德州透视脚本(透视)黑科技教程(2020已更新)(哔哩哔哩)1、用户打开应用后不用登录就可...
透视苹果版!wepoker透视... 透视苹果版!wepoker透视脚本(透视)辅助是真的假的(原来是有挂)1、点击下载安装,wepoke...
透视插件!wepokerplu... 透视插件!wepokerplus脚本(透视)wepoker是不是有人用挂(都是有挂)1、wepoke...
透视挂!pokermaster... 透视挂!pokermaster脚本(透视)必胜教程(2022已更新)(哔哩哔哩);1、pokerma...
透视ai代打!wepoker透... 透视ai代打!wepoker透视脚本免费使用视频(透视)辅助透视软件(一直真的是有挂)1、首先打开w...
透视脚本!WePoKer辅助器... 透视脚本!WePoKer辅助器(透视)wepoker脚本下载(竟然是有挂)1、下载好wepoker脚...
透视好友!wepoker有没有... 透视好友!wepoker有没有机器人(透视)有机器人(都是有挂)1、让任何用户在无需wepoker有...
透视存在!哈糖大菠萝有挂吗(透... 透视存在!哈糖大菠萝有挂吗(透视)可靠技巧(2023已更新)(哔哩哔哩);哈糖大菠萝有挂吗辅助器中分...
透视ai!wepokerplu... 透视ai!wepokerplus到底是挂了吗(透视)wepoker私人局透视教程(总是存在有挂);1...