Search code examples
c++visual-studioopengltexturesglut

GLuint not being recognised


I am creating a 3D application in OpenGL, and in order to display textures on the models that I'm reading in, I'm using GLuint. However, I am getting the visual studio error C4430 missing type, and a handful of others related to the issue.

The glut files are included and were working fine before this was put in. Is it that GLuint is outdated, or something else?

Edit: The code that has changed is:

Object constructor before

Object::Object(string shapeFileName, string texFileName){
    readFile(shapeFileName);
    loadTexture(texFileName);
}

Object constructor afterwards

Object::Object(string shapeFileName, string texFileName){
    readFile(shapeFileName);

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    loadTexture(texFileName);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, image_array);

    free(image_array);

    glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, image_array);
}

Along with the line GLuint texture; added in the header file, which is the only bit that is throwing an error.


Solution

  • Did you include the OpenGL header in the header you're declaring the variable in? GLuint is defined in gl.h so you must include that.

    On all operating systems except MacOS X it's

    #include <GL/gl.h>
    

    on MacOS X it is

    #include <OpenGL/gl.h>