CMake option 'WITH_HEADLESS' to build blender in headless mode (no x11/xlib) with...
[blender.git] / intern / ghost / intern / GHOST_ISystem.cpp
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file ghost/intern/GHOST_ISystem.cpp
30  *  \ingroup GHOST
31  */
32
33
34 /**
35
36  * $Id$
37  * Copyright (C) 2001 NaN Technologies B.V.
38  * @author      Maarten Gribnau
39  * @date        May 7, 2001
40  */
41
42 #include "GHOST_ISystem.h"
43
44 #ifdef WITH_HEADLESS
45 #       include "GHOST_SystemNULL.h"
46 #elif defined(WIN32)
47 #       include "GHOST_SystemWin32.h"
48 #else
49 #       ifdef __APPLE__
50 #               ifdef GHOST_COCOA
51 #                       include "GHOST_SystemCocoa.h"
52 #               else
53 #                       include "GHOST_SystemCarbon.h"
54 #               endif
55 #       else
56 #               include "GHOST_SystemX11.h"
57 #       endif
58 #endif
59
60
61 GHOST_ISystem* GHOST_ISystem::m_system = 0;
62
63
64 GHOST_TSuccess GHOST_ISystem::createSystem()
65 {
66         GHOST_TSuccess success;
67         if (!m_system) {
68 #ifdef WITH_HEADLESS
69                 m_system = new GHOST_SystemNULL();
70 #elif defined(WIN32)
71                 m_system = new GHOST_SystemWin32 ();
72 #else
73 #       ifdef __APPLE__
74 #               ifdef GHOST_COCOA
75                         m_system = new GHOST_SystemCocoa ();
76 #               else
77                         m_system = new GHOST_SystemCarbon ();
78 #               endif
79 #       else 
80                 m_system = new GHOST_SystemX11 ();
81 #       endif
82 #endif 
83                 success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure;
84         }
85         else {
86                 success = GHOST_kFailure;
87         }
88         if (success) {
89                 success = m_system->init();
90         }
91         return success;
92 }
93
94 GHOST_TSuccess GHOST_ISystem::disposeSystem()
95 {
96         GHOST_TSuccess success = GHOST_kSuccess;
97         if (m_system) {
98                 delete m_system;
99                 m_system = 0;
100         }
101         else {
102                 success = GHOST_kFailure;
103         }
104         return success;
105 }
106
107
108 GHOST_ISystem* GHOST_ISystem::getSystem()
109 {
110         return m_system;
111 }
112