Revision: 38332
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38332
Author:   campbellbarton
Date:     2011-07-12 13:17:54 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
build option to use SDL 1.3 for GHOST rather then X11/Win32/Cocoa api's,
This opens up the option for blender to be more easily ported to other devices, 
OS's.

TODO
- continuous grab.
- text glitch with multiple windows (was a bug in X11 too for a while, will 
check on this)

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/intern/ghost/CMakeLists.txt
    trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp
    trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp

Added Paths:
-----------
    trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp
    trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.h
    trunk/blender/intern/ghost/intern/GHOST_SystemSDL.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemSDL.h
    trunk/blender/intern/ghost/intern/GHOST_WindowSDL.cpp
    trunk/blender/intern/ghost/intern/GHOST_WindowSDL.h

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt        2011-07-12 13:11:00 UTC (rev 38331)
+++ trunk/blender/CMakeLists.txt        2011-07-12 13:17:54 UTC (rev 38332)
@@ -109,6 +109,9 @@
 option(WITH_AUDASPACE    "Build with blenders audio library" ON)
 mark_as_advanced(WITH_AUDASPACE)
 
+option(WITH_SDL_GHOST    "Enable SDL for sound and joystick support" OFF)
+mark_as_advanced(WITH_SDL_GHOST)
+
 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server 
mode only)" OFF)
 mark_as_advanced(WITH_HEADLESS)
 
@@ -209,6 +212,10 @@
        message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG 
require WITH_AUDASPACE")
 endif()
 
+if(NOT WITH_SDL AND WITH_SDL_GHOST)
+       message(FATAL_ERROR "WITH_SDL_GHOST requires WITH_SDL to be ON")
+endif()
+
 if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
        message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
 endif()

Modified: trunk/blender/intern/ghost/CMakeLists.txt
===================================================================
--- trunk/blender/intern/ghost/CMakeLists.txt   2011-07-12 13:11:00 UTC (rev 
38331)
+++ trunk/blender/intern/ghost/CMakeLists.txt   2011-07-12 13:17:54 UTC (rev 
38332)
@@ -89,14 +89,28 @@
        intern/GHOST_WindowManager.h
 )
 
-if(WITH_HEADLESS)
-       list(APPEND SRC
-               intern/GHOST_DisplayManagerNULL.h
-               intern/GHOST_SystemNULL.h
-               intern/GHOST_WindowNULL.h
-       )
-       add_definitions(-DWITH_HEADLESS)
+if(WITH_HEADLESS OR WITH_SDL_GHOST)
+       if(WITH_HEADLESS)
+               list(APPEND SRC
+                       intern/GHOST_DisplayManagerNULL.h
+                       intern/GHOST_SystemNULL.h
+                       intern/GHOST_WindowNULL.h
+               )
+               add_definitions(-DWITH_HEADLESS)
+       else()
+               list(APPEND SRC
+                       intern/GHOST_DisplayManagerSDL.cpp
+                       intern/GHOST_SystemSDL.cpp
+                       intern/GHOST_WindowSDL.cpp
 
+                       intern/GHOST_DisplayManagerSDL.h
+                       intern/GHOST_SystemSDL.h
+                       intern/GHOST_WindowSDL.h
+               )
+               add_definitions(-DWITH_SDL_GHOST)
+       endif()
+
+
        # ack, this is still system dependant
        if(APPLE)
                if(WITH_COCOA)
@@ -124,6 +138,8 @@
                )
        endif()
 
