00001 /**************************************************************************** 00002 00003 File: glscreenviewer.h 00004 Created: by Aidan Lane, January 26, 2004 00005 Updated: by Aidan Lane, February 17, 2004 00006 00007 This file is part of Glitch 00008 Copyright (C) 2003-2004 Monash University, Clayton Campus, Australia 00009 Created by Aidan Lane, under the supervision of Jon McCormack. 00010 00011 This program was developed to aid the students studying the CSE3313 00012 Computer Graphics course at Monash University. 00013 00014 This software may contain portions that are copyright (C) 1993, 00015 Silicon Graphics, Inc. All Rights Reserved. 00016 00017 Glitch is free software; you can redistribute it and/or modify 00018 it under the terms of the GNU General Public License as published by 00019 the Free Software Foundation, version 2. 00020 00021 Glitch is distributed in the hope that it will be useful, 00022 but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 GNU General Public License for more details. 00025 00026 You should have received a copy of the GNU General Public License 00027 along with this program; if not, write to the Free Software 00028 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00029 00030 *****************************************************************************/ 00031 00032 #ifndef __GLSCREENVIEWER_H__ 00033 #define __GLSCREENVIEWER_H__ 00034 00035 00036 #include "3rdparty/qglviewer_subset/qglviewer.h" 00037 #include "glscene.h" 00038 00039 00054 class GLScreenViewer : public QGLViewer 00055 { 00056 public: 00057 GLScreenViewer( const GLScene* const s, QWidget* parent ); 00058 GLScreenViewer( const GLScene* const s, const QGLFormat &format, QWidget* parent ); 00059 00061 bool willReinit() const { return reinitRequired; } 00063 void setReinitRequired( bool required ) { reinitRequired = required; } 00064 00065 GLenum matrixMode() const { return myMatrixMode; } // matrix mode at the current step position 00066 // Note: I have purposely limited the matrix mode to either GL_MODELVIEW or GL_PROJECTION, as to simplify matters for the user 00067 const GLdouble* projectionMatrix() const { return myProjectionMatrix; } // projection matrix at the CURRENT STEP POSITION 00068 const GLdouble* modelviewMatrix() const { return myModelviewMatrix; } // modelview matrix at the CURRENT STEP POSITION 00069 00070 // Auto glClear & glFLush and aspect 1:1 ratio are all enabled by default 00071 bool autoGLClearEnabled() const { return autoGLClear; } 00072 bool autoGLFlushEnabled() const { return autoGLFlush; } 00073 bool aspectRatioKept() const { return keepAspectRatio; } 00074 void setAutoGLClearEnabled( bool enable ) { autoGLClear = enable; } 00075 void setAutoGLFlushEnabled( bool enable ) { autoGLFlush = enable; } 00076 void setKeepAspectRatio( bool enable ); 00077 00078 protected: 00079 void sharedInit(); 00080 00081 virtual void init(); 00082 virtual void draw(); 00087 virtual void preDraw() {} 00092 virtual void postDraw() {} 00093 00094 protected slots: 00095 virtual void setGeometry( int x, int y, int w, int h ); 00096 virtual void setGeometry( const QRect& r ); 00097 00099 virtual void mousePressEvent( QMouseEvent* ) {} 00101 virtual void mouseDoubleClickEvent( QMouseEvent* ) {} 00103 virtual void mouseReleaseEvent( QMouseEvent* ) {} 00105 virtual void mouseMoveEvent( QMouseEvent* ) {} 00107 virtual void wheelEvent( QWheelEvent* ) {} 00108 00111 virtual void keyPressEvent(QKeyEvent* ) {} 00112 00113 private: 00114 const GLScene* const myScene; 00115 00116 GLenum myMatrixMode; 00117 GLdouble myProjectionMatrix[16]; 00118 GLdouble myModelviewMatrix[16]; 00119 00120 bool reinitRequired; 00121 00122 bool keepAspectRatio; 00123 bool autoGLClear; 00124 bool autoGLFlush; 00125 }; 00126 00127 00128 #endif // __GLSCREENVIEWER_H__
1.3.2