簡體   English   中英

glutBitmapCharacter() 給出鏈接錯誤 c++

[英]glutBitmapCharacter() giving a link error c++

我正在嘗試使用 function 在 window 上創建文本。 當我在代碼中有 glutBitmapCharacter() 時出現此錯誤: LNK2019 unresolved external symbol __imp__glutBitmapCharacter@8 referenced in function "void __cdecl drawText(char const *,int,int,int)" (?drawText@@YAXPBDHHH@Z)

drawText Function:

 void drawText(const char* text, int length, int x, int y) {
     glMatrixMode(GL_PROJECTION);
     double* matrix = new double[16];
     glGetDoublev(GL_PROJECTION_MATRIX, matrix);
     glLoadIdentity();
     glOrtho(0, 800, 0, 600, -5, 5);
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     glPushMatrix();
     glLoadIdentity();
     glRasterPos2i(x, y);
     for (int i=0; i<length; i++) {
         glutBitmapCharacter(GLUT_BITMAP_9_BY_15, (int)text[i]);
     }
     glPopMatrix();
     glMatrixMode(GL_PROJECTION);
     glLoadMatrixd(matrix);
     glMatrixMode(GL_MODELVIEW);
 }

主要 function:

 int main() {
    int windowWidth = 1024, windowHeight = 1024;
    if (!glfwInit())
        return -1;


GLFWwindow* window;
window = glfwCreateWindow(windowWidth, windowHeight, "electroCraft", NULL, NULL);
glfwMakeContextCurrent(window); // stes the specified window as active INACTIVE SCREEN IF WINDOW NOT CURRENT!!!!
if (!window) {
    glfwTerminate();
    printf("Screen failed to start. ABORTING...\n");
    return -1;
}
glMatrixMode(GL_PROJECTION);
glViewport(0, 0, windowWidth, windowHeight);
glOrtho(0, windowWidth, 0, windowHeight, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
string title;
title = "Hello World!";
while (!glfwWindowShouldClose(window)) {
    glClearColor(62.0f / 255.0f, 85.9f / 255.0f, 255.0 / 255.0, 0.0);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    //begin drawing
    drawText(title.data(), title.size(), windowWidth / 2, windowHeight / 2);

    glfwSwapBuffers(window);
    glfwPollEvents();
}
glfwTerminate();
return 0;

}

我很確定我收到此錯誤可能是因為未正確鏈接庫但我對 opengl 庫中的任何其他代碼沒有其他問題

問題是我同時使用 32 位庫和 64 位庫也會導致其他錯誤。 我通過下載所需的所有 64 位庫然后將我的項目重新啟動為 64 位項目來解決此問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM