Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-06-04 18:12:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-04 18:12:55 +0400
commit4a59928484b93a6c3876c0c8b065f6d313640804 (patch)
tree97dbc269d53121168026ff2896131a4a05488d39 /intern
parenta440679c57f6a309079a0253d557716044d78e6c (diff)
CMake option 'WITH_HEADLESS' to build blender in headless mode (no x11/xlib) with NULL ghost classe.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/CMakeLists.txt37
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerNULL.h51
-rw-r--r--intern/ghost/intern/GHOST_ISystem.cpp8
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp4
-rw-r--r--intern/ghost/intern/GHOST_SystemNULL.h93
-rw-r--r--intern/ghost/intern/GHOST_WindowNULL.h96
6 files changed, 285 insertions, 4 deletions
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 065aa68dd3d..922f6918392 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -89,7 +89,42 @@ set(SRC
intern/GHOST_WindowManager.h
)
-if(APPLE)
+if(WITH_HEADLESS)
+ list(APPEND SRC
+ intern/GHOST_DisplayManagerNULL.h
+ intern/GHOST_SystemNULL.h
+ intern/GHOST_WindowNULL.h
+ )
+ add_definitions(-DWITH_HEADLESS)
+
+ # ack, this is still system dependant
+ if(APPLE)
+ if(WITH_COCOA)
+ list(APPEND SRC
+ intern/GHOST_SystemPathsCocoa.mm
+ intern/GHOST_SystemPathsCocoa.h
+ )
+ else()
+ list(APPEND SRC
+ intern/GHOST_SystemPathsCarbon.cpp
+ intern/GHOST_SystemPathsCarbon.h
+ )
+ endif()
+ elseif(UNIX)
+ list(APPEND SRC
+ intern/GHOST_SystemPathsX11.cpp
+ intern/GHOST_SystemPathsX11.h
+ )
+ elseif(WIN32)
+
+ list(APPEND SRC
+ intern/GHOST_SystemPathsWin32.cpp
+
+ intern/GHOST_SystemPathsWin32.h
+ )
+ endif()
+
+elseif(APPLE)
if(WITH_COCOA)
list(APPEND SRC
intern/GHOST_DisplayManagerCocoa.mm
diff --git a/intern/ghost/intern/GHOST_DisplayManagerNULL.h b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
new file mode 100644
index 00000000000..e2902afd29b
--- /dev/null
+++ b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
@@ -0,0 +1,51 @@
+/*
+ * $Id:
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerNULL.h
+ * \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerNULL class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_NULL_H_
+#define _GHOST_DISPLAY_MANAGER_NULL_H_
+
+#include "GHOST_DisplayManager.h"
+#include "GHOST_SystemNULL.h"
+
+class GHOST_SystemNULL;
+
+class GHOST_DisplayManagerNULL : public GHOST_DisplayManager
+{
+public:
+ GHOST_DisplayManagerNULL( GHOST_SystemNULL *system ) : GHOST_DisplayManager(), m_system(system) { /* nop */ }
+ GHOST_TSuccess getNumDisplays( GHOST_TUns8& numDisplays ) const { return GHOST_kFailure; }
+ GHOST_TSuccess getNumDisplaySettings( GHOST_TUns8 display, GHOST_TInt32& numSettings ) const{ return GHOST_kFailure; }
+ GHOST_TSuccess getDisplaySetting( GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting ) const { return GHOST_kFailure; }
+ GHOST_TSuccess getCurrentDisplaySetting( GHOST_TUns8 display, GHOST_DisplaySetting& setting ) const { return getDisplaySetting(display,GHOST_TInt32(0),setting); }
+ GHOST_TSuccess setCurrentDisplaySetting( GHOST_TUns8 display, const GHOST_DisplaySetting& setting ){ return GHOST_kSuccess; }
+
+private :
+ GHOST_SystemNULL * m_system;
+};
+
+#endif /* _GHOST_DISPLAY_MANAGER_NULL_H_ */
diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp
index 040164e2c40..7f170d2e876 100644
--- a/intern/ghost/intern/GHOST_ISystem.cpp
+++ b/intern/ghost/intern/GHOST_ISystem.cpp
@@ -41,7 +41,9 @@
#include "GHOST_ISystem.h"
-#ifdef WIN32
+#ifdef WITH_HEADLESS
+# include "GHOST_SystemNULL.h"
+#elif defined(WIN32)
# include "GHOST_SystemWin32.h"
#else
# ifdef __APPLE__
@@ -63,7 +65,9 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
{
GHOST_TSuccess success;
if (!m_system) {
-#ifdef WIN32
+#ifdef WITH_HEADLESS
+ m_system = new GHOST_SystemNULL();
+#elif defined(WIN32)
m_system = new GHOST_SystemWin32 ();
#else
# ifdef __APPLE__
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index 95626ec26ea..7721b1708f9 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -81,7 +81,9 @@ GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window,
#if 0
printf("%i client \n", Pid);
#endif
- #if defined(_WIN32) || defined(__APPLE__)
+ #if defined(WITH_HEADLESS)
+ /* do nothing */
+ #elif defined(_WIN32) || defined(__APPLE__)
m_DeviceHandle = ndofDeviceOpen((void *)&currentNdofValues);
#else
GHOST_SystemX11 *sys;
diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h
new file mode 100644
index 00000000000..00277449ceb
--- /dev/null
+++ b/intern/ghost/intern/GHOST_SystemNULL.h
@@ -0,0 +1,93 @@
+/*
+ * $Id:
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_SystemNULL.h
+ * \ingroup GHOST
+ * Declaration of GHOST_SystemNULL class.
+ */
+
+#ifndef _GHOST_SYSTEM_NULL_H_
+#define _GHOST_SYSTEM_NULL_H_
+
+#include "GHOST_System.h"
+#include "../GHOST_Types.h"
+#include "GHOST_DisplayManagerNULL.h"
+#include "GHOST_WindowNULL.h"
+
+class GHOST_WindowNULL;
+
+class GHOST_SystemNULL : public GHOST_System {
+public:
+
+ GHOST_SystemNULL( ) : GHOST_System() { /* nop */ }
+ ~GHOST_SystemNULL() { /* nop */ }
+ bool processEvents(bool waitForEvent) { return false; }
+ int toggleConsole(int action) { return 0; }
+ GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const { return GHOST_kSuccess; }
+ GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const { return GHOST_kSuccess; }
+ GHOST_TUns8 *getClipboard(bool selection) const { return NULL; }
+ void putClipboard(GHOST_TInt8 *buffer, bool selection) const { /* nop */ }
+ GHOST_TUns64 getMilliSeconds( ) const { return 0; }
+ GHOST_TUns8 getNumDisplays( ) const { return GHOST_TUns8(1); }
+ GHOST_TSuccess getCursorPosition( GHOST_TInt32& x, GHOST_TInt32& y ) const { return GHOST_kFailure; }
+ GHOST_TSuccess setCursorPosition( GHOST_TInt32 x, GHOST_TInt32 y ) { return GHOST_kFailure; }
+ void getMainDisplayDimensions( GHOST_TUns32& width, GHOST_TUns32& height ) const { /* nop */ }
+
+ GHOST_TSuccess init() {
+ GHOST_TSuccess success = GHOST_System::init();
+
+ if (success) {
+ m_displayManager = new GHOST_DisplayManagerNULL(this);
+
+ if (m_displayManager) {
+ return GHOST_kSuccess;
+ }
+ }
+
+ return GHOST_kFailure;
+ }
+
+ GHOST_IWindow* createWindow(
+ const STR_String& title,
+ GHOST_TInt32 left,
+ GHOST_TInt32 top,
+ GHOST_TUns32 width,
+ GHOST_TUns32 height,
+ GHOST_TWindowState state,
+ GHOST_TDrawingContextType type,
+ bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples,
+ const GHOST_TEmbedderWindowID parentWindow
+ ) {
+ return new GHOST_WindowNULL (this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1);
+ }
+};
+
+#endif
+
+
+
+
+
+
+
diff --git a/intern/ghost/intern/GHOST_WindowNULL.h b/intern/ghost/intern/GHOST_WindowNULL.h
new file mode 100644
index 00000000000..c0162f412c5
--- /dev/null
+++ b/intern/ghost/intern/GHOST_WindowNULL.h
@@ -0,0 +1,96 @@
+/*
+ * $Id:
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_WindowNULL.h
+ * \ingroup GHOST
+ * Declaration of GHOST_WindowNULL class.
+ */
+
+#ifndef _GHOST_WINDOWNULL_H_
+#define _GHOST_WINDOWNULL_H_
+
+#include "GHOST_Window.h"
+
+#include <map>
+
+class STR_String;
+class GHOST_SystemNULL;
+
+class GHOST_WindowNULL : public GHOST_Window
+{
+public:
+ const GHOST_TabletData* GetTabletData() { return NULL; }
+
+ GHOST_WindowNULL(
+ GHOST_SystemNULL *system,
+ const STR_String& title,
+ GHOST_TInt32 left,
+ GHOST_TInt32 top,
+ GHOST_TUns32 width,
+ GHOST_TUns32 height,
+ GHOST_TWindowState state,
+ const GHOST_TEmbedderWindowID parentWindow,
+ GHOST_TDrawingContextType type,
+ const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples
+ ) :
+ GHOST_Window(title,left,top,width,height,state,type,stereoVisual,numOfAASamples),
+ m_system (system)
+ {
+ setTitle(title);
+ }
+
+protected:
+ GHOST_TSuccess installDrawingContext( GHOST_TDrawingContextType type ){ return GHOST_kSuccess; }
+ GHOST_TSuccess removeDrawingContext( ){ return GHOST_kSuccess; }
+ GHOST_TSuccess setWindowCursorGrab( GHOST_TGrabCursorMode mode ){ return GHOST_kSuccess; }
+ GHOST_TSuccess setWindowCursorShape( GHOST_TStandardCursor shape ){ return GHOST_kSuccess; }
+ GHOST_TSuccess setWindowCustomCursorShape( GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY ) { return GHOST_kSuccess; }
+ GHOST_TSuccess setWindowCustomCursorShape( GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color ){ return GHOST_kSuccess; }
+
+ bool getValid( ) const { return true; }
+ void setTitle( const STR_String& title ){ /* nothing */ }
+ void getTitle( STR_String& title ) const { title= "untitled"; }
+ void getWindowBounds( GHOST_Rect& bounds ) const { getClientBounds(bounds); }
+ void getClientBounds( GHOST_Rect& bounds ) const { /* nothing */ }
+ GHOST_TSuccess setClientWidth( GHOST_TUns32 width ){ return GHOST_kFailure; }
+ GHOST_TSuccess setClientHeight( GHOST_TUns32 height ){ return GHOST_kFailure; }
+ GHOST_TSuccess setClientSize( GHOST_TUns32 width, GHOST_TUns32 height ){ return GHOST_kFailure; }
+ void screenToClient( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const { outX = inX; outY = inY; }
+ void clientToScreen( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const { outX = inX; outY = inY; }
+ GHOST_TSuccess swapBuffers( ){ return GHOST_kFailure; }
+ GHOST_TSuccess activateDrawingContext( ){ return GHOST_kFailure; }
+ ~GHOST_WindowNULL( ){ /* nothing */ }
+ GHOST_TSuccess setWindowCursorVisibility( bool visible ){ return GHOST_kSuccess; }
+ GHOST_TSuccess setState(GHOST_TWindowState state) { return GHOST_kSuccess; }
+ GHOST_TWindowState getState() const { return GHOST_kWindowStateNormal; }
+ GHOST_TSuccess invalidate() { return GHOST_kSuccess; }
+ GHOST_TSuccess setOrder(GHOST_TWindowOrder order) { return GHOST_kSuccess; }
+
+
+private :
+ GHOST_SystemNULL * m_system;
+};
+
+
+#endif // _GHOST_WINDOWNULL_H_