nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #include "GLResource.h" 00024 #include "RunTimeStats.h" 00025 #include "NuxGraphicsResources.h" 00026 #include "FontTexture.h" 00027 #include "GlobalGraphicsInitializer.h" 00028 00029 namespace nux 00030 { 00031 00032 static NuxGraphicsGlobalSingletonInitializer *GNuxGraphicsGlobalInitializer = 0; 00033 00034 static void SystemStart() 00035 { 00036 static t_u8 StaticBuffer[sizeof (NuxGraphicsGlobalSingletonInitializer) ]; 00037 // Placement new in our reserved buffer. 00038 GNuxGraphicsGlobalInitializer = new (StaticBuffer) NuxGraphicsGlobalSingletonInitializer(); 00039 00040 //GLogDevice.AddOutputDevice( &NUX_GLOBAL_OBJECT_INSTANCE(NOutputLogFile) ); 00041 //GLogDevice.AddOutputDevice( &NUX_GLOBAL_OBJECT_INSTANCE(NOutputVisualDebugConsole) ); 00042 } 00043 00044 static void SystemShutdown() 00045 { 00046 // Manually destroy initializer 00047 if (GNuxGraphicsGlobalInitializer) 00048 GNuxGraphicsGlobalInitializer->~NuxGraphicsGlobalSingletonInitializer(); 00049 00050 GNuxGraphicsGlobalInitializer = 0; 00051 00052 } 00053 00054 bool NuxGraphicsGlobalSingletonInitializer::m_NuxGraphicsGlobalObjectsReady = false; 00055 NuxGraphicsGlobalSingletonInitializer::NuxGraphicsGlobalSingletonInitializer() 00056 { 00057 m_NuxGraphicsGlobalObjectsReady = true; 00058 } 00059 00060 NuxGraphicsGlobalSingletonInitializer::~NuxGraphicsGlobalSingletonInitializer() 00061 { 00062 m_NuxGraphicsGlobalObjectsReady = false; 00063 } 00064 00065 bool NuxGraphicsGlobalSingletonInitializer::Ready() 00066 { 00067 return m_NuxGraphicsGlobalObjectsReady; 00068 } 00069 00070 int NuxGraphicsGlobalInitializer::m_Count = 0; 00071 NuxGraphicsGlobalInitializer::NuxGraphicsGlobalInitializer() 00072 { 00073 if (m_Count++ == 0) 00074 { 00075 SystemStart(); 00076 } 00077 } 00078 00079 NuxGraphicsGlobalInitializer::~NuxGraphicsGlobalInitializer() 00080 { 00081 if (--m_Count == 0) 00082 { 00083 SystemShutdown(); 00084 } 00085 } 00086 00087 }