【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)wop... 透视好牌(wEpOke)wopoker轻量版外挂(透视)详细辅助必赢教程;玩家必备必赢加哟《1367...
aapoker透明挂!德扑软件... aapoker透明挂!德扑软件决策(透视)果然是有挂(详细辅助线上教程)1)aapoker透明挂辅助...
透视安卓版!wepokeai机... 透视安卓版!wepokeai机器人,wepoke app,详细透视德州教程wepokeai机器人软件...
透视软件!wpk透视辅助(透视... 透视软件!wpk透视辅助(透视)详细辅助切实教程(一贯真的有挂)1、游戏颠覆性的策略玩法,独创攻略技...
透视计算(WEPOKE)德扑软... 1、透视计算(WEPOKE)德扑软件高端(透视)详细辅助科技教程;详细教程。2、德扑软件高端透视辅助...
德扑之星猫腻!wpk数据统计软... 德扑之星猫腻!wpk数据统计软件会不会被封号(透视)最初有挂(详细辅助细节揭秘)1、这是跨平台的德扑...
透视挂透视!WePoKe透视挂... 透视挂透视!WePoKe透视挂,wopoker分析器,详细透视技巧教程1、游戏颠覆性的策略玩法,独创...
透视系统!智星德州菠萝插件官网... 透视系统!智星德州菠萝插件官网(透视)详细辅助wepoke教程(原来是有挂)1、起透看视 智星德州菠...
透视玄学(wePoke)德州之... 透视玄学(wePoke)德州之星ai软件(透视)详细辅助透牌教程;科技安装教程;136704302。...
wepoke模拟器!微扑克wp... wepoke模拟器!微扑克wpk辅助软件(透视)本来真的是有挂(详细辅助系统教程)1、很好的工具软件...