ฉันกำลังดิ้นรนกับการสร้างหน้าต่างด้วยฟังก์ชัน 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!
ฉันคิดว่าฉันได้รับข้อผิดพลาดเนื่องจากการตั้งค่าไม่ถูกต้องทั้งหมด แต่ฉันได้พยายามอย่างเต็มที่แล้วกับสิ่งที่พบได้ทั่วสถานที่
ฉันดาวน์โหลด windows 32 จาก glfw.org และติดไฟล์ 2 ไฟล์จากมันลงใน minGW/include/GLFW, ไฟล์ 2 .a (จากโฟลเดอร์ lib-mingw) ลงใน minGW/lib และ dll จาก lib- โฟลเดอร์ mingw ลงใน Windows/System32
ใน code::blocks ฉันมีจากตัวเลือกการสร้าง -> การตั้งค่าตัวเชื่อมโยงเชื่อมโยงไฟล์ 2 .a จากการดาวน์โหลด ฉันเชื่อว่าฉันต้องเชื่อมโยงสิ่งต่างๆ เพิ่มเติม แต่ฉันสามารถคิดได้ว่าอะไรหรือควรหาสิ่งเหล่านั้นจากที่ไหน