+       list(APPEND INC_SYS ${SDL_INCLUDE_DIR})
+
 elseif(APPLE)
        if(WITH_COCOA)
                list(APPEND SRC

Added: trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp               
                (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp       
2011-07-12 13:17:54 UTC (rev 38332)
@@ -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_DisplayManagerSDL.cpp
+ *  \ingroup GHOST
+ */
+
+#include "GHOST_SystemSDL.h"
+#include "GHOST_DisplayManagerSDL.h"
+
+GHOST_DisplayManagerSDL::GHOST_DisplayManagerSDL(GHOST_SystemSDL *system)
+    :
+      GHOST_DisplayManager(),
+      m_system(system)
+{
+       /* do nothing */
+}
+
+GHOST_TSuccess
+GHOST_DisplayManagerSDL::getNumDisplays(GHOST_TUns8& numDisplays)
+{
+       numDisplays=  SDL_GetNumVideoDisplays();
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplaySettings(GHOST_TUns8 
display,
+                                                              GHOST_TInt32& 
numSettings)
+{
+       GHOST_ASSERT(display < 1, "Only single display systems are currently 
supported.\n");
+       numSettings= GHOST_TInt32(1);
+       return GHOST_kSuccess;
+}
+
+GHOST_TSuccess
+GHOST_DisplayManagerSDL::getDisplaySetting(GHOST_TUns8 display,
+                                           GHOST_TInt32 index,
+                                           GHOST_DisplaySetting& setting)
+{
+
+       GHOST_ASSERT(display < 1, "Only single display systems are currently 
supported.\n");
+       GHOST_ASSERT(index < 1, "Requested setting outside of valid range.\n");
+       SDL_DisplayMode mode;
+
+       SDL_GetDesktopDisplayMode(display, &mode);
+
+       setting.xPixels= mode.w;
+       setting.yPixels= mode.h;
+       setting.bpp= SDL_BYTESPERPIXEL(mode.format);
+       /* assume 60 when unset */
+       setting.frequency= mode.refresh_rate ? mode.refresh_rate : 60;
+
+       return GHOST_kSuccess;
+}
+
+GHOST_TSuccess
+GHOST_DisplayManagerSDL::getCurrentDisplaySetting(GHOST_TUns8 display,
+                                                  GHOST_DisplaySetting& 
setting)
+{
+       return getDisplaySetting(display,GHOST_TInt32(0),setting);
+}
+
+GHOST_TSuccess
+GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display,
+                                                   const GHOST_DisplaySetting& 
setting)
+{
+       // This is never going to work robustly in X
+       // but it's currently part of the full screen interface
+
+       // we fudge it for now.
+
+       return GHOST_kSuccess;
+}

Added: trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.h                 
        (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_DisplayManagerSDL.h 2011-07-12 
13:17:54 UTC (rev 38332)
@@ -0,0 +1,67 @@
+/*
+ * $Id: GHOST_DisplayManagerSDL.h 37194 2011-06-05 00:10:20Z gsrb3d $
+ * ***** 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_DisplayManagerSDL.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerSDL class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_SDL_H_
+#define _GHOST_DISPLAY_MANAGER_SDL_H_
+
+#include "GHOST_DisplayManager.h"
+
+#include "SDL.h"
+
+class GHOST_SystemSDL;
+
+class GHOST_DisplayManagerSDL : public GHOST_DisplayManager
+{
+public:
+       GHOST_DisplayManagerSDL(GHOST_SystemSDL *system);
+
+       GHOST_TSuccess
+       getNumDisplays(GHOST_TUns8& numDisplays);
+
+       GHOST_TSuccess
+       getNumDisplaySettings(GHOST_TUns8 display,
+                             GHOST_TInt32& numSettings);
+
+       GHOST_TSuccess
+       getDisplaySetting(GHOST_TUns8 display,
+                         GHOST_TInt32 index,
+                         GHOST_DisplaySetting& setting);
+
+       GHOST_TSuccess
+       getCurrentDisplaySetting(GHOST_TUns8 display,
+                                GHOST_DisplaySetting& setting);
+
+       GHOST_TSuccess
+       setCurrentDisplaySetting(GHOST_TUns8 display,
+                                const GHOST_DisplaySetting& setting);
+
+private :
+       GHOST_SystemSDL * m_system;
+};
+
+#endif /* _GHOST_DISPLAY_MANAGER_SDL_H_ */

Modified: trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp 2011-07-12 13:11:00 UTC 
(rev 38331)
+++ trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp 2011-07-12 13:17:54 UTC 
(rev 38332)
@@ -43,6 +43,8 @@
 
 #ifdef WITH_HEADLESS
 #      include "GHOST_SystemNULL.h"
+#elif defined(WITH_SDL_GHOST)
+#      include "GHOST_SystemSDL.h"
 #elif defined(WIN32)
 #      include "GHOST_SystemWin32.h"
 #else
@@ -67,6 +69,8 @@
        if (!m_system) {
 #ifdef WITH_HEADLESS
                m_system = new GHOST_SystemNULL();
+#elif defined(WITH_SDL_GHOST)
+               m_system = new GHOST_SystemSDL();
 #elif defined(WIN32)
                m_system = new GHOST_SystemWin32 ();
 #else

Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp     2011-07-12 
13:11:00 UTC (rev 38331)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp     2011-07-12 
13:17:54 UTC (rev 38332)
@@ -85,6 +85,8 @@
                        /* do nothing */
                #elif defined(_WIN32) || defined(__APPLE__)
                        m_DeviceHandle = ndofDeviceOpen((void 
*)&currentNdofValues);    
+               #elif defined(WITH_SDL_GHOST)
+                       /* do nothing */
                #else
                        GHOST_SystemX11 *sys;
                        sys = 
static_cast<GHOST_SystemX11*>(GHOST_ISystem::getSystem());

Added: trunk/blender/intern/ghost/intern/GHOST_SystemSDL.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemSDL.cpp                       
        (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemSDL.cpp       2011-07-12 
13:17:54 UTC (rev 38332)
@@ -0,0 +1,500 @@
+/*
+ * $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_SystemSDL.cpp
+ *  \ingroup GHOST
+ */
+

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to