I am defining a structure in a header file, and then setting its members in the corrosponding .cpp file. For doing this I am using a function that is supposed to create a (same) structure in its scope, and then return it. Something like this:
in header:
#include <things>
class GLWindow : public QGLWidget, public QGLFunctions
{
Q_OBJECT
public:
GLWindow(QWidget *parent = 0);
~GLWindow();
//....
struct Drawable
{
GLuint vertexBuffer;
GLuint indexBuffer;
int faceCount;
QMatrix4x4 transform;
}cube;
GLuint cubeTex;
Drawable CreateDrawable(GLfloat* C_vertices, GLfloat* C_tex, GLfloat* C_normals, GLushort* C_facedata, int faces);
//.....
};
in cpp file:
#include "glwindow.h"
Drawable GLWindow :: CreateDrawable(GLfloat *C_vertices, GLfloat *C_tex, GLfloat *C_normals, GLushort *C_facedata, int faces)
{
int faceCount =faces;
QMatrix4x4 Transform;
Transform.setToIdentity();
GLuint VB;
/*Create vertexbuffer...*/
GLuint IB;
/*Create indexbuffer...*/
Drawable drawable;
drawable.faceCount = fCount;
drawable.transform = Transform;
drawable.vertexBuffer = VB;
drawable.indexBuffer = IB;
return drawable;
}
void GLWindow :: someOtherFunction()
{
//.....
cube = CreateDrawable(cube_vertices, cube_tex, cube_normals, cube_facedata, cube_face);
//.....
}
I am getting an error stating that 'Drawable' does not name a type, but I can't comprehend why I am getting this error, or what I can do to eliminate it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…