我正在努力使用 GLFW 3 函数 glfwCreateWindow 创建一个窗口。我设置了一个错误回调函数,它几乎只是打印出错误号和描述,并且根据 GLFW 库尚未初始化,即使 glfwInit 函数刚刚返回成功?
这是我的代码的摘录
// Error callback function prints out any errors from GFLW to the console
static void error_callback( int error, const char *description )
{
cout << error << '\t' << description << endl;
}
bool Base::Init()
{
// Set error callback
/*!
* According to the documentation this can be use before glfwInit,
* and removing won't change anything anyway
*/
glfwSetErrorCallback( error_callback );
// Initialize GLFW
/*!
* This return succesfull, but...
*/
if( !glfwInit() )
{
cout << "INITIALIZER: Failed to initialize GLFW!" << endl;
return false;
}
else
{
cout << "INITIALIZER: GLFW Initialized successfully!" << endl;
}
// Create window
/*!
* When this is called, or any other glfw functions, I get a
* "65537 The GLFW library is not initialized" in the console, through
* the error_callback function
*/
window = glfwCreateWindow( 800,
600,
"GLFW Window",
NULL,
NULL );
if( !window )
{
cout << "INITIALIZER: Failed to create window!" << endl;
glfwTerminate();
return false;
}
// Set window to current context
glfwMakeContextCurrent( window );
...
return true;
}
这是控制台中打印的内容
INITIALIZER: GLFW Initialized succesfully!
65537 The GLFW library is not initialized
INITIALIZER: Failed to create window!
我认为我收到了错误,因为设置不完全正确,但我已经尽我所能在这个地方找到了最好的东西
我从 glfw.org 下载了 windows 32 并将其中的 2 个包含文件粘贴到 minGW/include/GLFW 中,将 2 个 .a 文件(来自 lib-mingw 文件夹)粘贴到 minGW/lib 和 dll 中,也来自 lib- mingw 文件夹,进入 Windows/System32
在我拥有的 code::blocks 中,从构建选项-> 链接器设置,链接了下载中的 2 个 .a 文件。我相信我需要链接更多的东西,但我可以弄清楚我应该从什么或从哪里得到这些东西。