我正在努力使用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;
}
Run Code Online (Sandbox Code Playgroud)
这是控制台中打印出的内容
INITIALIZER: GLFW Initialized succesfully!
65537 The GLFW library is not initialized
INITIALIZER: Failed to create window!
Run Code Online (Sandbox Code Playgroud)
我认为由于设置不完全正确而导致出现错误,但是我已尽我所能在周围找到的一切已尽力而为
我从glfw.org下载了Windows 32,并将其中的2个包含文件粘贴到minGW / include / GLFW中,将2个.a文件(来自lib-mingw文件夹)粘贴到minGW / lib和dll中,也从lib- mingw文件夹,进入Windows / System32
在代码:: blocks中,我从构建选项->链接器设置中链接了下载中的2个.a文件。我相信我需要链接更多的东西,但是我可以弄清楚应该从哪里获得这些东西。