oculus1

annotate libovr/Src/Kernel/OVR_System.cpp @ 1:e2f9e4603129

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