2019/03/10 下午看了下关于opengl的资料,然后把敲了下代码,然后程序报错了。代码如下:
#include <glad/glad.h> #include <GLFW/glfw3.h> #include <iostream> int main() { 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); GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); return 0; }
下面这句代码直接返回的window直接是一个NULL,
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
然后我在网上查了半天,试了下都不靠谱。然后我google了一下,发现*网站里面有一个回答。
Docs say "Windows: Window creation will fail if the Microsoft GDI software OpenGL implementation is the only one available." What video card are you using, do you have the latest driver, and are you running remote desktop or in the console session?
我突然想起来我是在用我的笔记本远程我的台式机来调试代码的(天太冷了,坐床上舒服一些),然后我关了远程,直接在台式机上面运行,没有任何问题。。。。。。