Dextron
Dextron

Reputation: 628

glutBitmapCharacter() giving a link error c++

I am trying to create text on a window using a function. When I have glutBitmapCharacter() in the code I get this error: 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);
 }

main 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;

}

I am pretty sure I'm getting this error maybe because of a library not being linked properly but I have no other problem with any other code in here from the opengl libraries

Upvotes: 0

Views: 804

Answers (1)

Dextron
Dextron

Reputation: 628

Problem was I was using 32 bit libraries and 64 bit libraries together causing other errors as well. I fixed this by downloading all 64 bit libraries required and then restarting my project as a 64 bit project

Upvotes: 1

Related Questions