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/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-11-17 14:35:36 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2014-11-17 15:43:18 +0300
commit80d1d624d378d4d8c03fb26ef286baf5479b6497 (patch)
treed5ae6545d0318d8e0448d3a084a15e72aff6e2a5 /source
parent90bf426554a7cc1d429f2dd9a02edbcbeb51ceec (diff)
Support dynamic loading of SDL libraries
This is mainly to address old issue when one need to have SDL library installed in order to use our official builds. Some hip distros already installs SDL, but it's not quite the same across all the variety of the distros. We also now switching to SDL-2.0, most of the distros have it in repositories already, so it shouldn't be huge deal to install it if needed. Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D878
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/SConscript3
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt6
-rw-r--r--source/blender/makesrna/intern/SConscript3
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c47
-rw-r--r--source/blenderplayer/CMakeLists.txt1
-rw-r--r--source/creator/CMakeLists.txt4
-rw-r--r--source/creator/blender.map1
-rw-r--r--source/creator/creator.c8
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp37
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp6
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt7
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp9
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript4
13 files changed, 102 insertions, 34 deletions
diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript
index 4e7a564e9d4..0d215fbcf81 100644
--- a/source/blender/makesrna/SConscript
+++ b/source/blender/makesrna/SConscript
@@ -122,6 +122,9 @@ if env['WITH_BF_CYCLES']:
defs.append('WITH_CYCLES_DEBUG')
if env['WITH_BF_SDL']:
+ if env['WITH_BF_SDL_DYNLOAD']:
+ defs.append('WITH_SDL_DYNLOAD')
+ incs += ' #extern/sdlew/include'
defs.append('WITH_SDL')
if env['WITH_BF_OPENAL']:
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 5d736f9c011..e64743c5536 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -241,6 +241,12 @@ if(WITH_MOD_OCEANSIM)
endif()
if(WITH_SDL)
+ if(WITH_SDL_DYNLOAD)
+ add_definitions(-DWITH_SDL_DYNLOAD)
+ list(APPEND INC
+ ../../../../extern/sdlew/include
+ )
+ endif()
add_definitions(-DWITH_SDL)
endif()
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index d1eab5ca9db..28151fe5db1 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -123,6 +123,9 @@ if env['WITH_BF_FFTW3']:
defs.append('WITH_FFTW3')
if env['WITH_BF_SDL']:
+ if env['WITH_BF_SDL_DYNLOAD']:
+ defs.append('WITH_SDL_DYNLOAD')
+ incs += ' #extern/sdlew/include'
defs.append('WITH_SDL')
if env['WITH_BF_OPENAL']:
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 5c713e8de75..ab5039df627 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -104,6 +104,10 @@ EnumPropertyItem navigation_mode_items[] = {
#include "BKE_addon.h"
+#ifdef WITH_SDL_DYNLOAD
+# include "sdlew.h"
+#endif
+
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -510,37 +514,38 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P
static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop), bool *r_free)
{
-#ifdef WITH_JACK
- int jack_supported = sound_is_jack_supported();
-
- if (jack_supported) {
- return audio_device_items;
- }
- else {
- int index = 0;
- int totitem = 0;
- EnumPropertyItem *item = NULL;
+ int index = 0;
+ int totitem = 0;
+ EnumPropertyItem *item = NULL;
- /* NONE */
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
+ /* NONE */
+ RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
#ifdef WITH_SDL
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
+# ifdef WITH_SDL_DYNLOAD
+ if (sdlewInit() == SDLEW_SUCCESS)
+# endif
+ {
+ RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
+ }
+ index++;
#endif
#ifdef WITH_OPENAL
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
+ RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
#endif
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
+#ifdef WITH_JACK
+ if (sound_is_jack_supported()) {
+ RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
}
-#else
- (void)r_free;
- return audio_device_items;
+ index++;
#endif
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
}
#ifdef WITH_INTERNATIONAL
diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt
index 3dba4333884..4a154d778e7 100644
--- a/source/blenderplayer/CMakeLists.txt
+++ b/source/blenderplayer/CMakeLists.txt
@@ -167,6 +167,7 @@ endif()
extern_wcwidth
extern_libmv
extern_glog
+ extern_sdlew
)
if(WITH_MOD_CLOTH_ELTOPO)
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index d26d97baef3..0e596fb0c5f 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -81,6 +81,10 @@ if(WITH_GAMEENGINE)
endif()
if(WITH_SDL)
+ if(WITH_SDL_DYNLOAD)
+ add_definitions(-DWITH_SDL_DYNLOAD)
+ blender_include_dirs(../../extern/sdlew/include)
+ endif()
add_definitions(-DWITH_SDL)
endif()
diff --git a/source/creator/blender.map b/source/creator/blender.map
index f583ddc1a89..359cbe0415f 100644
--- a/source/creator/blender.map
+++ b/source/creator/blender.map
@@ -18,5 +18,6 @@ local:
NumNamedVarArgParams;
X86CompilationCallback*;
*boost*;
+ *SDL*;
};
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 60fa006ad08..be03ffe0bda 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -154,6 +154,10 @@
# include "CCL_api.h"
#endif
+#ifdef WITH_SDL_DYNLOAD
+# include "sdlew.h"
+#endif
+
/* from buildinfo.c */
#ifdef BUILD_DATE
extern char build_date[];
@@ -1586,6 +1590,10 @@ int main(
}
#endif
+#ifdef WITH_SDL_DYNLOAD
+ sdlewInit();
+#endif
+
C = CTX_create();
#ifdef WITH_PYTHON_MODULE
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index 6e379c91d0c..228adbb942e 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -41,6 +41,8 @@
#include "BLI_path_util.h"
+#define SDL_CHECK(x) ((x) != (void*)0)
+
SCA_Joystick::SCA_Joystick(short int index)
:
m_joyindex(index),
@@ -82,6 +84,9 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
#ifndef WITH_SDL
return NULL;
#else /* WITH_SDL */
+ if (!SDL_CHECK(SDL_InitSubSystem)) {
+ return NULL;
+ }
if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
JOYSTICK_ECHO("Error-invalid joystick index: " << joyindex);
return NULL;
@@ -135,8 +140,10 @@ void SCA_Joystick::ReleaseInstance()
if (--m_refCount == 0)
{
#ifdef WITH_SDL
- int i;
- for (i=0; i<JOYINDEX_MAX; i++) {
+ if (!SDL_CHECK(SDL_QuitSubSystem)) {
+ return;
+ }
+ for (int i=0; i<JOYINDEX_MAX; i++) {
if (m_instance[i]) {
m_instance[i]->DestroyJoystickDevice();
delete m_instance[i];
@@ -191,6 +198,9 @@ bool SCA_Joystick::aAxisIsPositive(int axis_single)
bool SCA_Joystick::aAnyButtonPressIsPositive(void)
{
#ifdef WITH_SDL
+ if (!SDL_CHECK(SDL_JoystickGetButton)) {
+ return false;
+ }
/* this is needed for the "all events" option
* so we know if there are no buttons pressed */
for (int i=0; i<m_buttonmax; i++)
@@ -206,7 +216,7 @@ bool SCA_Joystick::aButtonPressIsPositive(int button)
return false;
#else
bool result;
- SDL_JoystickGetButton(m_private->m_joystick, button)? result = true:result = false;
+ result = SDL_CHECK(SDL_JoystickGetButton) && SDL_JoystickGetButton(m_private->m_joystick, button);
return result;
#endif
}
@@ -218,7 +228,7 @@ bool SCA_Joystick::aButtonReleaseIsPositive(int button)
return false;
#else
bool result;
- SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true;
+ result = !(SDL_CHECK(SDL_JoystickGetButton) && SDL_JoystickGetButton(m_private->m_joystick, button));
return result;
#endif
}
@@ -253,7 +263,7 @@ bool SCA_Joystick::CreateJoystickDevice(void)
m_axismax = m_buttonmax = m_hatmax = 0;
return false;
#else /* WITH_SDL */
- if (m_isinit == false) {
+ if (m_isinit == false && SDL_CHECK(SDL_JoystickOpen)) {
if (m_joyindex>=m_joynum) {
/* don't print a message, because this is done anyway */
//JOYSTICK_ECHO("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
@@ -293,9 +303,9 @@ void SCA_Joystick::DestroyJoystickDevice(void)
#ifdef WITH_SDL
if (m_isinit) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (SDL_JoystickGetAttached(m_private->m_joystick))
+ if (SDL_CHECK(SDL_JoystickGetAttached) && SDL_JoystickGetAttached(m_private->m_joystick))
#else
- if (SDL_JoystickOpened(m_joyindex))
+ if (SDL_CHECK(SDL_JoystickOpened) && SDL_JoystickOpened(m_joyindex))
#endif
{
JOYSTICK_ECHO("Closing-joystick " << m_joyindex);
@@ -309,13 +319,16 @@ void SCA_Joystick::DestroyJoystickDevice(void)
int SCA_Joystick::Connected(void)
{
#ifdef WITH_SDL
- if (m_isinit
+ if (m_isinit &&
#if SDL_VERSION_ATLEAST(2, 0, 0)
- && SDL_JoystickGetAttached(m_private->m_joystick))
+ SDL_CHECK(SDL_JoystickGetAttached) && SDL_JoystickGetAttached(m_private->m_joystick)
#else
- && SDL_JoystickOpened(m_joyindex))
+ SDL_CHECK(SDL_JoystickOpened) && SDL_JoystickOpened(m_joyindex)
#endif
+ )
+ {
return 1;
+ }
#endif
return 0;
}
@@ -353,9 +366,9 @@ const char *SCA_Joystick::GetName()
{
#ifdef WITH_SDL
#if SDL_VERSION_ATLEAST(2, 0, 0)
- return SDL_JoystickName(m_private->m_joystick);
+ return (SDL_CHECK(SDL_JoystickName)) ? SDL_JoystickName(m_private->m_joystick) : "";
#else
- return SDL_JoystickName(m_joyindex);
+ return (SDL_CHECK(SDL_JoystickName)) ? SDL_JoystickName(m_joyindex) : "";
#endif
#else /* WITH_SDL */
return "";
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index 38baeaab35e..08f4d97ed1b 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -85,7 +85,11 @@ void SCA_Joystick::OnNothing(SDL_Event* sdl_event)
void SCA_Joystick::HandleEvents(void)
{
SDL_Event sdl_event;
-
+
+ if (SDL_PollEvent == (void*)0) {
+ return;
+ }
+
int i;
for (i=0; i<m_joynum; i++) { /* could use JOYINDEX_MAX but no reason to */
if (SCA_Joystick::m_instance[i])
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
index 8ab090eac02..a1bc7e88840 100644
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ -91,4 +91,11 @@ if(WITH_AUDASPACE)
add_definitions(-DWITH_AUDASPACE)
endif()
+if(WITH_SDL AND WITH_SDL_DYNLOAD)
+ list(APPEND INC
+ ../../../../extern/sdlew/include
+ )
+ add_definitions(-DWITH_SDL_DYNLOAD)
+endif()
+
blender_add_lib_nolist(ge_player_ghost "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 3bb5f17841d..1a6501fae6e 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -114,6 +114,10 @@ extern char datatoc_bmonofont_ttf[];
#endif // !defined(DEBUG)
#endif // WIN32
+#ifdef WITH_SDL_DYNLOAD
+# include "sdlew.h"
+#endif
+
const int kMinWindowWidth = 100;
const int kMinWindowHeight = 100;
@@ -421,6 +425,11 @@ int main(int argc, char** argv)
signal (SIGFPE, SIG_IGN);
#endif /* __alpha__ */
#endif /* __linux__ */
+
+#ifdef WITH_SDL_DYNLOAD
+ sdlewInit();
+#endif
+
BLI_init_program_path(argv[0]);
BLI_temp_dir_init(NULL);
diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript
index d4c31889a5e..610abcd0357 100644
--- a/source/gameengine/GamePlayer/ghost/SConscript
+++ b/source/gameengine/GamePlayer/ghost/SConscript
@@ -87,4 +87,8 @@ if env['WITH_BF_FFMPEG']:
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')
+if env['WITH_BF_SDL'] and env['WITH_BF_SDL_DYNLOAD']:
+ defs.append('WITH_SDL_DYNLOAD')
+ incs += ['#extern/sdlew/include']
+
env.BlenderLib (libname='ge_player_ghost', sources=source_files, includes = incs, defines = defs, libtype=['player'],priority=[0], cxx_compileflags=env['BGE_CXXFLAGS'])