PDA

View Full Version : 'GLint' does not name a type



sajis997
4th December 2014, 18:23
Hello forum,

I am trying to make a simple modern opegl application with qt5. I have defined the
QT += opengl inside the .pro file.

Then inside the class declaration i am declaring a variable as follows:




class scene : pulic abstractscene
{
Q_OBJECT

public:
.......................
.......................
private:

GLint vertices;
}



I am getting the error at "GLint vertices" with the message mentioned in the title.

Any clue ?


Thanks

wysota
4th December 2014, 20:01
You are missing

#include <GL.h>

sajis997
5th December 2014, 04:11
Thanks

There is another class and i am declaring a variable of type GLuint and the compiler is not complaining at all.

Any explanation that this particular class needs this inclusion. Details of the class definition are provided in the following:



#ifndef TESSELLATIONSCENE_H
#define TESSELLATIONSCENE_H

#include <GL/gl.h>
#include "defines.h"
#include "AbstractScene.h"

class QOpenGLFunctions_4_3_Core;

class GLSLShader;

class TeapotVboPatch;

class TessellationScene : public AbstractScene
{
Q_OBJECT

public:

TessellationScene(QObject *parent = 0);

~TessellationScene();

//scene related functions
virtual void initialise();
virtual void update(float t);
virtual void render();
virtual void resize(int w, int h);

private:

void loadShaders();

QOpenGLFunctions_4_3_Core *mFuncs;

GLSLShader *mTessellationShader;

TeapotVboPatch *mTeapotPatch;

//hold the maximum number of vertices
//inside a patch
GLint mMaxPatchVertices;
};

#endif // TESSELLATIONSCENE_H



As you can see above that the class definition contains the inclusion of GL/gl.h after your suggestion and now please check the following class structure:



#ifndef TEAPOTVBOPATCH_H
#define TEAPOTVBOPATCH_H

#include "defines.h"
#include "teapotdata.h"

class QOpenGLFunctions_4_3_Core;
class GLSLShader;

class TeapotVboPatch
{
private:
GLuint mTeapotVAOID;
GLuint mTeapotBufferID;

QOpenGLFunctions_4_3_Core *mTeapotRenderFunc;

void generatePatches(float *v);
void buildPatchReflect(int patchNum,
float *v,
int &index,
bool reflectX,
bool reflectY);

void buildPatch(glm::vec3 patch[][4],
float *v,
int &index,
glm::mat3 reflect);

void getPatch(int patchNum,glm::vec3 patch[][4],bool reverseV);

public:

TeapotVboPatch(GLSLShader *);
~TeapotVboPatch();

void render(GLSLShader *shader);

};

#endif // TEAPOTVBOPATCH_H



The compiler did not complain at all for the TeapotVboPatch class even though i have declaration of GLuint type without the inclusion of GL/gl.h.

Why is that so ?

Thanks

anda_skoa
5th December 2014, 07:05
The declaration of the GLuint type could come from one of the other includes or the TeapotVboPatch header is always included after includes that bring in the type.

Cheers,
_