Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://www.visualizationlibrary.com */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #include <vlCore/VisualizationLibrary.hpp> 00033 #include <vlCore/LoadWriterManager.hpp> 00034 #include <vlGraphics/Rendering.hpp> 00035 #include <vlGraphics/FontManager.hpp> 00036 00037 using namespace vl; 00038 00039 #if defined(VL_IO_3D_3DS) 00040 #include "plugins/vl3DS.hpp" 00041 #endif 00042 #if defined(VL_IO_3D_OBJ) 00043 #include "plugins/vlOBJ.hpp" 00044 #endif 00045 #if defined(VL_IO_3D_AC3D) 00046 #include "plugins/vlAC3D.hpp" 00047 #endif 00048 #if defined(VL_IO_3D_PLY) 00049 #include "plugins/vlPLY.hpp" 00050 #endif 00051 #if defined(VL_IO_3D_STL) 00052 #include "plugins/vlSTL.hpp" 00053 #endif 00054 #if defined(VL_IO_3D_MD2) 00055 #include "plugins/vlMD2.hpp" 00056 #endif 00057 00058 //------------------------------------------------------------------------------ 00059 // VL misc 00060 //------------------------------------------------------------------------------ 00061 namespace 00062 { 00063 bool gInitializedGraphics = false; 00064 }; 00065 //----------------------------------------------------------------------------- 00066 // Default FontManager 00067 //----------------------------------------------------------------------------- 00068 namespace 00069 { 00070 ref<FontManager> gDefaultFontManager = NULL; 00071 } 00072 FontManager* vl::defFontManager() 00073 { 00074 return gDefaultFontManager.get(); 00075 } 00076 void vl::setDefFontManager(FontManager* fm) 00077 { 00078 gDefaultFontManager = fm; 00079 } 00080 00081 //------------------------------------------------------------------------------ 00082 void VisualizationLibrary::initGraphics() 00083 { 00084 VL_CHECK(!gInitializedGraphics); 00085 if (gInitializedGraphics) 00086 { 00087 Log::bug("VisualizationLibrary::initGraphics(): Visualization Library Graphics is already initialized!\n"); 00088 return; 00089 } 00090 00091 // --- Init Graphics --- 00092 00093 // Install default FontManager 00094 gDefaultFontManager = new FontManager; 00095 00096 // Register 3D modules 00097 #if defined(VL_IO_3D_OBJ) 00098 registerLoadWriter(new LoadWriterOBJ); 00099 #endif 00100 #if defined(VL_IO_3D_3DS) 00101 registerLoadWriter(new LoadWriter3DS); 00102 #endif 00103 #if defined(VL_IO_3D_AC3D) 00104 registerLoadWriter(new LoadWriterAC3D); 00105 #endif 00106 #if defined(VL_IO_3D_PLY) 00107 registerLoadWriter(new LoadWriterPLY); 00108 #endif 00109 #if defined(VL_IO_3D_STL) 00110 registerLoadWriter(new LoadWriterSTL); 00111 #endif 00112 #if defined(VL_IO_3D_MD2) 00113 registerLoadWriter(new LoadWriterMD2); 00114 #endif 00115 00116 // --- 00117 00118 // Initialized = on 00119 gInitializedGraphics = true; 00120 } 00121 //------------------------------------------------------------------------------ 00122 void VisualizationLibrary::shutdownGraphics() 00123 { 00124 if (gInitializedGraphics) 00125 { 00126 gInitializedGraphics = false; 00127 00128 // --- Dispose Graphics --- 00129 00130 // Dispose default FontManager 00131 gDefaultFontManager->releaseAllFonts(); 00132 gDefaultFontManager = NULL; 00133 } 00134 } 00135 //------------------------------------------------------------------------------ 00136 void VisualizationLibrary::init(bool log_info) 00137 { 00138 initCore(log_info); 00139 initGraphics(); 00140 } 00141 //------------------------------------------------------------------------------ 00142 void VisualizationLibrary::shutdown() 00143 { 00144 shutdownGraphics(); 00145 shutdownCore(); 00146 } 00147 //------------------------------------------------------------------------------ 00148 bool VisualizationLibrary::isGraphicsInitialized() { return gInitializedGraphics; } 00149 //------------------------------------------------------------------------------