版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jining11/article/details/88201312
文章目录
安装教程: https://blog.csdn.net/sigmarising/article/details/80470054
首先:安装完毕VS2017,Cmake,安装包以及OpenGL Extension Viewer。
大坑一号:Cmake的错误提示
- 症状
- configure无法正常完成:
- log文件出现如下提示:The system is:Windows - 10.0.17134 - AMD64
- configure无法正常完成:
- 求医问药
一开始在网上查,都说是VS的版本没选对,把15选成17诸如此类,但我睁着眼睛瞅了半天,版本就是17,千真万确。后来就按着报错信息查,终于在一个不起眼的地方发现了这样一条回复。
- 下一步就是安装所谓的Desktop Development with C++了
-
打开VS installer
-
点击修改
选中使用C++的桌面开发,在右侧注意勾选上下方的win10 sdk(17134)
- 查看版本,下载对应类型的源文件
- 查看版本,下载对应类型的源文件
-
- 编译成功
大坑二号:"使用C++的桌面开发"巨慢的下载速度
一开始的下载速度是这样式儿的:
死马当活马医翻了个墙之后:
真.无话可说
大坑三号:如何跑起来第一个程序
由于我没有用过VS,所以光是建立起第一个能跑的程序就花了很长时间,还好最后明智地选择了去上B站学习,取得了最后一步的胜利。
具体步骤就自己看叭:
注意!添加cpp是在解决方案资源管理器这个视图下面的源文件里面添加,改变项目属性是在类视图里面直接右键选择最后一项属性。
运行成功(点击调试-开始执行)
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
using namespace std;
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
int main() {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow *window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
if (window == NULL) {
cout << "Failed to create GLFW window" << endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window)) {
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}