GLuint not being recognised
Solution 1
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>
Solution 2
I think you should be using glew and include:
#include <GL/glew.h>
rather than:
#include <GL/gl.h>
Yann
Babby programmer trying to be better, I promise. I'll be helpful one day. Currently studying at Staffordshire University doing Computer Games Programming. #SOreadytohelp
Updated on July 09, 2022Comments
-
Yann almost 2 years
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. -
datenwolf about 11 years@Yann4: Define "right places". The compilation error you quoted clearly tells it's not included at all the important places.
-
Yann about 11 yearsIt is defined in the header file, the .cpp file that the header file refers to and the main file, all with include guards