oculus1

diff libovr/Src/Kernel/OVR_System.cpp @ 3:b069a5c27388

added a couple more stuff, fixed all the LibOVR line endings
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 15 Sep 2013 04:10:05 +0300
parents e2f9e4603129
children
line diff
     1.1 --- a/libovr/Src/Kernel/OVR_System.cpp	Sat Sep 14 17:51:03 2013 +0300
     1.2 +++ b/libovr/Src/Kernel/OVR_System.cpp	Sun Sep 15 04:10:05 2013 +0300
     1.3 @@ -1,1 +1,70 @@
     1.4 -/************************************************************************************
     1.5 
     1.6 Filename    :   OVR_System.cpp
     1.7 Content     :   General kernel initialization/cleanup, including that
     1.8                 of the memory allocator.
     1.9 Created     :   September 19, 2012
    1.10 Notes       : 
    1.11 
    1.12 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
    1.13 
    1.14 Use of this software is subject to the terms of the Oculus license
    1.15 agreement provided at the time of installation or download, or which
    1.16 otherwise accompanies this software in either electronic or hard copy form.
    1.17 
    1.18 ************************************************************************************/
    1.19 
    1.20 #include "OVR_System.h"
    1.21 #include "OVR_Threads.h"
    1.22 #include "OVR_Timer.h"
    1.23 
    1.24 namespace OVR {
    1.25 
    1.26 // *****  OVR::System Implementation
    1.27 
    1.28 // Initializes System core, installing allocator.
    1.29 void System::Init(Log* log, Allocator *palloc)
    1.30 {    
    1.31     if (!Allocator::GetInstance())
    1.32     {
    1.33         Log::SetGlobalLog(log);
    1.34         Timer::initializeTimerSystem();
    1.35         Allocator::setInstance(palloc);
    1.36     }
    1.37     else
    1.38     {
    1.39         OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
    1.40     }
    1.41 }
    1.42 
    1.43 void System::Destroy()
    1.44 {    
    1.45     if (Allocator::GetInstance())
    1.46     {
    1.47         // Wait for all threads to finish; this must be done so that memory
    1.48         // allocator and all destructors finalize correctly.
    1.49 #ifdef OVR_ENABLE_THREADS
    1.50         Thread::FinishAllThreads();
    1.51 #endif
    1.52 
    1.53         // Shutdown heap and destroy SysAlloc singleton, if any.
    1.54         Allocator::GetInstance()->onSystemShutdown();
    1.55         Allocator::setInstance(0);
    1.56 
    1.57         Timer::shutdownTimerSystem();
    1.58         Log::SetGlobalLog(Log::GetDefaultLog());
    1.59     }
    1.60     else
    1.61     {
    1.62         OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
    1.63     }
    1.64 }
    1.65 
    1.66 // Returns 'true' if system was properly initialized.
    1.67 bool System::IsInitialized()
    1.68 {
    1.69     return Allocator::GetInstance() != 0;
    1.70 }
    1.71 
    1.72 } // OVR
    1.73 
    1.74 \ No newline at end of file
    1.75 +/************************************************************************************
    1.76 +
    1.77 +Filename    :   OVR_System.cpp
    1.78 +Content     :   General kernel initialization/cleanup, including that
    1.79 +                of the memory allocator.
    1.80 +Created     :   September 19, 2012
    1.81 +Notes       : 
    1.82 +
    1.83 +Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
    1.84 +
    1.85 +Use of this software is subject to the terms of the Oculus license
    1.86 +agreement provided at the time of installation or download, or which
    1.87 +otherwise accompanies this software in either electronic or hard copy form.
    1.88 +
    1.89 +************************************************************************************/
    1.90 +
    1.91 +#include "OVR_System.h"
    1.92 +#include "OVR_Threads.h"
    1.93 +#include "OVR_Timer.h"
    1.94 +
    1.95 +namespace OVR {
    1.96 +
    1.97 +// *****  OVR::System Implementation
    1.98 +
    1.99 +// Initializes System core, installing allocator.
   1.100 +void System::Init(Log* log, Allocator *palloc)
   1.101 +{    
   1.102 +    if (!Allocator::GetInstance())
   1.103 +    {
   1.104 +        Log::SetGlobalLog(log);
   1.105 +        Timer::initializeTimerSystem();
   1.106 +        Allocator::setInstance(palloc);
   1.107 +    }
   1.108 +    else
   1.109 +    {
   1.110 +        OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
   1.111 +    }
   1.112 +}
   1.113 +
   1.114 +void System::Destroy()
   1.115 +{    
   1.116 +    if (Allocator::GetInstance())
   1.117 +    {
   1.118 +        // Wait for all threads to finish; this must be done so that memory
   1.119 +        // allocator and all destructors finalize correctly.
   1.120 +#ifdef OVR_ENABLE_THREADS
   1.121 +        Thread::FinishAllThreads();
   1.122 +#endif
   1.123 +
   1.124 +        // Shutdown heap and destroy SysAlloc singleton, if any.
   1.125 +        Allocator::GetInstance()->onSystemShutdown();
   1.126 +        Allocator::setInstance(0);
   1.127 +
   1.128 +        Timer::shutdownTimerSystem();
   1.129 +        Log::SetGlobalLog(Log::GetDefaultLog());
   1.130 +    }
   1.131 +    else
   1.132 +    {
   1.133 +        OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
   1.134 +    }
   1.135 +}
   1.136 +
   1.137 +// Returns 'true' if system was properly initialized.
   1.138 +bool System::IsInitialized()
   1.139 +{
   1.140 +    return Allocator::GetInstance() != 0;
   1.141 +}
   1.142 +
   1.143 +} // OVR
   1.144 +