当前位置: 首页 > news >正文

【OpenGL】xcode+glfw画三角形

环境搭建

1. 执行brew install glfw

2. 项目中Build Settings中header Search Paths中添加glfw的include路径

3. 项目中Build Phases中的Link Binary With Libraries中添加glfw的lib文件(路径/opt/homebrew/Cellar/glfw/3.4/lib/libglfw.3.4.dylib)及opengl.framework

代码实现

#include <GLFW/glfw3.h>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;
}


http://www.mrgr.cn/news/8101.html

相关文章:

  • 《深入浅出WPF》读书笔记.6binding系统(中)
  • 信息学奥赛知识点(八)----计算机网络
  • web前端之选项卡集合、动态添加类名、动态移除类名、动态添加样式、激活、间距、节流、tabBar
  • 2161.根据给定数字划分数组
  • Outlook如何精确搜索邮件?
  • http应用层协议
  • 高德地图SDK Android版开发 8 覆盖物示例2动画
  • Java核心API——File类
  • 程序员:全栈的痛你不知道
  • Spring Boot 中的 starter 是什么
  • 13.订单页面的展示
  • JVM类加载机制—类加载器和双亲委派机制详解
  • HAL库中断处理函数 及 weak弱声明中断回调函数
  • 出现 2003 - Can’t connect to MySQL server on ‘xxx‘(10060) 解决方法
  • 05.C++类和对象(下)
  • Android 息屏录音
  • 速盾:cdn能防止攻击么?
  • 15.CentOS7升级内核
  • C语言 | Leetcode C语言题解之第372题超级次方
  • 链动 2+1 模式小程序 AI 智能名片商城源码培训邀约策略研究