Qt version of OpenGL SuperBible Triange - undefined reference GLBatch
I’m new to Qt and I’m trying to implement the examples in the OpenGL SuperBible which uses GLTools. I’m using Qt Creator (Qt Creator 2.0.94 (2.1.0-rc1)).
I expect that I’m missing something simple but I need some help.
Thanks for any help.
Dan
I run qmake and then Build Project.
I’m getting the following error from Build Project: Compile Output
These are all defined in GLTools.h and are in the gltools.lib
- g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug/SB_Triangle.exe debug/main.o debug/TriangleWidget.o debug/moc_TriangleWidget.o -L'c:/Qt/2010.05/qt/lib' -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\glew32s.lib" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\gltools.lib" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\GlU32.Lib" -lQtOpenGLd4 -lQtGuid4 -lQtCored4
- debug/TriangleWidget.o: In function `TriangleWidget':
- *D:\Development\GPU\code\C++\Qt\OpenGL SuperBible\Triangle\SB_Triangle-build-desktop/../SB_Triangle/TriangleWidget.cpp:6: undefined reference to `GLBatch::GLBatch()'*
I’m using:
- XP SP3
- Qt Creator 2.0.94 (2.1.0-rc1)
- Qt SDK – C:\Qt\2010.05
SB_Triangle.pro file
- QT += core gui
- QT += opengl
- TARGET = SB_Triangle
- TEMPLATE = app
- CONFIG += opengl glu glew gltools
- INCLUDEPATH += .
- INCLUDEPATH += D:\Development\GPU\CppLibs\GLEW\glew-1.5.8\include
- INCLUDEPATH += D:\Development\GPU\CppLibs\GLTools\include
- win32 : LIBS +=
- win32 : LIBS += $$quote(C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\glew32s.lib)
- win32 : LIBS += $$quote(C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\gltools.lib)
- win32 : LIBS += $$quote(C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\GlU32.Lib)
- SOURCES += main.cpp\
- TriangleWidget.cpp
- HEADERS += TriangleWidget.h
- FORMS += TriangleWidget.ui
The error is on line 6, – ui(new Ui::TriangleWidget)
TriangleWidget.cpp
- #include "TriangleWidget.h"
- #include "ui_TriangleWidget.h"
- ui(new Ui::TriangleWidget)
- {
- ui->setupUi(this);
- }
- TriangleWidget::~TriangleWidget()
- {
- delete ui;
- }
- void TriangleWidget::ChangeSize(int w, int h)
- {
- glViewport(0, 0, w, h);
- }
- void TriangleWidget::SetupRC()
- {
- // Blue background
- glClearColor(0.0f, 0.0f, 1.0f, 1.0f );
- shaderManager.InitializeStockShaders();
- // Load up a triangle
- GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f,
- 0.5f, 0.0f, 0.0f,
- 0.0f, 0.5f, 0.0f };
- triangleBatch.Begin(GL_TRIANGLES, 3);
- triangleBatch.CopyVertexData3f(vVerts);
- triangleBatch.End();
- }
- void TriangleWidget::RenderScene(void)
- {
- // Clear the window with current clearing color
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
- shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
- triangleBatch.Draw();
- // Perform the buffer swap to display back buffer
- //glutSwapBuffers();
- swapBuffers();
- }
TriangleWidget.h
- #ifndef TRIANGLEWIDGET_H
- #define TRIANGLEWIDGET_H
- #include <GL/glew.h>
- #include <QGLWidget>
- #include <GLTools.h> // OpenGL toolkit
- #include <GLShaderManager.h> // Shader Manager Class
- namespace Ui {
- class TriangleWidget;
- }
- // Based on Triangle.cpp in OpenGL SuperBible 5th edition
- // Port to Qt 4.7 - 3.20.2011 dpc
- // Our first OpenGL program that will just draw a triangle on the screen.
- {
- Q_OBJECT
- public:
- ~TriangleWidget();
- protected:
- ///////////////////////////////////////////////////////////////////////////////
- // Window has changed size, or has just been created. In either case, we need
- // to use the window dimensions to set the viewport and the projection matrix.
- void ChangeSize(int w, int h);
- ///////////////////////////////////////////////////////////////////////////////
- // This function does any needed initialization on the rendering context.
- // This is the first opportunity to do any OpenGL related tasks.
- void SetupRC();
- ///////////////////////////////////////////////////////////////////////////////
- // Called to draw scene
- void RenderScene(void);
- private:
- Ui::TriangleWidget *ui;
- GLBatch triangleBatch;
- GLShaderManager shaderManager;
- };
- #endif // TRIANGLEWIDGET_H
1 reply
You must log in to post a reply. Not a member yet? Register here!


