OpenGL doesn't create window with the desired size
所以我有这段代码
1 2 | GLFWwindow* window = glfwCreateWindow(1024, 768,"Hello Triangle", NULL, NULL); glViewport(0, 0, 1024, 768); |
但是,当我创建一个坐标为(-1,-1),(0,1)和(1,-1)的三角形时,它仅在拐角处绘制了一个小三角形。 如果我调整窗口大小,它将绘制正确的三角形。
因此,我设置了一个帧缓冲区大小回调:
1 2 3 4 | void FramebufferSizeCallback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); cout << width <<"" << height << endl; } |
我试图调整窗口的大小,结果发现窗口的大小大于1024 x 768。
那么,为什么
我正在使用macOS High Sierra。
1 2 3 4 5 | GLFWwindow* window = glfwCreateWindow(1024, 768,"Hello Triangle", NULL, NULL); glfwMakeContextCurrent(wnd); // <-- make the context current before glViewport glViewport(0, 0, 1024, 768); |
注意,