diff options
Diffstat (limited to 'source/gameengine/GamePlayer/ghost')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/CMakeLists.txt | 16 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 70 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.h | 8 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp | 18 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Canvas.h | 4 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 62 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/SConscript | 18 |
7 files changed, 136 insertions, 60 deletions
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index df752799c2c..283f222115c 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -42,12 +42,14 @@ set(INC ../../../blender/blenkernel ../../../blender/blenlib ../../../blender/blenloader + ../../../blender/blentranslation ../../../blender/gpu ../../../blender/imbuf ../../../blender/makesdna ../../../blender/makesrna ../../../../intern/container ../../../../intern/ghost + ../../../../intern/glew-mx ../../../../intern/guardedalloc ../../../../intern/string ../../../../intern/memutil @@ -73,7 +75,7 @@ set(SRC GPG_System.h ) -add_definitions(-DGLEW_STATIC) +add_definitions(${GL_DEFINITIONS}) if(WITH_CODEC_FFMPEG) add_definitions(-DWITH_FFMPEG) @@ -84,10 +86,18 @@ if(WITH_INTERNATIONAL) endif() if(WITH_AUDASPACE) + add_definitions(${AUDASPACE_DEFINITIONS}) + + list(APPEND INC_SYS + ${AUDASPACE_C_INCLUDE_DIRS} + ) +endif() + +if(WITH_SDL AND WITH_SDL_DYNLOAD) list(APPEND INC - ../../../../intern/audaspace/intern + ../../../../extern/sdlew/include ) - add_definitions(-DWITH_AUDASPACE) + 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_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index b85d4b40ca8..2b357f43031 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -36,8 +36,9 @@ # include <windows.h> #endif -#include "GL/glew.h" +#include "glew-mx.h" #include "GPU_extensions.h" +#include "GPU_init_exit.h" #include "GPG_Application.h" #include "BL_BlenderDataConversion.h" @@ -99,9 +100,7 @@ extern "C" #include "GHOST_Rect.h" #ifdef WITH_AUDASPACE -# include "AUD_C-API.h" -# include "AUD_I3DDevice.h" -# include "AUD_IDevice.h" +# include AUD_DEVICE_H #endif static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); @@ -113,6 +112,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) : m_startSceneName(""), m_startScene(0), m_maggie(0), + m_kxStartScene(NULL), m_exitRequested(0), m_system(system), m_mainWindow(0), @@ -249,9 +249,15 @@ bool GPG_Application::startScreenSaverPreview( int windowWidth = rc.right - rc.left; int windowHeight = rc.bottom - rc.top; STR_String title = ""; - + GHOST_GLSettings glSettings = {0}; + + if (stereoVisual) { + glSettings.flags |= GHOST_glStereoVisual; + } + glSettings.numOfAASamples = samples; + m_mainWindow = fSystem->createWindow(title, 0, 0, windowWidth, windowHeight, GHOST_kWindowStateMinimized, - GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples); + GHOST_kDrawingContextTypeOpenGL, glSettings); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -322,11 +328,16 @@ bool GPG_Application::startWindow( const int stereoMode, const GHOST_TUns16 samples) { + GHOST_GLSettings glSettings = {0}; bool success; // Create the main window //STR_String title ("Blender Player - GHOST"); + if (stereoVisual) + glSettings.flags |= GHOST_glStereoVisual; + glSettings.numOfAASamples = samples; + m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, stereoVisual, false, samples); + GHOST_kDrawingContextTypeOpenGL, glSettings); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -353,10 +364,16 @@ bool GPG_Application::startEmbeddedWindow( const GHOST_TUns16 samples) { GHOST_TWindowState state = GHOST_kWindowStateNormal; + GHOST_GLSettings glSettings = {0}; + + if (stereoVisual) + glSettings.flags |= GHOST_glStereoVisual; + glSettings.numOfAASamples = samples; + if (parentWindow != 0) state = GHOST_kWindowStateEmbedded; m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, state, - GHOST_kDrawingContextTypeOpenGL, stereoVisual, false, samples, parentWindow); + GHOST_kDrawingContextTypeOpenGL, glSettings, parentWindow); if (!m_mainWindow) { printf("error: could not create main window\n"); @@ -545,7 +562,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) { if (!m_engineInitialized) { - GPU_extensions_init(); + GPU_init(); bgl::InitExtensions(true); // get and set the preferences @@ -566,7 +583,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", gm->flag & GAME_DISPLAY_LISTS) != 0) && GPU_display_list_support(); bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 1) != 0); - bool restrictAnimFPS = gm->flag & GAME_RESTRICT_ANIM_UPDATES; + bool restrictAnimFPS = (gm->flag & GAME_RESTRICT_ANIM_UPDATES) != 0; if (GLEW_ARB_multitexture && GLEW_VERSION_1_1) m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); @@ -618,7 +635,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_networkdevice) goto initFailed; - sound_init(m_maggie); + BKE_sound_init(m_maggie); // create a ketsjisystem (only needed for timing and stuff) m_kxsystem = new GPG_System (m_system); @@ -654,7 +671,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) return m_engineInitialized; initFailed: - sound_exit(); + BKE_sound_exit(); delete m_kxsystem; delete m_networkdevice; delete m_mouse; @@ -698,7 +715,7 @@ bool GPG_Application::startEngine(void) m_sceneconverter = new KX_BlenderSceneConverter(m_maggie, m_ketsjiengine); if (m_sceneconverter) { - STR_String startscenename = m_startSceneName.Ptr(); + STR_String m_kxStartScenename = m_startSceneName.Ptr(); m_ketsjiengine->SetSceneConverter(m_sceneconverter); // if (always_use_expand_framing) @@ -710,17 +727,17 @@ bool GPG_Application::startEngine(void) if (m_startScene->gm.flag & GAME_NO_MATERIAL_CACHING) m_sceneconverter->SetCacheMaterials(false); - KX_Scene* startscene = new KX_Scene(m_keyboard, + m_kxStartScene = new KX_Scene(m_keyboard, m_mouse, m_networkdevice, - startscenename, + m_kxStartScenename, m_startScene, m_canvas); #ifdef WITH_PYTHON // some python things PyObject *gameLogic, *gameLogic_keys; - setupGamePython(m_ketsjiengine, startscene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv); + setupGamePython(m_ketsjiengine, m_kxStartScene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv); #endif // WITH_PYTHON //initialize Dome Settings @@ -728,13 +745,10 @@ bool GPG_Application::startEngine(void) m_ketsjiengine->InitDome(m_startScene->gm.dome.res, m_startScene->gm.dome.mode, m_startScene->gm.dome.angle, m_startScene->gm.dome.resbuf, m_startScene->gm.dome.tilt, m_startScene->gm.dome.warptext); // initialize 3D Audio Settings - AUD_I3DDevice* dev = AUD_get3DDevice(); - if (dev) - { - dev->setSpeedOfSound(m_startScene->audio.speed_of_sound); - dev->setDopplerFactor(m_startScene->audio.doppler_factor); - dev->setDistanceModel(AUD_DistanceModel(m_startScene->audio.distance_model)); - } + AUD_Device* device = BKE_sound_get_device(); + AUD_Device_setSpeedOfSound(device, m_startScene->audio.speed_of_sound); + AUD_Device_setDopplerFactor(device, m_startScene->audio.doppler_factor); + AUD_Device_setDistanceModel(device, AUD_DistanceModel(m_startScene->audio.distance_model)); #ifdef WITH_PYTHON // Set the GameLogic.globalDict from marshal'd data, so we can @@ -742,10 +756,10 @@ bool GPG_Application::startEngine(void) loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); #endif m_sceneconverter->ConvertScene( - startscene, + m_kxStartScene, m_rasterizer, m_canvas); - m_ketsjiengine->AddScene(startscene); + m_ketsjiengine->AddScene(m_kxStartScene); // Create a timer that is used to kick the engine if (!m_frameTimer) { @@ -758,7 +772,7 @@ bool GPG_Application::startEngine(void) // Set the animation playback rate for ipo's and actions // the framerate below should patch with FPS macro defined in blendef.h // Could be in StartEngine set the framerate, we need the scene to do this - Scene *scene= startscene->GetBlenderScene(); // needed for macro + Scene *scene= m_kxStartScene->GetBlenderScene(); // needed for macro m_ketsjiengine->SetAnimFrameRate(FPS); } @@ -829,7 +843,7 @@ void GPG_Application::exitEngine() if (!m_engineInitialized) return; - sound_exit(); + BKE_sound_exit(); if (m_ketsjiengine) { stopEngine(); @@ -867,7 +881,7 @@ void GPG_Application::exitEngine() m_canvas = 0; } - GPU_extensions_exit(); + GPU_exit(); #ifdef WITH_PYTHON // Call this after we're sure nothing needs Python anymore (e.g., destructors) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 2d21b50e664..b6f545c2de8 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -40,6 +40,7 @@ #include "KX_KetsjiEngine.h" class KX_KetsjiEngine; +class KX_Scene; class KX_ISceneConverter; class NG_LoopBackNetworkDeviceInterface; class RAS_IRasterizer; @@ -83,6 +84,12 @@ public: int getExitRequested(void); const STR_String& getExitString(void); GlobalSettings* getGlobalSettings(void); + + inline KX_Scene *GetStartScene() const + { + return m_kxStartScene; + } + bool StartGameEngine(int stereoMode); void StopGameEngine(); void EngineNextFrame(); @@ -118,6 +125,7 @@ protected: STR_String m_startSceneName; struct Scene* m_startScene; struct Main* m_maggie; + KX_Scene *m_kxStartScene; /* Exit state. */ int m_exitRequested; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp index 35c7c62a67d..09eb1691dae 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp @@ -113,12 +113,24 @@ void GPG_Canvas::SetSwapInterval(int interval) m_window->setSwapInterval(interval); } -int GPG_Canvas::GetSwapInterval() +bool GPG_Canvas::GetSwapInterval(int& intervalOut) { if (m_window) - return m_window->getSwapInterval(); + return (bool)m_window->getSwapInterval(intervalOut); - return 0; + return false; +} + +void GPG_Canvas::GetDisplayDimensions(int &width, int &height) + { + unsigned int uiwidth; + unsigned int uiheight; + + GHOST_ISystem *system = GHOST_ISystem::getSystem(); + system->getMainDisplayDimensions(uiwidth, uiheight); + + width = uiwidth; + height = uiheight; } void GPG_Canvas::ResizeWindow(int width, int height) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h index 6e1f86cac0e..18afbf6cd9e 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h @@ -56,13 +56,15 @@ public: virtual void SetMouseState(RAS_MouseState mousestate); virtual void SwapBuffers(); virtual void SetSwapInterval(int interval); - virtual int GetSwapInterval(); + virtual bool GetSwapInterval(int& intervalOut); virtual int GetMouseX(int x) { return x; } virtual int GetMouseY(int y) { return y; } virtual float GetMouseNormalizedX(int x); virtual float GetMouseNormalizedY(int y); + virtual void GetDisplayDimensions(int &width, int &height); + virtual void ResizeWindow(int width, int height); virtual void SetFullScreen(bool enable); virtual bool GetFullScreen(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b6456b105c8..23d5b89f140 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -43,6 +43,7 @@ #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" #include "KX_PythonMain.h" +#include "KX_PyConstraintBinding.h" // for PHY_SetActiveEnvironment /********************************** * Begin Blender include block @@ -64,6 +65,7 @@ extern "C" #include "BLO_readfile.h" #include "BLO_runtime.h" +#include "BKE_appdir.h" #include "BKE_blender.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -73,17 +75,21 @@ extern "C" #include "BKE_report.h" #include "BKE_library.h" #include "BKE_modifier.h" +#include "BKE_material.h" #include "BKE_text.h" #include "BKE_sound.h" #include "IMB_imbuf.h" #include "IMB_moviecache.h" +#ifdef __APPLE__ int GHOST_HACK_getFirstFile(char buf[]); +#endif // For BLF #include "BLF_api.h" -#include "BLF_translation.h" +#include "BLT_translation.h" +#include "BLT_lang.h" extern int datatoc_bfont_ttf_size; extern char datatoc_bfont_ttf[]; extern int datatoc_bmonofont_ttf_size; @@ -116,6 +122,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; @@ -299,7 +309,7 @@ static void get_filename(int argc, char **argv, char *filename) if (GHOST_HACK_getFirstFile(firstfilebuf)) { BLI_strncpy(filename, firstfilebuf, FILE_MAX); } - } + } } srclen -= ::strlen("MacOS/blenderplayer"); @@ -429,8 +439,13 @@ int main(int argc, char** argv) signal (SIGFPE, SIG_IGN); #endif /* __alpha__ */ #endif /* __linux__ */ - BLI_init_program_path(argv[0]); - BLI_temp_dir_init(NULL); + +#ifdef WITH_SDL_DYNLOAD + sdlewInit(); +#endif + + BKE_appdir_program_path_init(argv[0]); + BKE_tempdir_init(NULL); // We don't use threads directly in the BGE, but we need to call this so things like // freeing up GPU_Textures works correctly. @@ -459,8 +474,8 @@ int main(int argc, char** argv) // Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c) BLF_init(11, U.dpi); - BLF_lang_init(); - BLF_lang_set(""); + BLT_lang_init(); + BLT_lang_set(""); BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); if (blf_mono_font == -1) @@ -505,9 +520,12 @@ int main(int argc, char** argv) // enable fast mipmap generation U.use_gpu_mipmap = 1; - sound_init_once(); + BKE_sound_init_once(); + + // Initialize a default material for meshes without materials. + init_def_material(); - set_free_windowmanager_cb(wm_free); + BKE_library_callback_free_window_manager_set(wm_free); /* if running blenderplayer the last argument can't be parsed since it has to be the filename. else it is bundled */ isBlenderPlayer = !BLO_is_a_runtime(argv[0]); @@ -583,7 +601,7 @@ int main(int argc, char** argv) i++; G.debug |= G_DEBUG; MEM_set_memory_debug(); -#ifdef DEBUG +#ifndef NDEBUG BLI_mempool_set_memory_debug(); #endif break; @@ -811,14 +829,6 @@ int main(int argc, char** argv) if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION) #endif { - - if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { - GPU_set_mipmap(0); - } - - GPU_set_anisotropic(U.anisotropic_filter); - GPU_set_gpu_mipmapping(U.use_gpu_mipmap); - // Create the system if (GHOST_ISystem::createSystem() == GHOST_kSuccess) { GHOST_ISystem* system = GHOST_ISystem::getSystem(); @@ -877,7 +887,7 @@ int main(int argc, char** argv) } } else { - bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL); + bfd = load_game_data(BKE_appdir_program_path(), filename[0]? filename: NULL); } #if defined(DEBUG) @@ -1041,6 +1051,13 @@ int main(int argc, char** argv) else app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, stereoWindow, stereomode, aasamples); + + if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { + GPU_set_mipmap(0); + } + + GPU_set_anisotropic(U.anisotropic_filter); + GPU_set_gpu_mipmapping(U.use_gpu_mipmap); } } } @@ -1064,6 +1081,11 @@ int main(int argc, char** argv) char *python_code = KX_GetPythonCode(maggie, python_main); if (python_code) { #ifdef WITH_PYTHON + // Set python environement variable. + KX_Scene *startscene = app.GetStartScene(); + KX_SetActiveScene(startscene); + PHY_SetActiveEnvironment(startscene->GetPhysicsEnvironment()); + gpg_nextframestate.system = system; gpg_nextframestate.app = &app; gpg_nextframestate.gs = &gs; @@ -1125,7 +1147,7 @@ int main(int argc, char** argv) #ifdef WITH_INTERNATIONAL BLF_free_unifont(); BLF_free_unifont_mono(); - BLF_lang_free(); + BLT_lang_free(); #endif IMB_exit(); @@ -1142,7 +1164,7 @@ int main(int argc, char** argv) MEM_printmemlist(); } - BLI_temp_dir_session_purge(); + BKE_tempdir_session_purge(); return error ? -1 : 0; } diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index 3e8ab3d0dd7..be9f50f40fb 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -44,7 +44,6 @@ incs = [ '#intern/memutil', '#intern/moto/include', '#intern/container', - '#intern/audaspace/intern', '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', '#source/gameengine/BlenderRoutines', '#source/gameengine/Converter', @@ -53,6 +52,7 @@ incs = [ '#source/blender/blenfont', '#source/blender/blenlib', '#source/blender/blenkernel', + '#source/blender/blentranslation', '#source/blender', '#source/blender/include', '#source/blender/makesdna', @@ -68,24 +68,32 @@ incs = [ '#source/blender/misc', '#source/blender/blenloader', '#source/blender/gpu', - '#extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', ] incs.append(env['BF_PTHREADS_INC']) incs.append(env['BF_BOOST_INC']) -defs = [ - 'GLEW_STATIC', - ] +defs = [] +defs += env['BF_GL_DEFINITIONS'] if env['WITH_BF_PYTHON']: incs += Split(env['BF_PYTHON_INC']) defs.append('WITH_PYTHON') +if env['WITH_BF_AUDASPACE']: + defs += env['BF_AUDASPACE_DEF'] + incs.append(env['BF_AUDASPACE_C_INC']) + if env['WITH_BF_FFMPEG']: defs.append('WITH_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']) |