00001 /****************************************************************************\ 00002 * VRVis * 00003 * http://vrvis.sourceforge.net * 00004 * (C) 2004 by Alex Loeffler * 00005 * mailto:aloeffler@users.sourceforge.net * 00006 **************************************************************************** 00007 * License * 00008 * * 00009 * This library is free software; you can redistribute it and/or modify it * 00010 * under the terms of the GNU Library General Public License as published * 00011 * by the Free Software Foundation, version 2. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, but * 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Library General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Library General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00021 \****************************************************************************/ 00022 00023 #ifndef DRAWABLE_HPP 00024 #define DRAWABLE_HPP 00025 00026 #include <map> 00027 #include <vector> 00028 #include <vrj/Draw/OGL/GlContextData.h> 00029 #include "Common.hpp" 00030 00031 namespace vrvis 00032 { 00033 00035 class Drawable 00036 { 00037 // ================================================================== PUBLIC 00038 00039 public: 00040 00041 // ------------------------------------------------------------- Destructor. 00043 00045 virtual ~Drawable(void); 00046 00048 // ----------------------------------------- Forwarded VR Juggler Callbacks. 00050 00052 virtual void init(void); 00054 virtual void contextInit(void); 00056 virtual void contextUpdate(void); 00058 virtual void draw(void) = 0; 00059 00061 // ----------------------------------------- Forwarded VR Juggler Callbacks. 00063 00065 static void initAll(void); 00067 static void contextInitAll(void); 00069 static void contextUpdateAll(void); 00071 static void drawAll(void); 00072 00074 // -------------------------------------------------------------- Draw Flag. 00076 00078 virtual void show(void); 00080 virtual void hide(void); 00082 bool isHidden(void) const; 00083 00085 void setContextUpdateFlag(void); 00086 00088 // =============================================================== PROTECTED 00089 00090 protected: 00091 00092 // ------------------------------------------------------------ Constructor. 00094 00096 Drawable(void); 00097 00099 // ---------------------------------------------------------- Display Lists. 00101 00103 int createListID(const std::string& crName); 00105 int getListID(const std::string& crName); 00107 void drawAllLists(void); 00108 00110 // ================================================================= PRIVATE 00111 00112 private: 00113 00114 // ---------------------------------------------------------------- Friends. 00115 00117 friend class Input; 00118 00119 // --------------------------------------------------------------- Typedefs. 00120 00122 typedef std::vector<Drawable*> DrawableVector; 00124 typedef std::map<std::string, int> StringIntMap; 00125 00126 // ------------------------------------------------------------ Draw Matrix. 00127 00129 static void initMatrixData(const float* cTransRotMatrixData, 00130 const float* cScaleMatrixData); 00131 00132 // ---------------------------------------------------------------- Members. 00133 00135 vrj::GlContextData<StringIntMap> mDisplayLists; 00137 bool mDrawFlag; 00139 bool mContextUpdateFlag; 00140 00141 // --------------------------------------------------------- Static Members. 00142 00144 static DrawableVector sAllDrawables; 00146 static const float* sTransRotMatrixData; 00148 static const float* sScaleMatrixData; 00149 }; 00150 00151 } // End namespace. 00152 00153 #endif // DRAWABLE_HPP 00154