Hello forum,

I am trying to create UI for a third party API - H3D and while doing
it i am getting the following error:

Qt Code:
  1. 0-Source/HAPI/include -I/usr/X11R6/include -I. -I. -o H3DGLCanvas.o
  2. H3DGLCanvas.cpp
  3. In file included from /usr/local/include/H3D/H3DDisplayListObject.h:32,
  4. from /usr/local/include/H3D/X3DAppearanceNode.h:33,
  5. from /usr/local/include/H3D/Appearance.h:32,
  6. from /usr/local/include/H3D/DefaultAppearance.h:33,
  7. from /usr/local/include/H3D/H3DWindowNode.h:35,
  8. from MyH3DCanvasWindow.h:4,
  9. from H3DGLCanvas.cpp:3:
  10. /usr/include/GL/glew.h:84:2: error: #error gl.h included before glew.h
  11. /usr/include/GL/glew.h:87:2: error: #error glext.h included before glew.h
  12. In file included from /usr/local/include/H3D/H3DDisplayListObject.h:32,
  13. from /usr/local/include/H3D/X3DAppearanceNode.h:33,
  14. from /usr/local/include/H3D/Appearance.h:32,
  15. from /usr/local/include/H3D/DefaultAppearance.h:33,
  16. from /usr/local/include/H3D/H3DWindowNode.h:35,
  17. from MyH3DCanvasWindow.h:4,
  18. from H3DGLCanvas.cpp:3:
  19. /usr/include/GL/glew.h:8422: error: conflicting declaration ‘typedef
  20. void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, GLfloat*)’
  21. /usr/include/GL/glext.h:5570: error:
  22. ‘PFNGLFRAGMENTLIGHTMODELFVSGIXPROC’ has a previous declaration as
  23. ‘typedef void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, const
  24. GLfloat*)’
  25. /usr/include/GL/glew.h:8424: error: conflicting declaration ‘typedef
  26. void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, GLint*)’
  27. /usr/include/GL/glext.h:5572: error:
  28. ‘PFNGLFRAGMENTLIGHTMODELIVSGIXPROC’ has a previous declaration as
  29. ‘typedef void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, const
  30. GLint*)’
  31. /usr/include/GL/glew.h:8426: error: conflicting declaration ‘typedef
  32. void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, GLfloat*)’
  33. /usr/include/GL/glext.h:5566: error: ‘PFNGLFRAGMENTLIGHTFVSGIXPROC’
  34. has a previous declaration as ‘typedef void (*
  35. PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, const GLfloat*)’
  36. /usr/include/GL/glew.h:8428: error: conflicting declaration ‘typedef
  37. void (* PFNGLFRAGMENTLIGHTIVSGIXPROC)(GLenum, GLenum, GLint*)’
  38. /usr/include/GL/glext.h:5568: error: ‘PFNGLFRAGMENTLIGHTIVSGIXPROC’
  39. has a previous declaration as ‘typedef void (*
  40. PFNGLFRAGMENTLIGHTIVSGIXPROC)(GLenum, GLenum, const GLint*)’
  41. /usr/include/GL/glew.h:8435: error: conflicting declaration ‘typedef
  42. void (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, const
  43. GLfloat*)’
  44. /usr/include/GL/glext.h:5579: error:
  45. ‘PFNGLGETFRAGMENTMATERIALFVSGIXPROC’ has a previous declaration as
  46. ‘typedef void (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum,
  47. GLfloat*)’
  48. /usr/include/GL/glew.h:8436: error: conflicting declaration ‘typedef
  49. void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum, const
  50. GLint*)’
  51. /usr/include/GL/glext.h:5580: error:
  52. ‘PFNGLGETFRAGMENTMATERIALIVSGIXPROC’ has a previous declaration as
  53. ‘typedef void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum,
  54. GLint*)’
  55. /usr/include/GL/glew.h:9866: error:
  56. ‘PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC’ does not name a type
  57. /usr/include/GL/glew.h:9867: error:
  58. ‘PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC’ does not name a type
  59. H3DGLCanvas.cpp:8: warning: unused parameter ‘attribute_list’
  60. H3DGLCanvas.cpp:17: warning: unused parameter ‘attribute_list’
  61. H3DGLCanvas.cpp:34: warning: unused parameter ‘width’
  62. H3DGLCanvas.cpp:34: warning: unused parameter ‘height’
  63. make: *** [H3DGLCanvas.o] Error 1
  64. sajjad@sajjad:~/Documents/X3D/H3DViewer$
