I'm creating a sort of drawable object class for mesh data and i'm getting this linker error. This is also on top of another class that handles the drawing of the meshes that was used in one of the Qt tutorials. I'm also using a QGLWidget to be the surface i'm drawing to. Here's what the header file looks for the first class.
我正在为网格数据创建一种可绘制的对象类,我得到了这个链接器错误。这也是在处理在Qt教程中使用的网格绘制的另一个类之上。我还使用QGLWidget作为我要绘制的表面。这是头文件查找第一个类的内容。
#ifndef GLOBJECT_H
#define GLOBJECT_H
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QVector3D>
#include <QVector2D>
#include <QDebug>
#include <QFile>
struct VertexData
{
QVector3D position;
QVector2D texCoord;
QVector3D normal;
};
class GLObject
{
public:
GLObject();
VertexData *data;
GLushort *indices;
GLuint vboIds[2];
int faceCount, vertCount;
bool generateFromPLY(QString filename);
};
#endif // GLOBJECT_H
Here's the header for the other class.
这是另一个类的标题。
#ifndef GEOMETRYENGINE_H
#define GEOMETRYENGINE_H
#include <QObject>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QVector2D>
#include <QVector3D>
#include <QFile>
#include <QDebug>
#include <QVector>
#include <globject.h>
class GeometryEngine : public QObject, protected QOpenGLFunctions
{
Q_OBJECT
public:
GeometryEngine();
~GeometryEngine();
void init();
void drawGeometry(QOpenGLShaderProgram *program);
//void drawCubeGeometry(QOpenGLShaderProgram *program);
bool generateFromPly(QString filename);
QVector<GLObject> drawables;
int drawableId = 0;
};
#endif // GEOMETRYENGINE_H
G:\Dropbox\GLSLDemo\globject.cpp:60: error: 'glGenBuffers' was not declared in this scope glGenBuffers(2, vboIds); along with the same error for the other gl calls. Initially I had all the code in GeometryEngine to begin with. I didn't have a scope issue then. initilizeOpenGLFunctions() is called in GeometryEngine's init() if that's relevant. ^
G:\ Dropbox \ GLSLDemo \ globject。错误:在此范围内没有声明glGenBuffers(2, vboid);以及其他gl调用的相同错误。一开始我用的是GeometryEngine中的所有代码。当时我没有涉及范围问题。initilizeOpenGLFunctions()在GeometryEngine的init()中调用,如果相关的话。^
1 个解决方案
#1
-1
QT OpenGL is weird. I think the QOpenGLFunctions maintains a common context. Also i'm bad at C++ and used protected wrong.
QT OpenGL是奇怪的。我认为QOpenGLFunctions维护了一个公共上下文。我也不擅长c++,使用了保护错误。
#1
-1
QT OpenGL is weird. I think the QOpenGLFunctions maintains a common context. Also i'm bad at C++ and used protected wrong.
QT OpenGL是奇怪的。我认为QOpenGLFunctions维护了一个公共上下文。我也不擅长c++,使用了保护错误。