OpenGL配置(Mac + CLion) Posted on 2017-09-26 | Edited on 2018-07-10 | In C++ , OpenGL | 受人指导配置了OpenGL开发环境,记下备忘 安装库1brew install glew glfw CLion cmake配置12345678910111213141516cmake_minimum_required(VERSION 3.8)project(graph)set(CMAKE_CXX_STANDARD 11)# find libraryfind_library(OPENGL OpenGL)find_library(GLFW glfw)find_library(GLEW glew)# link themlink_libraries(${GLEW} ${GLFW} ${OPENGL})set(SOURCE_FILES main.cpp)add_executable(graph ${SOURCE_FILES}) 写代码1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include <iostream>#include <GL/glew.h>#include <GLFW/glfw3.h>const int SCR_WIDTH = 800;const int SCR_HEIGHT = 600;int main(){ // glfw: initialize and configure glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); // glad: load all OpenGL function pointers GLenum err = glewInit(); if(err != GLEW_OK) { std::cout << "glewInit failed: " << glewGetErrorString(err) << std::endl; exit(1); } // render loop while (!glfwWindowShouldClose(window)) { // input // ...... // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) glfwSwapBuffers(window); glfwPollEvents(); } // glfw: terminate, clearing all previously allocated GLFW resources. glfwTerminate(); return 0;} 学习资源https://learnopengl-cn.github.io/