To copy to clipboard, switch view to plain text mode 

I have sub-classed the QGLWidget which contains the reference to the
another class that is the subclass of the third party class. It may be
clashing with the glew initialization.


The following snippet shows the sub-classed qglwidget
Qt Code:
  1. #ifndef H3DGLCANVAS_H
  2. #define H3DGLCANVAS_H
  3.  
  4. #include <QGLWidget>
  5. class MyH3DCanvasWindow;
  6.  
  7. //this class is similar to the subclass of wxGLCanvas
  8. class H3DGLCanvas :public QGLWidget
  9. {
  10. Q_OBJECT
  11. public:
  12. H3DGLCanvas(MyH3DCanvasWindow *owner,
  13. QGLContext *shared_context,
  14. int *attribute_list = 0,
  15. QWidget *defaultParent = 0);
  16.  
  17. H3DGLCanvas(MyH3DCanvasWindow *owner,
  18. int *attribute_list = 0,
  19. QWidget *defaultParent = 0);
  20. ~H3DGLCanvas();
  21.  
  22. /*!
  23.   \sa sets up the opengl rendering context,defines the display list. gets called once before the first time resizeGL() or paintGL() is called.
  24.   */
  25. void initializeGL();
  26.  
  27. /*!
  28.   \sa sets up the opengl viewport,projection. gets called whenever the widgets gets resized.
  29.   */
  30. void resizeGL(int width, int height);
  31. /*!
  32.   \sa renders the opengl scene . gets called wehnever the widget needs to be updated
  33.   */
  34. void paintGL();
  35.  
  36. protected:
  37.  
  38. MyH3DCanvasWindow *m_owner;
  39.  
  40. };
  41.  
  42.  
  43. #endif // H3DGLCANVAS_H
  44. ............................................................
  45.  
  46. #include "H3DGLCanvas.h"
  47.  
  48. #include "MyH3DCanvasWindow.h"
  49.  
  50. H3DGLCanvas::H3DGLCanvas(MyH3DCanvasWindow *owner,
  51. QGLContext *shared_context,
  52. int *attribute_list,
  53. QWidget *defaultParent)
  54. : QGLWidget(shared_context,defaultParent),
  55. m_owner(owner)
  56. {
  57.  
  58. }
  59.  
  60. H3DGLCanvas::H3DGLCanvas(MyH3DCanvasWindow *owner,
  61. int *attribute_list,
  62. QWidget *parent)
  63. :QGLWidget(parent),
  64. m_owner(owner)
  65. {
  66.  
  67. }
  68.  
  69. H3DGLCanvas::~H3DGLCanvas()
  70. {
  71.  
  72. }
  73.  
  74. void H3DGLCanvas::initializeGL()
  75. {
  76.  
  77. }
  78.  
  79. void H3DGLCanvas::resizeGL(int width, int height)
  80. {
  81.  
  82. }
  83.  
  84. void H3DGLCanvas::paintGL()
  85. {
  86.  
  87. }
To copy to clipboard, switch view to plain text mode 

And i have another class that is the subclass of the API's class. Here is goes:

