持续更新(如果这个项目还活着的话)
使用工具:
Google Chrome ( To read the fking manual )
Visual Studio ( 我还需要说嘛 :\ )
OpenGL ( 同上 :/ )
vcpkg ( 真的需要说嘛 )
1 vcpkg install glfw3:x64-windows glfw3:x86-windows glew:x64-windows glew:x86-windows glm:x64-windows glm:x86-windows
使用 vcpkg 安装任何 OpenGL 的扩展和所需依赖
跟着 manual 写到目前我可以说 Intel 已经被针对了 ( 什么 )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 #include <iostream> #include <GL/glew.h> #include <GLFW/glfw3.h> #include <glm/glm.hpp> using namespace std;using namespace glm;int main () { glewExperimental = true ; if (!glewInit ()) { cerr << "ERR: Failed to initialize GLFW" << endl; return 1 ; } glfwWindowHint (GLFW_SAMPLES, 4 ); glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3 ); glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3 ); glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window; window = glfwCreateWindow (1024 , 768 , "Win32 OpenGL Testing" , nullptr , nullptr ); if (window == nullptr ) { cerr << "ERR: Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible" << endl; glfwTerminate (); return 1 ; } glfwMakeContextCurrent (window); glewExperimental = true ; if (glewInit () != GLEW_OK) { cerr << "Failed to initialize GLFW" << endl; return 1 ; } glfwSetInputMode (window, GLFW_STICKY_KEYS, GL_TRUE); do { glClear (GL_COLOR_BUFFER_BIT); glfwSwapBuffers (window); glfwPollEvents (); } while (glfwGetKey (window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose (window) == 0 ); }
出现了
1 ERR: Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible
为了以最快的速度跑起我们的第一个 Demo Application,我找到了这篇 manual 的 GitHub REPO 并且使用了老写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 #include <iostream> #include <GL/glew.h> #include <GLFW/glfw3.h> #include <glm/glm.hpp> using namespace std;using namespace glm;int main () { if (!glfwInit ()) { cerr << "ERR: Failed to initialize GLFW" << endl; getchar (); return 1 ; } glfwWindowHint (GLFW_SAMPLES, 4 ); glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2 ); glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1 ); GLFWwindow* window; window = glfwCreateWindow (1024 , 768 , "Win32 OpenGL Testing" , nullptr , nullptr ); if (window == nullptr ) { cerr << "ERR: Failed to open GLFW window" << endl; getchar (); glfwTerminate (); return 1 ; } glfwMakeContextCurrent (window); if (glewInit () != GLEW_OK) { cerr << "ERR: Failed to initialize GLEW" << endl; getchar (); glfwTerminate (); return 1 ; } glfwSetInputMode (window, GLFW_STICKY_KEYS, GL_TRUE); glClearColor (107.0f / 255.0f , 146.0f / 255.0f , 185.0f / 255.0f , 0.0f ); do { glClear (GL_COLOR_BUFFER_BIT); glfwSwapBuffers (window); glfwPollEvents (); } while (glfwGetKey (window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose (window) == 0 ); glfwTerminate (); return 0 ; }
至于为什么 glCleaerColor
要除以 255,根据 manual 说明 这个函数接受的 RGBA 值是 0 到 1 的区间
更新分割线
别看了,我跑去 Vulkan 了,下篇文章见