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

相关内容

热门资讯

一分钟辅助(兴动互娱辅助脚本下... 一分钟辅助(兴动互娱辅助脚本下载)一贯存在有挂(详细辅助实用技巧)1、首先打开兴动互娱辅助脚本下载最...
揭秘一下“丰城双剑辅助”果然真... 揭秘一下“丰城双剑辅助”果然真的有挂(辅助挂)详细辅助必备教程1、下载好辅助软件之后点击打开,先需要...
透视教程!桂林字牌辅助科技,h... 透视教程!桂林字牌辅助科技,hhpoker辅助软件是真的么,微扑克教程(有挂方法);支持多人共享记分...
一分钟揭秘“一起宁德麻将辅助”... 一分钟揭秘“一起宁德麻将辅助”果然有挂(辅助挂)详细辅助AI教程1、下载好辅助软件之后点击打开,先需...
第一分钟辅助(一起宁德钓蟹辅助... 第一分钟辅助(一起宁德钓蟹辅助器)真是有挂(详细辅助攻略教程)1、一起宁德钓蟹辅助器ai机器人多个强...
透视计算!手机奇迹辅助工具,新... 透视计算!手机奇迹辅助工具,新荣耀平台辅助,专业教程(有挂透明);科技安装教程;136704302。...
3分钟辅助(潮汕娱手机暗宝透视... 3分钟辅助(潮汕娱手机暗宝透视)确实真的是有挂(详细辅助安装教程);1、完成潮汕娱手机暗宝透视透视辅...
透视好友!爱来大菠萝怎么玩,福... 您好,福建天天开心辅助工具这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩...
解密关于“胡易决胜麻架辅助”果... 解密关于“胡易决胜麻架辅助”果然是真的有挂(辅助挂)详细辅助专业教程1、机器人多个强度级别选择2、发...
两分钟辅助(和和营口辅助)一贯... 两分钟辅助(和和营口辅助)一贯是真的有挂(详细辅助科技教程)1、打开软件启动之后找到中间准星的标志长...