diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /source/gameengine/GamePlayer/ghost | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'source/gameengine/GamePlayer/ghost')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 159 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.h | 18 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 157 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/Makefile | 6 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/SConscript | 74 |
6 files changed, 271 insertions, 145 deletions
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 3d17cd2cfdd..5e0ca93ac06 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -64,7 +64,9 @@ SET(INC ../../../../source/gameengine/GamePlayer/common ../../../../source/blender/misc ../../../../source/blender/blenloader + ../../../../source/blender/gpu ../../../../extern/solid + ../../../../extern/glew/include ${PYTHON_INC} ) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 020798d5f24..aa5e5835cdc 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -37,23 +37,14 @@ #include <windows.h> #endif -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include <OpenGL/gl.h> -#include <OpenGL/glu.h> -#else -#include <GL/gl.h> -#if defined(__sun__) && !defined(__sparc__) -#include <mesa/glu.h> -#else -#include <GL/glu.h> -#endif -#endif +#include "GL/glew.h" +#include "GPU_extensions.h" #include "GPG_Application.h" #include <iostream> #include <MT_assert.h> +#include <stdlib.h> /********************************** * Begin Blender include block @@ -66,6 +57,8 @@ extern "C" #include "BLO_readfile.h" #include "BKE_global.h" #include "BKE_main.h" +#include "IMB_imbuf.h" +#include "DNA_scene_types.h" #ifdef __cplusplus } #endif // __cplusplus @@ -107,15 +100,15 @@ extern "C" #include "GHOST_IWindow.h" #include "GHOST_Rect.h" - static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); static GHOST_ISystem* fSystem = 0; static const int kTimerFreq = 10; -GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName) - : m_startSceneName(startSceneName), - m_maggie(maggie), +GPG_Application::GPG_Application(GHOST_ISystem* system) + : m_startSceneName(""), + m_startScene(0), + m_maggie(0), m_exitRequested(0), m_system(system), m_mainWindow(0), @@ -123,6 +116,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR m_cursor(GHOST_kStandardCursorFirstCursor), m_engineInitialized(0), m_engineRunning(0), + m_isEmbedded(false), m_ketsjiengine(0), m_kxsystem(0), m_keyboard(0), @@ -133,7 +127,10 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR m_sceneconverter(0), m_networkdevice(0), m_audiodevice(0), - m_blendermat(0) + m_blendermat(0), + m_blenderglslmat(0), + m_pyGlobalDictString(0), + m_pyGlobalDictString_Length(0) { fSystem = system; } @@ -142,21 +139,28 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR GPG_Application::~GPG_Application(void) { + if(m_pyGlobalDictString) { + delete [] m_pyGlobalDictString; + m_pyGlobalDictString = 0; + m_pyGlobalDictString_Length = 0; + } + exitEngine(); fSystem->disposeWindow(m_mainWindow); } -bool GPG_Application::SetGameEngineData(struct Main* maggie, STR_String startSceneName) +bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene) { bool result = false; - if (maggie != NULL && startSceneName != "") + if (maggie != NULL && scene != NULL) { - G.scene = (Scene*)maggie->scene.first; + G.scene = scene; m_maggie = maggie; - m_startSceneName = startSceneName; + m_startSceneName = scene->id.name+2; + m_startScene = scene; result = true; } @@ -328,6 +332,26 @@ bool GPG_Application::startWindow(STR_String& title, return success; } +bool GPG_Application::startEmbeddedWindow(STR_String& title, + const GHOST_TEmbedderWindowID parentWindow, + const bool stereoVisual, + const int stereoMode) { + + m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, GHOST_kWindowStateNormal, + GHOST_kDrawingContextTypeOpenGL, stereoVisual, parentWindow); + + if (!m_mainWindow) { + printf("error: could not create main window\n"); + exit(-1); + } + m_isEmbedded = true; + + bool success = initEngine(m_mainWindow, stereoMode); + if (success) { + success = startEngine(); + } + return success; +} bool GPG_Application::startFullScreen( @@ -486,7 +510,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) { if (!m_engineInitialized) { - bgl::InitExtensions(1); + GPU_extensions_init(); + bgl::InitExtensions(true); // get and set the preferences SYS_SystemHandle syshandle = SYS_GetSystem(); @@ -504,25 +529,16 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0); bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); - bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0; - bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); -#ifdef GL_ARB_multitexture - int gameflag =(G.fileflags & G_FILE_GAME_MAT); - // ---------------------------------- - if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { - m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); - int unitmax=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); - bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; - //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; - } else { - bgl::max_texture_units = 0; - } -#else - m_blendermat=0; -#endif//GL_ARB_multitexture - // ---------------------------------- - + bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0); + + if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) + m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); + + if(GPU_extensions_minimum_support()) + m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0); + else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + m_blendermat = false; + // create the canvas, rasterizer and rendertools m_canvas = new GPG_Canvas(window); if (!m_canvas) @@ -533,12 +549,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_rendertools) goto initFailed; - if(useLists) - m_rasterizer = new RAS_ListRasterizer(m_canvas); - else if (useVertexArrays && bgl::QueryVersion(1, 1)) + if(useLists) { + if(GLEW_VERSION_1_1) + m_rasterizer = new RAS_ListRasterizer(m_canvas, true); + else + m_rasterizer = new RAS_ListRasterizer(m_canvas); + } + else if (GLEW_VERSION_1_1) m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas); else m_rasterizer = new RAS_OpenGLRasterizer(m_canvas); + m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode); if (!m_rasterizer) goto initFailed; @@ -640,31 +661,37 @@ bool GPG_Application::startEngine(void) { STR_String startscenename = m_startSceneName.Ptr(); m_ketsjiengine->SetSceneConverter(m_sceneconverter); - + // if (always_use_expand_framing) // sceneconverter->SetAlwaysUseExpandFraming(true); - if(m_blendermat) + if(m_blendermat && (G.fileflags & G_FILE_GAME_MAT)) m_sceneconverter->SetMaterials(true); + if(m_blenderglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) + m_sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(m_keyboard, m_mouse, m_networkdevice, m_audiodevice, - startscenename); + startscenename, + m_startScene); // some python things PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest); m_ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(m_rasterizer, m_canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene); + PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); + initMathutils(); + initVideoTexture(); - - - - + // Set the GameLogic.globalDict from marshal'd data, so we can + // load new blend files and keep data in GameLogic.globalDict + loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); + m_sceneconverter->ConvertScene( startscenename, startscene, @@ -682,6 +709,11 @@ bool GPG_Application::startEngine(void) m_ketsjiengine->StartEngine(true); m_engineRunning = true; + // 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 + m_ketsjiengine->SetAnimFrameRate( (((double) G.scene->r.frs_sec) / G.scene->r.frs_sec_base) ); + } if (!m_engineRunning) @@ -695,6 +727,16 @@ bool GPG_Application::startEngine(void) void GPG_Application::stopEngine() { + // GameLogic.globalDict gets converted into a buffer, and sorted in + // m_pyGlobalDictString so we can restore after python has stopped + // and started between .blend file loads. + if(m_pyGlobalDictString) { + delete [] m_pyGlobalDictString; + m_pyGlobalDictString = 0; + } + + m_pyGlobalDictString_Length = saveGamePythonConfig(&m_pyGlobalDictString); + // when exiting the mainloop exitGamePythonScripting(); m_ketsjiengine->StopEngine(); @@ -761,6 +803,12 @@ void GPG_Application::exitEngine() m_canvas = 0; } + libtiff_exit(); +#ifdef WITH_QUICKTIME + quicktime_exit(); +#endif + GPU_extensions_exit(); + m_exitRequested = 0; m_engineInitialized = false; } @@ -838,11 +886,12 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown) { GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData); - if (fSystem->getFullScreen()) { - if (keyData->key == GHOST_kKeyEsc) { + //no need for this test + //if (fSystem->getFullScreen()) { + if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc && !m_isEmbedded) { m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; } - } + //} m_keyboard->ConvertEvent(keyData->key, isDown); handled = true; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 024ca1dbf32..38408f919b4 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -50,17 +50,19 @@ class GPG_Canvas; class GPG_KeyboardDevice; class GPG_System; struct Main; +struct Scene; class GPG_Application : public GHOST_IEventConsumer { public: - GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName); + GPG_Application(GHOST_ISystem* system); ~GPG_Application(void); - bool SetGameEngineData(struct Main* maggie,STR_String startSceneName); + bool SetGameEngineData(struct Main* maggie, struct Scene* scene); bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, const bool stereoVisual, const int stereoMode); bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); + bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode); #ifdef WIN32 bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode); @@ -100,6 +102,7 @@ protected: /* The game data */ STR_String m_startSceneName; + struct Scene* m_startScene; struct Main* m_maggie; /* Exit state. */ @@ -118,6 +121,8 @@ protected: bool m_engineInitialized; /** Engine state. */ bool m_engineRunning; + /** Running on embedded window */ + bool m_isEmbedded; /** the gameengine itself */ KX_KetsjiEngine* m_ketsjiengine; @@ -141,6 +146,13 @@ protected: SND_IAudioDevice* m_audiodevice; bool m_blendermat; - + bool m_blenderglslmat; + + /* + * GameLogic.globalDict as a string so that loading new blend files can use the same dict. + * Do this because python starts/stops when loading blend files. + */ + char* m_pyGlobalDictString; + int m_pyGlobalDictString_Length; }; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 5226ca02662..0bf0317d8f2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -44,6 +44,7 @@ #endif // __APPLE__ #include "GEN_messaging.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" /********************************** * Begin Blender include block @@ -52,25 +53,31 @@ extern "C" { #endif // __cplusplus +#include "MEM_guardedalloc.h" +#include "BKE_blender.h" #include "BKE_global.h" #include "BKE_icons.h" +#include "BKE_node.h" #include "BLI_blenlib.h" #include "DNA_scene_types.h" #include "BLO_readfile.h" #include "BLO_readblenfile.h" +#include "IMB_imbuf.h" int GHOST_HACK_getFirstFile(char buf[]); #ifdef __cplusplus } #endif // __cplusplus + +#include "GPU_draw.h" + /********************************** * End Blender include block **********************************/ #include "SYS_System.h" #include "GPG_Application.h" -#include "GPC_PolygonMaterial.h" #include "GHOST_ISystem.h" #include "RAS_IRasterizer.h" @@ -146,9 +153,9 @@ static BOOL scr_saver_init(int argc, char **argv) #endif /* WIN32 */ -void usage(char* program) +void usage(const char* program) { - char * consoleoption; + const char * consoleoption; #ifdef _WIN32 consoleoption = "-c "; #else @@ -176,9 +183,13 @@ void usage(char* program) printf(" anaglyph (Red-Blue glasses)\n"); printf(" vinterlace (Vertical interlace for autostereo display)\n"); printf(" depending on the type of stereo you want\n"); +#ifndef _WIN32 + printf(" -i: parent windows ID \n"); +#endif #ifdef _WIN32 printf(" -c: keep console window open\n"); #endif + printf(" -d: turn debugging on\n"); printf(" -g: game engine options:\n"); printf(" Name Default Description\n"); printf(" ----------------------------------------\n"); @@ -187,14 +198,14 @@ void usage(char* program) printf(" show_framerate 0 Show the frame rate\n"); printf(" show_properties 0 Show debug properties\n"); printf(" show_profile 0 Show profiling information\n"); - printf(" vertexarrays 1 Enable vertex arrays\n"); printf(" blender_material 0 Enable material settings\n"); printf("\n"); printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program); - printf("example: %s -g vertexarrays = 0 c:\\loadtest.blend\n", program); + printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); } -char *get_filename(int argc, char **argv) { +static void get_filename(int argc, char **argv, char *filename) +{ #ifdef __APPLE__ /* On Mac we park the game file (called game.blend) in the application bundle. * The executable is located in the bundle as well. @@ -202,22 +213,18 @@ char *get_filename(int argc, char **argv) { */ int srclen = ::strlen(argv[0]); int len = 0; - char *filename = NULL; + char *gamefile = NULL; + filename[0] = '\0'; + if (argc > 1) { if (BLI_exists(argv[argc-1])) { - len = ::strlen(argv[argc-1]); - filename = new char [len + 1]; - ::strcpy(filename, argv[argc-1]); - return(filename); + BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); } if (::strncmp(argv[argc-1], "-psn_", 5)==0) { static char firstfilebuf[512]; if (GHOST_HACK_getFirstFile(firstfilebuf)) { - len = ::strlen(firstfilebuf); - filename = new char [len + 1]; - ::strcpy(filename, firstfilebuf); - return(filename); + BLI_strncpy(filename, firstfilebuf, FILE_MAXDIR + FILE_MAXFILE); } } } @@ -225,23 +232,26 @@ char *get_filename(int argc, char **argv) { srclen -= ::strlen("MacOS/blenderplayer"); if (srclen > 0) { len = srclen + ::strlen("Resources/game.blend"); - filename = new char [len + 1]; - ::strcpy(filename, argv[0]); - ::strcpy(filename + srclen, "Resources/game.blend"); + gamefile = new char [len + 1]; + ::strcpy(gamefile, argv[0]); + ::strcpy(gamefile + srclen, "Resources/game.blend"); //::printf("looking for file: %s\n", filename); - if (BLI_exists(filename)) { - return (filename); - } + if (BLI_exists(gamefile)) + BLI_strncpy(filename, gamefile, FILE_MAXDIR + FILE_MAXFILE); + + delete gamefile; } - return(NULL); #else - return (argc>1)?argv[argc-1]:NULL; + filename[0] = '\0'; + + if(argc > 1) + BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); #endif // !_APPLE } -static BlendFileData *load_game_data(char *progname, char *filename = NULL) { +static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) { BlendReadError error; BlendFileData *bfd = NULL; @@ -283,7 +293,7 @@ int main(int argc, char** argv) bool fullScreenParFound = false; bool windowParFound = false; bool closeConsole = true; - RAS_IRasterizer::StereoMode stereomode; + RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO; bool stereoWindow = false; bool stereoParFound = false; int windowLeft = 100; @@ -294,14 +304,16 @@ int main(int argc, char** argv) GHOST_TUns32 fullScreenHeight= 0; int fullScreenBpp = 32; int fullScreenFrequency = 60; + GHOST_TEmbedderWindowID parentWindow = 0; + + #ifdef __linux__ #ifdef __alpha__ signal (SIGFPE, SIG_IGN); #endif /* __alpha__ */ #endif /* __linux__ */ BLI_where_am_i(bprogname, argv[0]); - #ifdef __APPLE__ // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) /* @@ -323,8 +335,18 @@ int main(int argc, char** argv) ::DisposeNibReference(nibRef); */ #endif // __APPLE__ + + init_nodesystem(); + initglobals(); + GEN_init_messaging_system(); + +#ifdef WITH_QUICKTIME + quicktime_init(); +#endif + + libtiff_init(); // Parse command line options #ifndef NDEBUG @@ -403,6 +425,12 @@ int main(int argc, char** argv) } } break; + + case 'd': + i++; + G.f |= G_DEBUG; /* std output printf's */ + MEM_set_memory_debug(); + break; case 'p': // Parse window position and size options @@ -455,6 +483,16 @@ int main(int argc, char** argv) usage(argv[0]); return 0; break; +#ifndef _WIN32 + case 'i': + i++; + if ( (i + 1) < argc ) + parentWindow = atoi(argv[i++]); +#ifndef NDEBUG + printf("XWindows ID = %d\n", parentWindow); +#endif //NDEBUG + +#endif // _WIN32 case 'c': i++; closeConsole = false; @@ -525,21 +563,19 @@ int main(int argc, char** argv) return 0; } - if (!stereoParFound) stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO; - #ifdef WIN32 if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION) #endif { #ifdef __APPLE__ //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1); - SYS_WriteCommandLineInt(syshandle, "nomipmap", 1); + //SYS_WriteCommandLineInt(syshandle, "nomipmap", 1); //fullScreen = false; // Can't use full screen #endif if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { - GPC_PolygonMaterial::SetMipMappingEnabled(0); + GPU_set_mipmap(0); } // Create the system @@ -561,32 +597,46 @@ int main(int argc, char** argv) { int exitcode = KX_EXIT_REQUEST_NO_REQUEST; STR_String exitstring = ""; - GPG_Application app(system, NULL, exitstring); + GPG_Application app(system); bool firstTimeRunning = true; + char filename[FILE_MAXDIR + FILE_MAXFILE]; + char pathname[FILE_MAXDIR + FILE_MAXFILE]; + char *titlename; + + get_filename(argc, argv, filename); + if(filename[0]) + BLI_convertstringcwd(filename); do { // Read the Blender file - char *filename = get_filename(argc, argv); - char *titlename; - char pathname[160]; BlendFileData *bfd; // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file if (exitcode == KX_EXIT_REQUEST_START_OTHER_GAME) { - char basedpath[160]; + char basedpath[240]; - // base the actuator filename with respect - // to the original file working directory + // base the actuator filename relative to the last file strcpy(basedpath, exitstring.Ptr()); - BLI_convertstringcode(basedpath, pathname, 0); + BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); + + if (!bfd) + { + // just add "//" in front of it + char temppath[242]; + strcpy(temppath, "//"); + strcat(temppath, basedpath); + + BLI_convertstringcode(temppath, pathname); + bfd = load_game_data(temppath); + } } else { - bfd = load_game_data(argv[0], filename); + bfd = load_game_data(bprogname, filename[0]? filename: NULL); } //::printf("game data loaded from %s\n", filename); @@ -608,9 +658,10 @@ int main(int argc, char** argv) #endif // WIN32 Main *maggie = bfd->main; Scene *scene = bfd->curscene; - strcpy (pathname, maggie->name); - char *startscenename = scene->id.name + 2; - G.fileflags = bfd->fileflags; + G.main = maggie; + + if (firstTimeRunning) + G.fileflags = bfd->fileflags; //Seg Fault; icon.c gIcons == 0 BKE_icons_init(1); @@ -647,12 +698,16 @@ int main(int argc, char** argv) } // GPG_Application app (system, maggie, startscenename); - app.SetGameEngineData(maggie, startscenename); + app.SetGameEngineData(maggie, scene); + BLI_strncpy(pathname, maggie->name, sizeof(pathname)); + BLI_strncpy(G.sce, maggie->name, sizeof(G.sce)); + if (firstTimeRunning) { + setGamePythonPath(G.sce); firstTimeRunning = false; - + if (fullScreen) { #ifdef WIN32 @@ -710,7 +765,10 @@ int main(int argc, char** argv) else #endif { - app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, + if (parentWindow != 0) + app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode); + else + app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, stereoWindow, stereomode); } } @@ -737,13 +795,8 @@ int main(int argc, char** argv) } } app.StopGameEngine(); + BLO_blendfiledata_free(bfd); - -#ifdef __APPLE__ - if (filename) { - delete [] filename; - } -#endif // __APPLE__ } } while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME); } @@ -759,6 +812,8 @@ int main(int argc, char** argv) } } + free_nodesystem(); + return error ? -1 : 0; } diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index fd070c006f5..52e219db8f2 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -36,10 +36,12 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) # OpenGL header files +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_BMFONT)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../GamePlayer/common @@ -68,6 +70,9 @@ CPPFLAGS += -I../../../blender/blenloader CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna CPPFLAGS += -I../../../blender/readblenfile +CPPFLAGS += -I../../../blender/gpu + +CPPFLAGS += -I../../../gameengine/BlenderRoutines # kernel? GEN? stuff CPPFLAGS += -I../../../kernel/gen_system @@ -77,4 +82,3 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_GHOST)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) - diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index f704f02c513..a7ee2d51d14 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -3,47 +3,51 @@ import sys Import ('env') source_files = ['GPG_Application.cpp', - 'GPG_Canvas.cpp', - 'GPG_ghost.cpp', - 'GPG_KeyboardDevice.cpp', - 'GPG_System.cpp'] + 'GPG_Canvas.cpp', + 'GPG_ghost.cpp', + 'GPG_KeyboardDevice.cpp', + 'GPG_System.cpp'] incs = ['.', - '#intern/string', - '#intern/ghost', - '#intern/guardedalloc', - '#intern/bmfont', - '#intern/moto/include', - '#intern/SoundSystem', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - '#source/kernel/gen_system', - '#source/kernel/gen_messaging', - '#source/gameengine/Converter', - '#source/blender/imbuf', - '#source/gameengine/Ketsji', - '#source/blender/blenlib', - '#source/blender/blenkernel', - '#source/blender/readblenfile', - '#source/blender', - '#source/blender/editors/include', - '#source/blender/makesdna', - '#source/gameengine/Rasterizer', - '#source/gameengine/GameLogic', - '#source/gameengine/Expressions', - '#source/gameengine/Network', - '#source/gameengine/SceneGraph', - '#source/gameengine/Physics/common', - '#source/gameengine/Physics/Sumo', - '#source/gameengine/Physics/Sumo/Fuzzics/include', - '#source/gameengine/Network/LoopBackNetwork', - '#source/gameengine/GamePlayer/common', - '#source/blender/misc', - '#source/blender/blenloader'] + '#intern/string', + '#intern/ghost', + '#intern/guardedalloc', + '#intern/bmfont', + '#intern/moto/include', + '#intern/SoundSystem', + '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', + '#source/kernel/gen_system', + '#source/kernel/gen_messaging', + '#source/gameengine/Converter', + '#source/blender/imbuf', + '#source/gameengine/Ketsji', + '#source/blender/blenlib', + '#source/blender/blenkernel', + '#source/blender/readblenfile', + '#source/blender', + '#source/blender/include', + '#source/blender/makesdna', + '#source/gameengine/BlenderRoutines', + '#source/gameengine/Rasterizer', + '#source/gameengine/GameLogic', + '#source/gameengine/Expressions', + '#source/gameengine/Network', + '#source/gameengine/SceneGraph', + '#source/gameengine/Physics/common', + '#source/gameengine/Physics/Sumo', + '#source/gameengine/Physics/Sumo/Fuzzics/include', + '#source/gameengine/Network/LoopBackNetwork', + '#source/gameengine/GamePlayer/common', + '#source/blender/misc', + '#source/blender/blenloader', + '#source/blender/gpu', + '#extern/glew/include'] incs += Split(env['BF_PYTHON_INC']) incs += Split(env['BF_SOLID_INC']) cflags = [] if env['OURPLATFORM']=='win32-vc': - cflags = ['/GR'] + cflags = ['/GR'] + env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=5, compileflags=cflags) |