2016-11-03 52 views
3

我最近一直在使用OpenGL,並決定使用C++爲我的最新項目使用OpenGL。我正在使用xCode 8.1,並且正確鏈接了我的庫路徑和標題路徑。一切編譯罰款,但我在運行時出現此錯誤:xCode 8.1 GLFWWindow「第一響應者」問題

2016-11-03 15:17:24.649264 Modulo[25303:14858638] [General] ERROR: Setting <GLFWContentView: 0x100343da0> as the first responder for window <GLFWWindow: 0x100222540>, 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        0x00007fff85c069a4 -[NSWindow _validateFirstResponder:] + 566 
1 AppKit        0x00007fff853f79eb -[NSWindow _setFirstResponder:] + 31 
2 AppKit        0x00007fff8549f66a -[NSWindow _realMakeFirstResponder:] + 406 
3 AppKit        0x00007fff8549f480 -[NSWindow makeFirstResponder:] + 123 
4 libglfw3.3.dylib     0x000000010011194a _glfwPlatformCreateWindow + 610 
5 libglfw3.3.dylib     0x000000010010d533 glfwCreateWindow + 428 
6 Modulo        0x00000001000010a8 main + 296 
7 libdyld.dylib      0x00007fff9c828255 start + 1 
8 ???         0x0000000000000001 0x0 + 1) 

我運行產生這個錯誤的代碼如下:

#include <iostream> 
#define GLEW_STATIC 
#include <GL/glew.h> 
#include <GLFW/glfw3.h> 

int main(int argc, const char * argv[]) { 
    //Engine Startup. 
    std::cout << "<----- Engine Start-Up ----->" << std::endl; 
    //Initialize GLFW. 
    if(!glfwInit()) { 
     std::cout << "- GLFW Failed to Initialize!" << std::endl; 
     return -1; 
    } 
    std::cout << "+ GLFW Initialized!" << std::endl; 
    //Create GLFWWindow 
    GLFWwindow* window = glfwCreateWindow(640, 480, "Engine", nullptr, nullptr); 
    if(!window) { 
     std::cout << "- GLFWWindow Failed to Create!" << std::endl; 
     glfwTerminate(); 
     return -1; 
    } 
    std::cout << "+ GLFWWindow Created!" << std::endl; 
    return 0; 
} 

程序執行,因爲它應該,但這個錯誤可能會成爲問題後來也讓控制檯很難調試,所以我想盡早整理它!

預先感謝您,如果需要更多信息,請讓我知道! :)

回答

2

我是初學者,我也遇到過這個問題。

我得到了一個錯誤,但成功創建窗口。加入怎麼樣:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); 
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); 
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 

before glfwCreateWindow

1

請注意這裏的討論GLFW first responder error這表明它是macOS Sierra中的一個已知錯誤,已經在GLFW的git repo中解決,但尚未發佈。