GLFW first responder error
Asked Answered
H

1

6

I am trying to create a simple GLFW window and a succeed but xcode gives me an error:

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

The code I used is:

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

The part that is confusing me is from what I have looked up is that including the hints that I have will allow it to work on mac but for some reason I am stilling getting the errors so I was hoping that someone could help me solve this error.

Headrick answered 14/12, 2016 at 15:21 Comment(9)
Looking at github.com/glfw/glfw/issues/876 this seems to have been a bug. Are you running the latest version of GLFW? (And are you using macOS Sierra?)Flowerage
@Flowerage yes on bothHeadrick
And what version of Sierra? This forums.developer.apple.com/thread/49052 seems to suggest it's a problem with apple as well.Flowerage
@Flowerage Serria: 10.12.1 and GLFW: 3.2.1Headrick
There's a new version of Sierra out (10.12.2), you could try to upgrade. How did you install GLFW? Looking at the latest compiled release at glfw.org/changelog.html it doesn't look like the bug fix is included, however at the git-rep github.com/glfw/glfw. I would try to pull the code from the repo and compile it locally.Flowerage
@Flowerage you suggestion to use the github.com version worked perfectly. I have one last question and that is it generates documentation warnings from glfw is there anyway to suppress these warnings?Headrick
Great! I've added the contents of my comment as an answer. Do you get documentation warnings when you compile or when you run? And what kinds of warnings? It might be considered off-topic for your current question, so it could be an idea to post another one.Flowerage
just warnings on from what I can tell the doxygen. It shows the warnings on build or running of the code.Headrick
This has been fixed in the glfw-master version.Clayclaybank
F
5

This seems to indicate that this is a known bug in macOS Sierra, and looking at the git-repo it seems to be fixed. However, it does not look like the (currently) latest version on their webpage has been updated.

If you have installed GLFW from their website, I recommend pulling the code from git and compiling it locally.

(Edit: see this for some helpful details about building the .dylib file from the source.)

Flowerage answered 15/12, 2016 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.