/**************************************************************************** Copyright (C) 2002-2008 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.3.6. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef SIMPLEVIEWER_H #define SIMPLEVIEWER_H #include #include #include #include #include #include #include "../interfaces/visitor.h" #include "../glnodes/glnode.h" #include "../glnodes/scenegroup.h" #include "../glnodes/shapes.h" #include QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram) class Viewer : public QGLViewer, protected QOpenGLFunctions_4_0_Core, public Visitor { Q_OBJECT public: Viewer(); ~Viewer(); virtual void visit(SceneGroup &s); virtual void visit(Cube &s); public slots: void cleanup(); void changeColor(QColor); signals: int shapeSelected(int); protected : virtual void draw(); virtual void drawSkybox(); virtual void init(); virtual void mouseMoveEvent(QMouseEvent* e); virtual void mouseReleaseEvent(QMouseEvent* e); virtual void mousePressEvent(QMouseEvent *e); SceneGroup root; std::stack modelStack; private: void initShaders(); void initGeometries(); void deselect(); Shape* pickGeom(int, int); // shader switching variables and constants; QOpenGLShaderProgram *colorPickerShaderProgram; QOpenGLShaderProgram *textureRenderShaderprogram; QOpenGLShaderProgram *skyboxRenderShaderProgram; QOpenGLShaderProgram *m_program; int m_vPositionLocation; int m_colorLocation; int m_projMatrixLocation; int m_mvMatrixLocation; int s_texCoordsLocation; int s_vPositionLocation; int s_mvMatrixLocation; int s_colorLocation; int s_projMatrixLocation; int s_skyboxCubemapLocation; int s_vUvLocation; QOpenGLTexture *s_texture; SceneGroup* activeCell; QColor* activeColor; int activeShape; enum VAO_IDs { VAO_Cube, NumVAOs }; enum Buffer_IDs { VBO_Cube, NumBuffers }; GLuint m_VAOs[NumVAOs]; GLuint m_Buffers[NumBuffers]; Shape* generateShapeFromIndex(int); QQuaternion rot; unsigned int frame; }; #endif // SIMPLEVIEWER_H