【问题标题】:GLFW first responder errorGLFW 第一响应者错误
【发布时间】:2016-12-14 15:21:00
【问题描述】:

我正在尝试创建一个简单的 GLFW 窗口并成功,但 xcode 给了我一个错误:

2016-12-14 10:16:40.412191 CREngine[830:21929] [General] ERROR: Setting <GLFWContentView: 0x100369850> as the first responder for window <GLFWWindow: 0x10033ea00>, 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                              0x00007fff9710b9a4 -[NSWindow _validateFirstResponder:] + 566
    1   AppKit                              0x00007fff968fc9eb -[NSWindow _setFirstResponder:] + 31
    2   AppKit                              0x00007fff969a466a -[NSWindow _realMakeFirstResponder:] + 406
    3   AppKit                              0x00007fff969a4480 -[NSWindow makeFirstResponder:] + 123
    4   libglfw.3.dylib                     0x00000001000a9895 _glfwPlatformCreateWindow + 631
    5   libglfw.3.dylib                     0x00000001000a5430 glfwCreateWindow + 487
    6   CREngine                            0x0000000100000e87 main + 135
    7   libdyld.dylib                       0x00007fffadd2d255 start + 1
)
Program ended with exit code: 0

我使用的代码是:

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

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

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

令我困惑的部分是我所查找的内容,包括我所拥有的提示将允许它在 mac 上工作,但由于某种原因,我仍然收到错误,所以我希望有人可以帮助我解决这个错误。

【问题讨论】:

  • 查看github.com/glfw/glfw/issues/876 这似乎是一个错误。您正在运行最新版本的 GLFW 吗? (你使用的是 macOS Sierra 吗?)
  • @pingul 两者都是
  • 什么版本的 Sierra?这个forums.developer.apple.com/thread/49052 似乎表明它也是苹果的问题。
  • @pingul Serria:10.12.1 和 GLFW:3.2.1
  • 有一个新版本的 Sierra out (10.12.2),你可以尝试升级。你是如何安装 GLFW 的?查看glfw.org/changelog.html 的最新编译版本,它看起来不像包含错误修复,但是在 git-rep github.com/glfw/glfw。我会尝试从 repo 中提取代码并在本地编译。

标签: c++ opengl glfw


【解决方案1】:

This 似乎表明这是 macOS Sierra 中的一个已知错误,查看git-repo 似乎已修复。但是,(当前)latest version on their webpage 似乎没有更新。

如果你从他们的网站安装了 GLFW,我建议你从 git 中提取代码并在本地编译。

(编辑:有关从源代码构建 .dylib 文件的一些有用详细信息,请参阅 this。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 2021-11-26
    • 2011-06-21
    • 1970-01-01
    相关资源
    最近更新 更多