xcode OpenGL输出一个窗口

具体错误信息:
Starting GLFW context, OpenGL 3.3
2017-03-31 11:00:23.247187+0800 opengl[6941:354760] [General] ERROR: Setting as the first responder for window , but it is in a different window ((null))! This would eventually crash when the view is freed. The first responder will be set to nil.
(
0 AppKit 0x00007fff957aea3f -[NSWindow _validateFirstResponder:] + 557
1 AppKit 0x00007fff94f29b1c -[NSWindow _setFirstResponder:] + 31
2 AppKit 0x00007fff94fd1d9e -[NSWindow _realMakeFirstResponder:] + 406
3 AppKit 0x00007fff94fd1bb4 -[NSWindow makeFirstResponder:] + 123
4 libglfw.3.dylib 0x00000001000b9895 _glfwPlatformCreateWindow + 631
5 libglfw.3.dylib 0x00000001000b5430 glfwCreateWindow + 487
6 opengl 0x0000000100000fdf main + 159
7 libdyld.dylib 0x00007fffacb7d235 start + 1
8 ??? 0x0000000000000001 0x0 + 1
)
Failed to create GLFW window
Program ended with exit code: 255

代码如下
#include

// GLEW
#define GLEW_STATIC
#include

// GLFW
#include

// Window dimensions
const GLuint WIDTH = 800, HEIGHT = 600;

// The MAIN function, from here we start the application and run the game loop
int main()
{
std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
// Init GLFW
glfwInit();
// Set all the required options for GLFW
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

// Create a GLFWwindow object that we can use for GLFW's functions
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr);
if (window == nullptr)
{
    std::cout << "Failed to create GLFW window" << std::endl;
    glfwTerminate();
    return -1;
}

}

2个回答

程序没有问题,如果认真看了那个教程 应该要注意到有提到。Note that on Mac OS X you need to add glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); to your initialization code for it to work. 把这一行加上,运行正常

f_zyj
f_zyj 不太行
一年多之前 回复

看下你的程序有没有什么编译的问题的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!