Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 361
Yann Avatar asked Apr 17 '13 11:04

Yann


People also ask

Should GLGL uint be included in right places?

GLuint is defined in gl.h so you must include that. @Yann4: Define "right places". The compilation error you quoted clearly tells it's not included at all the important places.

How to fix GPU not recognized in Device Manager?

By clicking on your GPU, you can also choose ‘Enable device’ to fix the problem. The text will show “Enable device” if the GPU is disabled Unfortunately, it’s also possible that the Device Manager won’t even recognize your discrete GPU and will instead just show properties of the integrated one.

What is the use of GL uint in OpenGL?

GLuint is just a shorter way of typing unsigned int: That might be true on your particular OpenGL implementation, but once you switch to a platform where unsigned int is not 4 bytes your code might stop working. – ComicSansMS Nov 11 '13 at 11:08


2 Answers

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>
like image 162
datenwolf Avatar answered Oct 15 '22 08:10

datenwolf


I think you should be using glew and include:

#include <GL/glew.h>

rather than:

#include <GL/gl.h>
like image 30
Lywx Avatar answered Oct 15 '22 07:10

Lywx