Qt Code:
  1. #include "MyH3DCanvasWindow.h"
  2.  
  3. #include <QGLFormat>
  4. #include <vector>
  5.  
  6. #include <H3D/Viewpoint.h>
  7. #include <H3D/INIFile.h>
  8.  
  9.  
  10. #include "H3DGLCanvas.h"
  11.  
  12. //first of add the node to the H3DNodeDatabase system
  13. H3DNodeDatabase MyH3DCanvasWindow::database("MyH3DCanvasWindow",
  14. &(newInstance<MyH3DCanvasWindow>),
  15. typeid(MyH3DCanvasWindow),
  16. &(H3D::H3DWindowNode::database));
  17.  
  18.  
  19. MyH3DCanvasWindow::MyH3DCanvasWindow(QMainWindow *parent ,
  20. H3D::Inst<SFInt32> _width ,
  21. H3D::Inst<SFInt32> _height,
  22. H3D::Inst<SFBool> _fullScreen ,
  23. H3D::Inst<SFBool> _mirrored,
  24. H3D::Inst<RenderMode> _renderMode,
  25. H3D::Inst<SFViewpoint> _viewpoint,
  26. H3D::Inst<SFInt32> _posX,
  27. H3D::Inst<SFInt32> _posY,
  28. H3D::Inst<SFBool> _manualCursorControl,
  29. H3D::Inst<SFString> _cursorType)
  30. : H3DWindowNode(_width,_height,_fullScreen,_mirrored,
  31. _renderMode,_viewpoint,_posX,_posY,_manualCursorControl,
  32. _cursorType),
  33. m_parent(parent),
  34. m_isInitialized(false),
  35. m_useH3DSettings(true),
  36. m_glCanvas(0)
  37.  
  38. {
  39. database.initFields(this);
  40.  
  41. m_haveParent = m_parent != NULL;
  42.  
  43.  
  44. vector<string> valid_values;
  45. getSupportedCursorsTypes(valid_values);
  46.  
  47. cursorType->addValidValues(valid_values.begin(),valid_values.end());
  48.  
  49. //THE FOLLOWING WILL NOT BE HAPENING HERE WHICH HAS BEEN HANDLED IN wxWidget
  50. //SO COMMENT IT OUT!!!
  51. // if(!m_parent)
  52. // {
  53. // m_parent = new QMainWindow();
  54. // }
  55. }
  56.  
  57. MyH3DCanvasWindow::~MyH3DCanvasWindow()
  58. {
  59.  
  60. }
  61.  
  62.  
  63. void MyH3DCanvasWindow::swapBuffers()
  64. {
  65. RenderMode::Mode stereo_mode = renderMode->getRenderMode();
  66.  
  67. int attributeList[8];
  68.  
  69. //initialize the opengl format
  70. // QGLFormat glformat;
  71.  
  72. attributeList[0] = QGL::Rgba;
  73. attributeList[1] = QGL::DoubleBuffer;
  74. attributeList[2] = QGLFormat::depthBufferSize();//glformat.depthBufferSize();
  75. attributeList[3] = 24;
  76. attributeList[4] = QGLFormat::stencilBufferSize();//glformat.stencilBufferSize();
  77. attributeList[5] = 8;
  78.  
  79. if(stereo_mode == RenderMode::QUAD_BUFFERED_STEREO)
  80. {
  81. attributeList[6] = QGL::StereoBuffers;
  82. }
  83.  
  84. attributeList[7] = 0;
  85. }
  86.  
  87. void MyH3DCanvasWindow::initWindow()
  88. {
  89.  
  90. }
  91.  
  92. void MyH3DCanvasWindow::initWindowHandler()
  93. {
  94.  
  95. }
  96.  
  97. void MyH3DCanvasWindow::setFullscreen(bool fullscreen)
  98. {
  99.  
  100. }
  101.  
  102. void MyH3DCanvasWindow::makeWindowActive()
  103. {
  104.  
  105. }
  106.  
  107.  
  108.  
  109. int MyH3DCanvasWindow::setCursorType(const std::string &cursor_type)
  110. {
  111.  
  112. }
  113.  
  114. /// Return the cursor type to use for given modes. This should
  115. /// be implemented for each subclass to choose appropriate cursors.
  116. /// The standard modes are:
  117. /// "DEFAULT" - normal mode
  118. /// "ON_SENSOR_OVER" - when mouse pointer is over a pointing device
  119. /// sensor.
  120. /// "ON_SENSOR_ACTIVE" - when a sensor node is active
  121. /// "ON_NAV_LOOKAT" - when lookat mode is chosen
  122. string MyH3DCanvasWindow::getCursorForMode(const string &)
  123. {
  124.  
  125. }
  126.  
  127. void MyH3DCanvasWindow::getSupportedCursorsTypes(vector<string> &types)
  128. {
  129.  
  130. }
To copy to clipboard, switch view to plain text mode 

Any idea to resolve this ?

Thanks
Sajjad