xCode 8.1 GLFWWindow "first responder" 问题

xCode 8.1 GLFWWindow "first responder" Issue

本文关键字:first 问题 responder GLFWWindow xCode      更新时间:2023-10-16

我最近一直在使用OpenGL,并决定在我最新的OpenGL项目中使用C++。我使用的xCode 8.1使我的库路径和头路径正确链接。一切都编译得很好,但我在运行时收到了这个错误:

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;
}

程序运行正常,但这个错误可能会在以后成为一个问题,也会使控制台难以调试,所以我想早点解决它!

提前感谢您,如果需要更多信息,请告诉我!:(

我是一个初学者,也遇到过这个问题。

我犯了一个错误,但成功创建了窗口。如何添加:

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);

glfwCreateWindow之前?

请注意此处的讨论GLFW第一响应程序错误,这表明它是macOS Sierra中的一个已知错误,该错误已在GLFW的git repo中解决,但尚未发布。