oculus1
view libovr/Src/Kernel/OVR_System.cpp @ 21:ef4c9d8eeca7
added shaderless distortion method
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 02 Oct 2013 04:09:37 +0300 |
parents | e2f9e4603129 |
children |
line source
1 /************************************************************************************
3 Filename : OVR_System.cpp
4 Content : General kernel initialization/cleanup, including that
5 of the memory allocator.
6 Created : September 19, 2012
7 Notes :
9 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
11 Use of this software is subject to the terms of the Oculus license
12 agreement provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
15 ************************************************************************************/
17 #include "OVR_System.h"
18 #include "OVR_Threads.h"
19 #include "OVR_Timer.h"
21 namespace OVR {
23 // ***** OVR::System Implementation
25 // Initializes System core, installing allocator.
26 void System::Init(Log* log, Allocator *palloc)
27 {
28 if (!Allocator::GetInstance())
29 {
30 Log::SetGlobalLog(log);
31 Timer::initializeTimerSystem();
32 Allocator::setInstance(palloc);
33 }
34 else
35 {
36 OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
37 }
38 }
40 void System::Destroy()
41 {
42 if (Allocator::GetInstance())
43 {
44 // Wait for all threads to finish; this must be done so that memory
45 // allocator and all destructors finalize correctly.
46 #ifdef OVR_ENABLE_THREADS
47 Thread::FinishAllThreads();
48 #endif
50 // Shutdown heap and destroy SysAlloc singleton, if any.
51 Allocator::GetInstance()->onSystemShutdown();
52 Allocator::setInstance(0);
54 Timer::shutdownTimerSystem();
55 Log::SetGlobalLog(Log::GetDefaultLog());
56 }
57 else
58 {
59 OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
60 }
61 }
63 // Returns 'true' if system was properly initialized.
64 bool System::IsInitialized()
65 {
66 return Allocator::GetInstance() != 0;
67 }
69 } // OVR