oculus1

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