GLuint not being recognised
Asked Answered
A

3

9

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.

Allpowerful answered 17/4, 2013 at 11:18 Comment(4)
Can you show some code, please? Best would be a before-after comparison, i.e. a working code and one which fails to compile, as you say it was "working fine before this was put in"...Carmellacarmelle
@leemes: If someone hasn't provided enough information to answer the question, please vote to close.Pneumatics
It is just that issue. I just added in an uninitialised variable GLuint texture;Allpowerful
We need more context.Carmellacarmelle
F
8

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>
Freewheeling answered 17/4, 2013 at 12:42 Comment(2)
@Yann4: Define "right places". The compilation error you quoted clearly tells it's not included at all the important places.Freewheeling
It is defined in the header file, the .cpp file that the header file refers to and the main file, all with include guardsAllpowerful
S
4

I think you should be using glew and include:

#include <GL/glew.h>

rather than:

#include <GL/gl.h>
Schroder answered 15/4, 2016 at 15:19 Comment(0)
F
-1

For iOS you need to link OpenGLES.framework to your target and import header in your code:

#import <OpenGLES/gltypes.h>
Freestyle answered 17/2, 2020 at 16:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.