具体错误信息:
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;
}
}