[英]glfw does not create a window
當我創建一個簡單的glfw窗口並設置以下兩個標志時:
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
該窗口將為NULL,我不知道為什么。 如果未調用這兩項,則將創建該窗口。
這是下面的代碼:
#include <iostream>
using namespace std;
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int main() {
if (!glfwInit()) {
cout << "glfw did not initialize!" << endl;
return -1;
}
glfwWindowHint(GL_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window;
window = glfwCreateWindow(640, 300, "ARoo", NULL, NULL);
if (!window) {
cout << "window == null" << endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window)) {
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
}
我使用視覺研究社區2015,Windows 8.1 x64(glfw和glew是x32)我的視頻驅動程序是最新的。
該問題可能與所請求的OpenGL配置文件有關。
您可以獲取有關正在發生的情況的診斷消息,只需設置一個回調即可,可以在glfwInit()
之前完成此glfwInit()
:
static void glfwError(int id, const char* description)
{
std::cout << description << std::endl;
}
int main()
{
glfwSetErrorCallback(&glfwError);
glfwInit();
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.