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
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/GamePlayer/ghost/GPG_ghost.cpp')
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp144
1 files changed, 65 insertions, 79 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index ba7d3135a10..5d843cccf85 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -258,10 +258,10 @@ static void usage(const char* program, bool isBlenderPlayer)
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.
-* Therefore, we can locate the game relative to the executable.
- */
+ /* On Mac we park the game file (called game.blend) in the application bundle.
+ * The executable is located in the bundle as well.
+ * Therefore, we can locate the game relative to the executable.
+ */
int srclen = ::strlen(argv[0]);
int len = 0;
char *gamefile = NULL;
@@ -449,6 +449,10 @@ int main(int argc, char** argv)
IMB_init();
BKE_images_init();
+#ifdef WITH_FFMPEG
+ IMB_ffmpeg_init();
+#endif
+
// 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();
@@ -471,7 +475,7 @@ int main(int argc, char** argv)
break;
case SCREEN_SAVER_MODE_PASSWORD:
/* This is W95 only, which we currently do not support.
- Fall-back to normal screen saver behavior in that case... */
+ * Fall-back to normal screen saver behavior in that case... */
case SCREEN_SAVER_MODE_SAVER:
fullScreen = true;
fullScreenParFound = true;
@@ -608,7 +612,7 @@ int main(int argc, char** argv)
case 'i':
i++;
if ( (i + 1) <= validArguments )
- parentWindow = atoi(argv[i++]);
+ parentWindow = atoi(argv[i++]);
else {
error = true;
printf("error: too few options for parent window argument.\n");
@@ -641,10 +645,10 @@ int main(int argc, char** argv)
stereomode = (RAS_IRasterizer::StereoMode) atoi(argv[i]);
if (stereomode < RAS_IRasterizer::RAS_STEREO_NOSTEREO || stereomode >= RAS_IRasterizer::RAS_STEREO_MAXSTEREO)
stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
-
+
if (!strcmp(argv[i], "nostereo")) // ok, redundant but clear
stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
-
+
// only the hardware pageflip method needs a stereo window
else if (!strcmp(argv[i], "hwpageflip")) {
stereomode = RAS_IRasterizer::RAS_STEREO_QUADBUFFERED;
@@ -652,22 +656,22 @@ int main(int argc, char** argv)
}
else if (!strcmp(argv[i], "syncdoubling"))
stereomode = RAS_IRasterizer::RAS_STEREO_ABOVEBELOW;
-
+
else if (!strcmp(argv[i], "anaglyph"))
stereomode = RAS_IRasterizer::RAS_STEREO_ANAGLYPH;
-
+
else if (!strcmp(argv[i], "sidebyside"))
stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
-
+
else if (!strcmp(argv[i], "vinterlace"))
stereomode = RAS_IRasterizer::RAS_STEREO_VINTERLACE;
-
+
#if 0
- // future stuff
- else if (!strcmp(argv[i], "stencil")
- stereomode = RAS_STEREO_STENCIL;
+// // future stuff
+// else if (!strcmp(argv[i], "stencil")
+// stereomode = RAS_STEREO_STENCIL;
#endif
-
+
i++;
stereoParFound = true;
stereoFlag = STEREO_ENABLED;
@@ -729,7 +733,7 @@ int main(int argc, char** argv)
i++;
}
}
-
+
if ((windowWidth < kMinWindowWidth) || (windowHeight < kMinWindowHeight))
{
error = true;
@@ -752,8 +756,7 @@ int main(int argc, char** argv)
//fullScreen = false; // Can't use full screen
#endif
- if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0))
- {
+ if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
GPU_set_mipmap(0);
}
@@ -761,15 +764,14 @@ int main(int argc, char** argv)
GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
// Create the system
- if (GHOST_ISystem::createSystem() == GHOST_kSuccess)
- {
+ if (GHOST_ISystem::createSystem() == GHOST_kSuccess) {
GHOST_ISystem* system = GHOST_ISystem::getSystem();
assertd(system);
if (!fullScreenWidth || !fullScreenHeight)
system->getMainDisplayDimensions(fullScreenWidth, fullScreenHeight);
// process first batch of events. If the user
- // drops a file on top off the blenderplayer icon, we
+ // drops a file on top off the blenderplayer icon, we
// receive an event with the filename
system->processEvents(0);
@@ -794,8 +796,7 @@ int main(int argc, char** argv)
// those may change during the game and persist after using Game Actuator
GlobalSettings gs;
- do
- {
+ do {
// Read the Blender file
BlendFileData *bfd;
@@ -810,19 +811,17 @@ int main(int argc, char** argv)
bfd = load_game_data(basedpath);
- if (!bfd)
- {
+ if (!bfd) {
// just add "//" in front of it
char temppath[242];
strcpy(temppath, "//");
strcat(temppath, basedpath);
-
+
BLI_path_abs(temppath, pathname);
bfd = load_game_data(temppath);
}
}
- else
- {
+ else {
bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL);
}
@@ -832,13 +831,11 @@ int main(int argc, char** argv)
usage(argv[0], isBlenderPlayer);
error = true;
exitcode = KX_EXIT_REQUEST_QUIT_GAME;
- }
- else
- {
+ }
+ else {
#ifdef WIN32
#if !defined(DEBUG)
- if (closeConsole)
- {
+ if (closeConsole) {
system->toggleConsole(0); // Close a console window
}
#endif // !defined(DEBUG)
@@ -860,8 +857,7 @@ int main(int argc, char** argv)
titlename = maggie->name;
// Check whether the game should be displayed full-screen
- if ((!fullScreenParFound) && (!windowParFound))
- {
+ if ((!fullScreenParFound) && (!windowParFound)) {
// Only use file settings when command line did not override
if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
//printf("fullscreen option found in Blender file\n");
@@ -881,16 +877,16 @@ int main(int argc, char** argv)
// Check whether the game should be displayed in stereo
- if (!stereoParFound)
- {
+ if (!stereoParFound) {
if (scene->gm.stereoflag == STEREO_ENABLED) {
stereomode = (RAS_IRasterizer::StereoMode) scene->gm.stereomode;
if (stereomode == RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
stereoWindow = true;
}
}
- else
+ else {
scene->gm.stereoflag = STEREO_ENABLED;
+ }
if (!samplesParFound)
aasamples = scene->gm.aasamples;
@@ -904,10 +900,9 @@ int main(int argc, char** argv)
scene->gm.dome.tilt = domeTilt;
if (domeMode > 0)
scene->gm.dome.mode = domeMode;
- if (domeWarp)
- {
+ if (domeWarp) {
//XXX to do: convert relative to absolute path
- domeText= BKE_text_load(domeWarp, "");
+ domeText= BKE_text_load(G.main, domeWarp, "");
if (!domeText)
printf("error: invalid warpdata text file - %s\n", domeWarp);
else
@@ -924,23 +919,21 @@ int main(int argc, char** argv)
#ifdef WITH_PYTHON
setGamePythonPath(G.main->name);
#endif
- if (firstTimeRunning)
- {
+ if (firstTimeRunning) {
firstTimeRunning = false;
- if (fullScreen)
- {
+ if (fullScreen) {
#ifdef WIN32
if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER)
{
app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
- stereoWindow, stereomode, aasamples);
+ stereoWindow, stereomode, aasamples);
}
else
#endif
{
app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
- stereoWindow, stereomode, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION));
+ stereoWindow, stereomode, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION));
}
}
else
@@ -964,8 +957,7 @@ int main(int argc, char** argv)
vector<STR_String> parts = path.Explode('\\');
#endif // WIN32
STR_String title;
- if (parts.size())
- {
+ if (parts.size()) {
title = parts[parts.size()-1];
parts = title.Explode('.');
if (parts.size() > 1)
@@ -973,8 +965,7 @@ int main(int argc, char** argv)
title = parts[0];
}
}
- else
- {
+ else {
title = "blenderplayer";
}
#ifdef WIN32
@@ -985,16 +976,15 @@ int main(int argc, char** argv)
else
#endif
{
- if (parentWindow != 0)
+ if (parentWindow != 0)
app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aasamples);
else
app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
- stereoWindow, stereomode, aasamples);
+ stereoWindow, stereomode, aasamples);
}
}
}
- else
- {
+ else {
app.StartGameEngine(stereomode);
exitcode = KX_EXIT_REQUEST_NO_REQUEST;
}
@@ -1004,44 +994,40 @@ int main(int argc, char** argv)
// Enter main loop
bool run = true;
- char *python_main = NULL;
+ char *python_main = NULL;
pynextframestate.state = NULL;
pynextframestate.func = NULL;
#ifdef WITH_PYTHON
python_main = KX_GetPythonMain(scene);
#endif // WITH_PYTHON
- if (python_main)
- {
+ if (python_main) {
char *python_code = KX_GetPythonCode(maggie, python_main);
- if (python_code)
- {
-#ifdef WITH_PYTHON
+ if (python_code) {
+#ifdef WITH_PYTHON
gpg_nextframestate.system = system;
gpg_nextframestate.app = &app;
gpg_nextframestate.gs = &gs;
pynextframestate.state = &gpg_nextframestate;
pynextframestate.func = &GPG_PyNextFrame;
- printf("Yielding control to Python script '%s'...\n", python_main);
- PyRun_SimpleString(python_code);
- printf("Exit Python script '%s'\n", python_main);
+ printf("Yielding control to Python script '%s'...\n", python_main);
+ PyRun_SimpleString(python_code);
+ printf("Exit Python script '%s'\n", python_main);
#endif // WITH_PYTHON
- MEM_freeN(python_code);
- }
- else {
- fprintf(stderr, "ERROR: cannot yield control to Python: no Python text data block named '%s'\n", python_main);
- }
- }
- else
- {
- while (run)
- {
+ MEM_freeN(python_code);
+ }
+ else {
+ fprintf(stderr, "ERROR: cannot yield control to Python: no Python text data block named '%s'\n", python_main);
+ }
+ }
+ else {
+ while (run) {
run = GPG_NextFrame(system, &app, exitcode, exitstring, &gs);
}
}
app.StopGameEngine();
- /* 'app' is freed automatic when out of scope.
+ /* 'app' is freed automatic when out of scope.
* removal is needed else the system will free an already freed value */
system->removeEventConsumer(&app);
@@ -1056,7 +1042,8 @@ int main(int argc, char** argv)
// Dispose the system
GHOST_ISystem::disposeSystem();
- } else {
+ }
+ else {
error = true;
printf("error: couldn't create a system.\n");
}
@@ -1068,6 +1055,7 @@ int main(int argc, char** argv)
#ifdef WITH_INTERNATIONAL
BLF_free_unifont();
+ BLF_free_unifont_mono();
BLF_lang_free();
#endif
@@ -1086,5 +1074,3 @@ int main(int argc, char** argv)
return error ? -1 : 0;
}
-
-