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

相关内容

热门资讯

透视插件!来玩app破解,广丰... 透视插件!来玩app破解,广丰510k同城游攻略(一直是有挂)广丰510k同城游攻略辅助器中分为三种...
透视安卓版!hhpoker辅助... 透视安卓版!hhpoker辅助软件,hhpoker有透视功能吗(详细辅助德州论坛);1.hhpoke...
透视计算“wepoker底牌透... 透视计算“wepoker底牌透视脚本怎样安装”总是真的有挂(辅助挂)详细辅助安装教程1、操作简单,无...
透视美元局!德普之星辅助器,卡... 透视美元局!德普之星辅助器,卡五星游戏有挂吗,可靠教程(有挂解说)1、用户打开应用后不用登录就可以直...
红龙poker辅助!hhpok... 一、hhpoker免费透视脚本简介了解软件请加微:136704302hhpoker免费透视脚本是一款...
透视真的!wpk插件,情怀游戏... 透视真的!wpk插件,情怀游戏辅助器破解版,专业教程(有挂脚本)在进入情怀游戏辅助器破解版辅助挂后,...
透视系统!wepoker轻量版... 透视系统!wepoker轻量版书签,悠悠辅助器(本来是有挂);1、上手简单,内置详细流程视频教学,新...
透视总结!wepoker透视脚... 透视总结!wepoker透视脚本下载,fishpoker透视(详细辅助总结教程);wepoker透视...
透视黑科技“aapoker透视... 透视黑科技“aapoker透视脚本下载”切实是真的有挂(辅助挂)详细辅助必胜教程1. ai辅助创建新...
aapoker辅助包!wepo... aapoker辅助包!wepoker手机插件,aapkoer德州辅助挂下载(详细辅助2025教程)1...