I am trying out an opengl application in ubuntu 10.04 using NetBeans IDE.
The code is compiling perfectly but when running it, the application is giving a "segmentation fault". By debugging, I found that that the error is occurring in the constructor.
I have already enabled the OpenGl in the Netbeans IDE. A "hello world" program, which just shows the Hello world in a label is executing properly.
I give below some snippets of the code :
Main.cpp
read_file.getTestCase(test_case, test_data, ((randomize_pts == 'y') || (randomize_pts == 'Y') ? true : false));
std::cerr<<"The system has no opengl suppport"<<std::endl;
return 1;
}
DrawTriangulation *drawtriangulation = new DrawTriangulation(test_data);
drawtriangulation->show();
read_file.getTestCase(test_case, test_data, ((randomize_pts == 'y') || (randomize_pts == 'Y') ? true : false));
QApplication app(argc, argv);
if(!QGLFormat::hasOpenGL()){
std::cerr<<"The system has no opengl suppport"<<std::endl;
return 1;
}
DrawTriangulation *drawtriangulation = new DrawTriangulation(test_data);
drawtriangulation->show();
To copy to clipboard, switch view to plain text mode
Q_OBJECT
private:
vector <Point_2D> *mTestData;
vector <Point_2D>::iterator mTestDataItr;
vector <Line *> *mLines;
protected:
void PrintLines(bool Mode);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
public:
DrawTriangulation
(vector <Point_2D>
*TestData,
QWidget *parent
=NULL);
};
class DrawTriangulation : public QGLWidget {
Q_OBJECT
private:
vector <Point_2D> *mTestData;
vector <Point_2D>::iterator mTestDataItr;
vector <Line *> *mLines;
protected:
void PrintLines(bool Mode);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
public:
DrawTriangulation(vector <Point_2D> *TestData, QWidget *parent=NULL);
};
To copy to clipboard, switch view to plain text mode
The "Point_2D" is a tested class which is working.
The constructor is as :
DrawTriangulation
::DrawTriangulation(vector <Point_2D>
*TestData,
QWidget *parent
) : QGLWidget(parent
) {
mTestData = new vector <Point_2D >;
mLines = new vector<Line *>;
cout<<"hello world ... in const";
mTestData->assign(TestData->begin(), TestData->end());
setFormat
(QGLFormat(QGL
::DoubleBuffer | QGL
::DepthBuffer));
};
DrawTriangulation::DrawTriangulation(vector <Point_2D> *TestData, QWidget *parent) : QGLWidget(parent) {
mTestData = new vector <Point_2D >;
mLines = new vector<Line *>;
cout<<"hello world ... in const";
mTestData->assign(TestData->begin(), TestData->end());
setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer));
};
To copy to clipboard, switch view to plain text mode
The debugging error is giving in the last line of "qglobal.h". The code stops running and points to ...
template<typename Enum>
{
typedef void **Zero;
int i;
public:
typedef Enum enum_type;
inline QFlags(Enum f
) : i
(f
) {} inline QFlags(Zero
= 0) : i
(0) {}
template<typename Enum>
class QFlags
{
typedef void **Zero;
int i;
public:
typedef Enum enum_type;
inline QFlags(const QFlags &f) : i(f.i) {}
inline QFlags(Enum f) : i(f) {}
inline QFlags(Zero = 0) : i(0) {}
To copy to clipboard, switch view to plain text mode
Please help ....
Bookmarks