Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';即使glfwInit()返回1,也不能使GLFW工作_C++_Opengl_Graphics_Glfw - Fatal编程技术网

C++ Can';即使glfwInit()返回1,也不能使GLFW工作

C++ Can';即使glfwInit()返回1,也不能使GLFW工作,c++,opengl,graphics,glfw,C++,Opengl,Graphics,Glfw,我已经设置了GLFW库,根据它的用户指南,我应该使用glfwInit()函数初始化它。之后,我应该能够——例如——在我按下键盘上的键后调用回调函数,但这个函数没有被调用,所以我尝试了一些更简单的方法——获取鼠标位置。但它也不起作用,所以我认为我的整个GLFW有问题 这是我的应用程序的主循环: while (!m_exit) { int x, y; glfwGetMousePos(&x, &y); glfwPollEvents(); gameCyc

我已经设置了
GLFW
库,根据它的用户指南,我应该使用
glfwInit()
函数初始化它。之后,我应该能够——例如——在我按下键盘上的键后调用回调函数,但这个函数没有被调用,所以我尝试了一些更简单的方法——获取鼠标位置。但它也不起作用,所以我认为我的整个GLFW有问题

这是我的应用程序的主循环:

while (!m_exit)
{

    int x, y;
    glfwGetMousePos(&x, &y);
    glfwPollEvents();
    gameCycle();                        // Do one cycle

    while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
    {
        // Check the pressence of commands
        if (!GetMessage (&msg, NULL, 0, 0))
        {
            return msg.wParam; // Hand the control on to system
        }

        TranslateMessage (&msg);
        DispatchMessage (&msg);
    }
}
同样在这个循环之前,我初始化了我的
GLFW

// Initialize GLFW
if( !glfwInit() )
{
    exit( EXIT_FAILURE );
}

glfwSetKeyCallback(processKeys);

// Main message loop:
int loopRet = g_pGameAppLayer->mainLoop();
当我检查保存在
x
y
变量中的值时,我只得到-858993460,这表示没有向它们传递值

那么,我在设置
GLFW
up时遗漏了什么呢

您的问题在于:

之后,我应该能够——例如——在按下键盘上的键后调用回调函数

不,你不应该。在使用GLFW创建窗口之前,无法获取输入。这通常适用于许多窗口系统;只有在有窗口的情况下才能获得输入。

您的问题在于:

之后,我应该能够——例如——在按下键盘上的键后调用回调函数


不,你不应该。在使用GLFW创建窗口之前,无法获取输入。这通常适用于许多窗口系统;只有在有窗口的情况下,您才能获得输入。

如果您使用GLFW,为什么要显式发送Win32消息?@rioki,因为我不知道我不应该这样做。如果您使用GLFW,为什么要显式发送Win32消息?@rioki,因为我不知道我不应该这样做。谢谢Nicol,我想我可能只能将GLFW用于句柄输入,因为我已经创建了没有使用GLFW的窗口。谢谢Nicol,我想我可能只能将GLFW用于句柄输入,因为我已经创建了没有使用GLFW的窗口。