2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2011-10-23 17:52:20 +00:00
|
|
|
* Start up of the Blender Player on GHOST.
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-02-25 13:35:11 +00:00
|
|
|
/** \file gameengine/GamePlayer/ghost/GPG_ghost.cpp
|
|
|
|
* \ingroup player
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
#ifdef __alpha__
|
|
|
|
#include <signal.h>
|
|
|
|
#endif /* __alpha__ */
|
|
|
|
#endif /* __linux__ */
|
|
|
|
|
|
|
|
#include "KX_KetsjiEngine.h"
|
2008-10-11 00:56:49 +00:00
|
|
|
#include "KX_PythonInit.h"
|
2012-09-01 21:23:05 +00:00
|
|
|
#include "KX_PythonMain.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**********************************
|
|
|
|
* Begin Blender include block
|
|
|
|
**********************************/
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif // __cplusplus
|
2008-09-15 12:40:17 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2013-12-22 09:26:59 +00:00
|
|
|
#include "MEM_CacheLimiterC-Api.h"
|
|
|
|
|
2013-08-25 21:24:16 +00:00
|
|
|
#include "BLI_threads.h"
|
2013-10-03 16:34:00 +00:00
|
|
|
#include "BLI_mempool.h"
|
2013-08-25 21:24:16 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2013-10-03 16:34:00 +00:00
|
|
|
|
2013-08-25 21:24:16 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_userdef_types.h"
|
2013-10-03 16:34:00 +00:00
|
|
|
|
2013-08-25 21:24:16 +00:00
|
|
|
#include "BLO_readfile.h"
|
|
|
|
#include "BLO_runtime.h"
|
2013-10-03 16:34:00 +00:00
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
#include "BKE_blender.h"
|
2013-08-19 10:51:40 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2012-09-16 04:58:18 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_icons.h"
|
2012-11-15 15:59:58 +00:00
|
|
|
#include "BKE_image.h"
|
2012-09-16 04:58:18 +00:00
|
|
|
#include "BKE_node.h"
|
2011-05-29 04:15:35 +00:00
|
|
|
#include "BKE_report.h"
|
|
|
|
#include "BKE_library.h"
|
2013-08-19 09:05:34 +00:00
|
|
|
#include "BKE_modifier.h"
|
2010-02-25 06:05:56 +00:00
|
|
|
#include "BKE_text.h"
|
2011-06-02 23:25:38 +00:00
|
|
|
#include "BKE_sound.h"
|
2013-10-03 16:34:00 +00:00
|
|
|
|
2013-08-25 21:24:16 +00:00
|
|
|
#include "IMB_imbuf.h"
|
2014-01-29 21:39:44 +00:00
|
|
|
#include "IMB_moviecache.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-11-12 07:16:33 +00:00
|
|
|
// For BLF
|
|
|
|
#include "BLF_api.h"
|
2011-09-20 09:32:14 +00:00
|
|
|
#include "BLF_translation.h"
|
2010-11-12 07:16:33 +00:00
|
|
|
extern int datatoc_bfont_ttf_size;
|
|
|
|
extern char datatoc_bfont_ttf[];
|
2013-11-04 19:22:15 +00:00
|
|
|
extern int datatoc_bmonofont_ttf_size;
|
|
|
|
extern char datatoc_bmonofont_ttf[];
|
2010-11-12 07:16:33 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif // __cplusplus
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
#include "GPU_draw.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**********************************
|
|
|
|
* End Blender include block
|
|
|
|
**********************************/
|
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
#include "BL_System.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "GPG_Application.h"
|
|
|
|
|
|
|
|
#include "GHOST_ISystem.h"
|
|
|
|
#include "RAS_IRasterizer.h"
|
|
|
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
2010-10-18 06:52:10 +00:00
|
|
|
#if !defined(DEBUG)
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <wincon.h>
|
2010-10-18 06:52:10 +00:00
|
|
|
#endif // !defined(DEBUG)
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif // WIN32
|
|
|
|
|
2014-11-17 11:35:36 +00:00
|
|
|
#ifdef WITH_SDL_DYNLOAD
|
|
|
|
# include "sdlew.h"
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
const int kMinWindowWidth = 100;
|
|
|
|
const int kMinWindowHeight = 100;
|
|
|
|
|
2011-03-26 04:50:59 +00:00
|
|
|
static void mem_error_cb(const char *errorStr)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s", errorStr);
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
|
2013-08-10 21:17:46 +00:00
|
|
|
// library.c will only free window managers with a callback function.
|
|
|
|
// We don't actually use a wmWindowManager, but loading a blendfile
|
|
|
|
// loads wmWindows, so we need to free those.
|
|
|
|
static void wm_free(bContext *C, wmWindowManager *wm)
|
|
|
|
{
|
|
|
|
BLI_freelistN(&wm->windows);
|
|
|
|
}
|
|
|
|
|
2004-12-01 08:35:38 +00:00
|
|
|
#ifdef WIN32
|
2012-06-06 22:38:39 +00:00
|
|
|
typedef enum {
|
2012-11-03 15:35:03 +00:00
|
|
|
SCREEN_SAVER_MODE_NONE = 0,
|
|
|
|
SCREEN_SAVER_MODE_PREVIEW,
|
|
|
|
SCREEN_SAVER_MODE_SAVER,
|
|
|
|
SCREEN_SAVER_MODE_CONFIGURATION,
|
|
|
|
SCREEN_SAVER_MODE_PASSWORD,
|
2004-12-01 08:35:38 +00:00
|
|
|
} ScreenSaverMode;
|
|
|
|
|
|
|
|
static ScreenSaverMode scr_saver_mode = SCREEN_SAVER_MODE_NONE;
|
|
|
|
static HWND scr_saver_hwnd = NULL;
|
|
|
|
|
|
|
|
static BOOL scr_saver_init(int argc, char **argv)
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_NONE;
|
|
|
|
scr_saver_hwnd = NULL;
|
2014-04-01 00:34:00 +00:00
|
|
|
BOOL ret = false;
|
2004-12-01 08:35:38 +00:00
|
|
|
|
|
|
|
int len = ::strlen(argv[0]);
|
|
|
|
if (len > 4 && !::stricmp(".scr", argv[0] + len - 4))
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
|
2014-04-01 00:34:00 +00:00
|
|
|
ret = true;
|
2004-12-01 08:35:38 +00:00
|
|
|
if (argc >= 2)
|
|
|
|
{
|
|
|
|
if (argc >= 3)
|
|
|
|
{
|
|
|
|
scr_saver_hwnd = (HWND) ::atoi(argv[2]);
|
|
|
|
}
|
|
|
|
if (!::stricmp("/c", argv[1]))
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
|
|
|
|
if (scr_saver_hwnd == NULL)
|
|
|
|
scr_saver_hwnd = ::GetForegroundWindow();
|
|
|
|
}
|
|
|
|
else if (!::stricmp("/s", argv[1]))
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_SAVER;
|
|
|
|
}
|
|
|
|
else if (!::stricmp("/a", argv[1]))
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_PASSWORD;
|
|
|
|
}
|
|
|
|
else if (!::stricmp("/p", argv[1])
|
|
|
|
|| !::stricmp("/l", argv[1]))
|
|
|
|
{
|
|
|
|
scr_saver_mode = SCREEN_SAVER_MODE_PREVIEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
2012-11-09 23:47:06 +00:00
|
|
|
static void usage(const char* program, bool isBlenderPlayer)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-09-20 11:08:35 +00:00
|
|
|
const char * consoleoption;
|
2011-10-23 17:52:20 +00:00
|
|
|
const char * example_filename = "";
|
|
|
|
const char * example_pathname = "";
|
2010-09-13 08:30:56 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef _WIN32
|
2014-04-06 21:17:31 +00:00
|
|
|
consoleoption = "[-c] ";
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
|
|
|
consoleoption = "";
|
|
|
|
#endif
|
2010-09-13 08:30:56 +00:00
|
|
|
|
|
|
|
if (isBlenderPlayer) {
|
2011-10-23 17:52:20 +00:00
|
|
|
example_filename = "filename.blend";
|
2010-09-13 08:30:56 +00:00
|
|
|
#ifdef _WIN32
|
2011-10-23 17:52:20 +00:00
|
|
|
example_pathname = "c:\\";
|
2010-09-13 08:30:56 +00:00
|
|
|
#else
|
2011-10-23 17:52:20 +00:00
|
|
|
example_pathname = "/home/user/";
|
2010-09-13 08:30:56 +00:00
|
|
|
#endif
|
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
printf("\n");
|
|
|
|
printf("usage: %s [--options] %s\n\n", program, example_filename);
|
|
|
|
printf("Available options are: [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] ", consoleoption);
|
|
|
|
printf("[-s stereomode] [-m aasamples]\n");
|
|
|
|
printf("Optional parameters must be passed in order.\n");
|
|
|
|
printf("Default values are set in the blend file.\n\n");
|
2009-02-28 21:44:24 +00:00
|
|
|
printf(" -h: Prints this command summary\n\n");
|
2004-03-22 22:02:18 +00:00
|
|
|
printf(" -w: display in a window\n");
|
2009-02-28 21:44:24 +00:00
|
|
|
printf(" --Optional parameters--\n");
|
|
|
|
printf(" w = window width\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" h = window height\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
printf(" l = window left coordinate\n");
|
|
|
|
printf(" t = window top coordinate\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" Note: To define 'w' or 'h', both must be used.");
|
|
|
|
printf("Also, to define 'l' or 't', all four parameters must be used.\n");
|
|
|
|
printf(" Example: -w or -w 500 300 or -w 500 300 0 0\n\n");
|
|
|
|
printf(" -f: start game in fullscreen mode\n");
|
2009-02-28 21:44:24 +00:00
|
|
|
printf(" --Optional parameters--\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" fw = fullscreen mode pixel width (use 0 to detect automatically)\n");
|
|
|
|
printf(" fh = fullscreen mode pixel height (use 0 to detect automatically)\n");
|
|
|
|
printf(" fb = fullscreen mode bits per pixel (default unless set in the blend file: 32)\n");
|
|
|
|
printf(" ff = fullscreen mode frequency (default unless set in the blend file: 60)\n");
|
|
|
|
printf(" Note: To define 'fw'' or 'fh'', both must be used.\n");
|
|
|
|
printf(" Example: -f or -f 1024 768 or -f 0 0 16 or -f 1024 728 16 30\n\n");
|
|
|
|
printf(" -s: start player in stereoscopy mode (requires 3D capable hardware)\n");
|
|
|
|
printf(" stereomode: nostereo (default unless stereo is set in the blend file)\n");
|
2004-08-10 11:34:12 +00:00
|
|
|
printf(" anaglyph (Red-Blue glasses)\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" sidebyside (Left Right)\n");
|
|
|
|
printf(" syncdoubling (Above Below)\n");
|
|
|
|
printf(" 3dtvtopbottom (Squashed Top-Bottom for passive glasses)\n");
|
|
|
|
printf(" interlace (Interlace horizontally)\n");
|
2004-10-24 11:03:18 +00:00
|
|
|
printf(" vinterlace (Vertical interlace for autostereo display)\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" hwpageflip (Quad buffered shutter glasses)\n");
|
|
|
|
printf(" Example: -s sidebyside or -s vinterlace\n\n");
|
2010-02-24 23:01:49 +00:00
|
|
|
printf(" -D: start player in dome mode\n");
|
|
|
|
printf(" --Optional parameters--\n");
|
2010-02-25 06:05:56 +00:00
|
|
|
printf(" angle = field of view in degrees\n");
|
|
|
|
printf(" tilt = tilt angle in degrees\n");
|
2012-09-16 04:58:18 +00:00
|
|
|
printf(" warpdata = a file to use for warping the image (absolute path)\n");
|
2010-02-24 23:01:49 +00:00
|
|
|
printf(" mode: fisheye (Fisheye)\n");
|
|
|
|
printf(" truncatedfront (Front-Truncated)\n");
|
|
|
|
printf(" truncatedrear (Rear-Truncated)\n");
|
|
|
|
printf(" cubemap (Cube Map)\n");
|
|
|
|
printf(" sphericalpanoramic (Spherical Panoramic)\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" Example: -D or -D mode cubemap\n\n");
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
printf(" -m: maximum anti-aliasing (eg. 2,4,8,16)\n\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf(" -i: parent window's ID\n\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef _WIN32
|
2009-02-28 21:44:24 +00:00
|
|
|
printf(" -c: keep console window open\n\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
2009-02-28 21:44:24 +00:00
|
|
|
printf(" -d: turn debugging on\n\n");
|
2009-01-26 08:34:40 +00:00
|
|
|
printf(" -g: game engine options:\n\n");
|
|
|
|
printf(" Name Default Description\n");
|
|
|
|
printf(" ------------------------------------------------------------------------\n");
|
|
|
|
printf(" fixedtime 0 \"Enable all frames\"\n");
|
|
|
|
printf(" nomipmap 0 Disable mipmaps\n");
|
|
|
|
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(" blender_material 0 Enable material settings\n");
|
2009-04-20 15:06:46 +00:00
|
|
|
printf(" ignore_deprecation_warnings 1 Ignore deprecation warnings\n");
|
|
|
|
printf("\n");
|
|
|
|
printf(" - : all arguments after this are ignored, allowing python to access them from sys.argv\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
printf("\n");
|
2014-04-06 21:17:31 +00:00
|
|
|
printf("example: %s -w 320 200 10 10 -g noaudio %s%s\n", program, example_pathname, example_filename);
|
2011-10-23 17:52:20 +00:00
|
|
|
printf("example: %s -g show_framerate = 0 %s%s\n", program, example_pathname, example_filename);
|
|
|
|
printf("example: %s -i 232421 -m 16 %s%s\n\n", program, example_pathname, example_filename);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2008-09-12 16:06:17 +00:00
|
|
|
static void get_filename(int argc, char **argv, char *filename)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __APPLE__
|
2013-02-02 04:48:21 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
int srclen = ::strlen(argv[0]);
|
|
|
|
int len = 0;
|
2008-09-12 16:06:17 +00:00
|
|
|
char *gamefile = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-12 16:06:17 +00:00
|
|
|
filename[0] = '\0';
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
if (BLI_exists(argv[argc-1])) {
|
2011-11-26 04:07:38 +00:00
|
|
|
BLI_strncpy(filename, argv[argc-1], FILE_MAX);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
srclen -= ::strlen("MacOS/blenderplayer");
|
|
|
|
if (srclen > 0) {
|
|
|
|
len = srclen + ::strlen("Resources/game.blend");
|
2008-09-12 16:06:17 +00:00
|
|
|
gamefile = new char [len + 1];
|
|
|
|
::strcpy(gamefile, argv[0]);
|
|
|
|
::strcpy(gamefile + srclen, "Resources/game.blend");
|
2002-10-12 11:37:38 +00:00
|
|
|
//::printf("looking for file: %s\n", filename);
|
|
|
|
|
2008-09-12 16:06:17 +00:00
|
|
|
if (BLI_exists(gamefile))
|
2011-11-26 04:07:38 +00:00
|
|
|
BLI_strncpy(filename, gamefile, FILE_MAX);
|
2008-09-12 16:06:17 +00:00
|
|
|
|
2009-03-16 17:02:19 +00:00
|
|
|
delete [] gamefile;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2008-09-12 16:06:17 +00:00
|
|
|
filename[0] = '\0';
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (argc > 1)
|
2011-11-26 04:07:38 +00:00
|
|
|
BLI_strncpy(filename, argv[argc-1], FILE_MAX);
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif // !_APPLE
|
|
|
|
}
|
|
|
|
|
2011-10-19 23:10:54 +00:00
|
|
|
static BlendFileData *load_game_data(const char *progname, char *filename = NULL, char *relativename = NULL)
|
2008-12-19 00:50:21 +00:00
|
|
|
{
|
|
|
|
ReportList reports;
|
2004-04-24 06:29:51 +00:00
|
|
|
BlendFileData *bfd = NULL;
|
2008-12-19 00:50:21 +00:00
|
|
|
|
|
|
|
BKE_reports_init(&reports, RPT_STORE);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* try to load ourself, will only work if we are a runtime */
|
2011-05-11 19:29:23 +00:00
|
|
|
if (BLO_is_a_runtime(progname)) {
|
|
|
|
bfd= BLO_read_runtime(progname, &reports);
|
2004-04-29 10:51:02 +00:00
|
|
|
if (bfd) {
|
|
|
|
bfd->type= BLENFILETYPE_RUNTIME;
|
2011-10-19 23:10:54 +00:00
|
|
|
BLI_strncpy(bfd->main->name, progname, sizeof(bfd->main->name));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-04-29 10:51:02 +00:00
|
|
|
} else {
|
2008-12-19 00:50:21 +00:00
|
|
|
bfd= BLO_read_from_file(progname, &reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-29 10:51:02 +00:00
|
|
|
if (!bfd && filename) {
|
|
|
|
bfd = load_game_data(filename);
|
|
|
|
if (!bfd) {
|
2008-12-19 00:50:21 +00:00
|
|
|
printf("Loading %s failed: ", filename);
|
|
|
|
BKE_reports_print(&reports, RPT_ERROR);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-19 00:50:21 +00:00
|
|
|
|
|
|
|
BKE_reports_clear(&reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return bfd;
|
|
|
|
}
|
|
|
|
|
2012-11-09 23:47:06 +00:00
|
|
|
static bool GPG_NextFrame(GHOST_ISystem* system, GPG_Application *app, int &exitcode, STR_String &exitstring, GlobalSettings *gs)
|
2012-09-01 21:23:05 +00:00
|
|
|
{
|
2012-09-06 02:20:03 +00:00
|
|
|
bool run = true;
|
|
|
|
system->processEvents(false);
|
|
|
|
system->dispatchEvents();
|
2012-09-04 02:33:37 +00:00
|
|
|
app->EngineNextFrame();
|
2012-09-06 02:20:03 +00:00
|
|
|
if ((exitcode = app->getExitRequested())) {
|
|
|
|
run = false;
|
|
|
|
exitstring = app->getExitString();
|
|
|
|
*gs = *app->getGlobalSettings();
|
|
|
|
}
|
|
|
|
return run;
|
2012-09-01 21:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct GPG_NextFrameState {
|
|
|
|
GHOST_ISystem* system;
|
|
|
|
GPG_Application *app;
|
|
|
|
GlobalSettings *gs;
|
|
|
|
} gpg_nextframestate;
|
|
|
|
|
2012-11-09 23:47:06 +00:00
|
|
|
static int GPG_PyNextFrame(void *state0)
|
2012-09-01 21:23:05 +00:00
|
|
|
{
|
|
|
|
GPG_NextFrameState *state = (GPG_NextFrameState *) state0;
|
|
|
|
int exitcode;
|
|
|
|
STR_String exitstring;
|
|
|
|
bool run = GPG_NextFrame(state->system, state->app, exitcode, exitstring, state->gs);
|
|
|
|
if (run) return 0;
|
|
|
|
else {
|
|
|
|
if (exitcode)
|
|
|
|
fprintf(stderr, "Exit code %d: %s\n", exitcode, exitstring.ReadPtr());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
int i;
|
2009-04-20 15:06:46 +00:00
|
|
|
int argc_py_clamped= argc; /* use this so python args can be added after ' - ' */
|
2002-10-12 11:37:38 +00:00
|
|
|
bool error = false;
|
|
|
|
SYS_SystemHandle syshandle = SYS_GetSystem();
|
2004-07-17 00:48:59 +00:00
|
|
|
bool fullScreen = false;
|
|
|
|
bool fullScreenParFound = false;
|
2002-10-12 11:37:38 +00:00
|
|
|
bool windowParFound = false;
|
2011-05-18 06:27:32 +00:00
|
|
|
#ifdef WIN32
|
2002-10-12 11:37:38 +00:00
|
|
|
bool closeConsole = true;
|
2011-05-18 06:27:32 +00:00
|
|
|
#endif
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
|
2002-10-12 11:37:38 +00:00
|
|
|
bool stereoWindow = false;
|
|
|
|
bool stereoParFound = false;
|
2010-02-24 23:01:49 +00:00
|
|
|
int stereoFlag = STEREO_NOSTEREO;
|
|
|
|
int domeFov = -1;
|
|
|
|
int domeTilt = -200;
|
|
|
|
int domeMode = 0;
|
|
|
|
char* domeWarp = NULL;
|
2010-02-25 06:05:56 +00:00
|
|
|
Text *domeText = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
int windowLeft = 100;
|
|
|
|
int windowTop = 100;
|
|
|
|
int windowWidth = 640;
|
|
|
|
int windowHeight = 480;
|
2004-03-22 22:02:18 +00:00
|
|
|
GHOST_TUns32 fullScreenWidth = 0;
|
|
|
|
GHOST_TUns32 fullScreenHeight= 0;
|
2004-08-10 11:34:12 +00:00
|
|
|
int fullScreenBpp = 32;
|
2002-10-12 11:37:38 +00:00
|
|
|
int fullScreenFrequency = 60;
|
2008-09-09 21:15:30 +00:00
|
|
|
GHOST_TEmbedderWindowID parentWindow = 0;
|
2014-04-06 21:17:31 +00:00
|
|
|
bool isBlenderPlayer = false; //true when lauching from blender or command line. false for bundled player
|
2010-09-13 08:30:56 +00:00
|
|
|
int validArguments=0;
|
2012-01-11 20:53:22 +00:00
|
|
|
bool samplesParFound = false;
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
GHOST_TUns16 aasamples = 0;
|
2008-08-20 06:11:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
#ifdef __alpha__
|
|
|
|
signal (SIGFPE, SIG_IGN);
|
|
|
|
#endif /* __alpha__ */
|
|
|
|
#endif /* __linux__ */
|
2014-11-17 11:35:36 +00:00
|
|
|
|
|
|
|
#ifdef WITH_SDL_DYNLOAD
|
|
|
|
sdlewInit();
|
|
|
|
#endif
|
|
|
|
|
2011-10-21 17:37:38 +00:00
|
|
|
BLI_init_program_path(argv[0]);
|
T39690: Modifications to Blender's 'temp dir' system.
Current temporary data of Blender suffers one major issue - default 'temp' dir on Windows is never
automatically cleaned up, and can end being quite big when used by Blender, especially when we have
to store per-process data (using getpid() in file names).
To address this, this patch:
* Divides tempdir paths in two, one for 'base' temp dir (the same as previous unique tempdir path),
the other is a mkdtemp-generated sub-dir, specific to each Blender instance.
* Only uses base tempdir when we need some shallow persistance accross Blender sessions - and we always
reuse the same filename (quit.blend...) or generate small file (crash reports...).
* Uses temp sub-dir for heavy files like pointcache or renderEXRs (Save Buffer option).
* Erases temp sub-dir on quit or crash.
To get this working it also adds a working 'recursive delete' to BLI_delete() under Windows.
Note that, as in current code, the 'recover render result' hack-feature that was possible
with SaveBuffer option is still removed. A real renderresult cache feature will be added
soon, though.
Reviewers: campbellbarton, brecht, sergey
Reviewed By: campbellbarton, sergey
CC: sergey
Differential Revision: https://developer.blender.org/D531
2014-06-23 11:42:19 +00:00
|
|
|
BLI_temp_dir_init(NULL);
|
2011-07-07 10:37:46 +00:00
|
|
|
|
|
|
|
// We don't use threads directly in the BGE, but we need to call this so things like
|
|
|
|
// freeing up GPU_Textures works correctly.
|
|
|
|
BLI_threadapi_init();
|
2011-06-20 10:07:46 +00:00
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
RNA_init();
|
|
|
|
|
2008-09-14 03:51:51 +00:00
|
|
|
init_nodesystem();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-26 14:54:21 +00:00
|
|
|
initglobals();
|
|
|
|
|
2011-10-26 14:05:01 +00:00
|
|
|
U.gameflags |= USER_DISABLE_VBO;
|
2011-05-29 04:15:35 +00:00
|
|
|
// We load our own G.main, so free the one that initglobals() gives us
|
2013-12-30 02:25:27 +00:00
|
|
|
BKE_main_free(G.main);
|
2011-06-24 03:30:50 +00:00
|
|
|
G.main = NULL;
|
2011-05-29 04:15:35 +00:00
|
|
|
|
2013-12-22 09:26:59 +00:00
|
|
|
MEM_CacheLimiter_set_disabled(true);
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
IMB_init();
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_images_init();
|
2013-08-19 09:05:34 +00:00
|
|
|
BKE_modifier_init();
|
2013-12-26 11:24:42 +00:00
|
|
|
DAG_init();
|
2010-11-12 07:16:33 +00:00
|
|
|
|
2013-02-22 20:37:14 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
|
|
|
IMB_ffmpeg_init();
|
|
|
|
#endif
|
|
|
|
|
2011-09-19 15:10:38 +00:00
|
|
|
// 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("");
|
|
|
|
|
2010-11-12 07:16:33 +00:00
|
|
|
BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
2013-11-04 19:22:15 +00:00
|
|
|
if (blf_mono_font == -1)
|
|
|
|
blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
|
2011-09-01 02:12:53 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Parse command line options
|
2010-10-18 06:52:10 +00:00
|
|
|
#if defined(DEBUG)
|
2002-10-12 11:37:38 +00:00
|
|
|
printf("argv[0] = '%s'\n", argv[0]);
|
|
|
|
#endif
|
2004-12-01 08:35:38 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
if (scr_saver_init(argc, argv))
|
|
|
|
{
|
|
|
|
switch (scr_saver_mode)
|
|
|
|
{
|
|
|
|
case SCREEN_SAVER_MODE_CONFIGURATION:
|
|
|
|
MessageBox(scr_saver_hwnd, "This screen saver has no options that you can set", "Screen Saver", MB_OK);
|
|
|
|
break;
|
|
|
|
case SCREEN_SAVER_MODE_PASSWORD:
|
|
|
|
/* This is W95 only, which we currently do not support.
|
2013-02-02 04:48:21 +00:00
|
|
|
* Fall-back to normal screen saver behavior in that case... */
|
2004-12-01 08:35:38 +00:00
|
|
|
case SCREEN_SAVER_MODE_SAVER:
|
|
|
|
fullScreen = true;
|
|
|
|
fullScreenParFound = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCREEN_SAVER_MODE_PREVIEW:
|
|
|
|
/* This will actually be handled somewhere below... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2009-09-04 20:14:59 +00:00
|
|
|
// XXX add the ability to change this values to the command line parsing.
|
|
|
|
U.mixbufsize = 2048;
|
|
|
|
U.audiodevice = 2;
|
|
|
|
U.audiorate = 44100;
|
|
|
|
U.audioformat = 0x24;
|
|
|
|
U.audiochannels = 2;
|
|
|
|
|
2011-06-24 03:30:50 +00:00
|
|
|
// XXX this one too
|
|
|
|
U.anisotropic_filter = 2;
|
2012-12-11 08:01:16 +00:00
|
|
|
// enable fast mipmap generation
|
|
|
|
U.use_gpu_mipmap = 1;
|
2011-06-24 03:30:50 +00:00
|
|
|
|
2011-06-02 23:25:38 +00:00
|
|
|
sound_init_once();
|
|
|
|
|
2013-08-10 21:17:46 +00:00
|
|
|
set_free_windowmanager_cb(wm_free);
|
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
/* if running blenderplayer the last argument can't be parsed since it has to be the filename. else it is bundled */
|
2011-05-11 19:29:23 +00:00
|
|
|
isBlenderPlayer = !BLO_is_a_runtime(argv[0]);
|
2010-09-13 08:30:56 +00:00
|
|
|
if (isBlenderPlayer)
|
|
|
|
validArguments = argc - 1;
|
|
|
|
else
|
|
|
|
validArguments = argc;
|
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
|
|
|
|
/* Parsing command line arguments (can be set from WM_OT_blenderplayer_start) */
|
|
|
|
#if defined(DEBUG)
|
|
|
|
printf("Parsing command line arguments...\n");
|
|
|
|
printf("Num of arguments is: %i\n", validArguments-1); //-1 because i starts at 1
|
|
|
|
#endif
|
|
|
|
|
2010-09-13 08:30:56 +00:00
|
|
|
for (i = 1; (i < validArguments) && !error
|
2004-12-01 08:35:38 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
&& scr_saver_mode == SCREEN_SAVER_MODE_NONE
|
|
|
|
#endif
|
|
|
|
;)
|
2004-11-07 22:21:47 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2010-10-18 06:52:10 +00:00
|
|
|
#if defined(DEBUG)
|
2014-04-06 21:17:31 +00:00
|
|
|
printf("argv[%d] = '%s'\n", i, argv[i]);
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
if (argv[i][0] == '-')
|
|
|
|
{
|
2009-04-20 15:06:46 +00:00
|
|
|
/* ignore all args after " - ", allow python to have own args */
|
|
|
|
if (argv[i][1]=='\0') {
|
|
|
|
argc_py_clamped= i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
switch (argv[i][1])
|
|
|
|
{
|
2014-04-06 21:17:31 +00:00
|
|
|
case 'g': //game engine options (show_framerate, fixedtime, etc)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if (i <= validArguments)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-04-06 21:17:31 +00:00
|
|
|
char* paramname = argv[i];
|
|
|
|
// Check for single value versus assignment
|
|
|
|
if (i+1 <= validArguments && (*(argv[i+1]) == '='))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-04-06 21:17:31 +00:00
|
|
|
i++;
|
|
|
|
if (i + 1 <= validArguments)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
i++;
|
2014-04-06 21:17:31 +00:00
|
|
|
// Assignment
|
|
|
|
SYS_WriteCommandLineInt(syshandle, paramname, atoi(argv[i]));
|
|
|
|
SYS_WriteCommandLineFloat(syshandle, paramname, atof(argv[i]));
|
|
|
|
SYS_WriteCommandLineString(syshandle, paramname, argv[i]);
|
2010-10-18 06:52:10 +00:00
|
|
|
#if defined(DEBUG)
|
2014-04-06 21:17:31 +00:00
|
|
|
printf("%s = '%s'\n", paramname, argv[i]);
|
2004-08-10 11:34:12 +00:00
|
|
|
#endif
|
2014-04-06 21:17:31 +00:00
|
|
|
i++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-06 21:17:31 +00:00
|
|
|
error = true;
|
|
|
|
printf("error: argument assignment %s without value.\n", paramname);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// SYS_WriteCommandLineInt(syshandle, argv[i++], 1);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'd': //debug on
|
|
|
|
{
|
2008-09-15 12:40:17 +00:00
|
|
|
i++;
|
2013-10-03 16:34:00 +00:00
|
|
|
G.debug |= G_DEBUG;
|
2008-09-15 12:40:17 +00:00
|
|
|
MEM_set_memory_debug();
|
2013-10-03 16:34:00 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
BLI_mempool_set_memory_debug();
|
|
|
|
#endif
|
2008-09-15 12:40:17 +00:00
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'f': //fullscreen mode
|
|
|
|
{
|
2004-08-10 11:34:12 +00:00
|
|
|
i++;
|
|
|
|
fullScreen = true;
|
|
|
|
fullScreenParFound = true;
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
2004-08-10 11:34:12 +00:00
|
|
|
{
|
|
|
|
fullScreenWidth = atoi(argv[i++]);
|
|
|
|
fullScreenHeight = atoi(argv[i++]);
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 1) <= validArguments && argv[i][0] != '-')
|
2004-08-10 11:34:12 +00:00
|
|
|
{
|
|
|
|
fullScreenBpp = atoi(argv[i++]);
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 1) <= validArguments && argv[i][0] != '-')
|
2004-08-10 11:34:12 +00:00
|
|
|
fullScreenFrequency = atoi(argv[i++]);
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: to define fullscreen width or height, both options must be used.\n");
|
|
|
|
}
|
2004-08-10 11:34:12 +00:00
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'w': //display in a window
|
|
|
|
{
|
2009-02-28 21:44:24 +00:00
|
|
|
i++;
|
|
|
|
fullScreen = false;
|
|
|
|
windowParFound = true;
|
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
// Parse window position and size options
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-02-28 21:44:24 +00:00
|
|
|
windowWidth = atoi(argv[i++]);
|
|
|
|
windowHeight = atoi(argv[i++]);
|
2014-04-06 21:17:31 +00:00
|
|
|
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
2009-02-28 21:44:24 +00:00
|
|
|
{
|
|
|
|
windowLeft = atoi(argv[i++]);
|
|
|
|
windowTop = atoi(argv[i++]);
|
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: to define the window left or right coordinates, both options must be used.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: to define the window's width or height, both options must be used.\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'h': //display help
|
|
|
|
{
|
2010-09-13 08:30:56 +00:00
|
|
|
usage(argv[0], isBlenderPlayer);
|
2004-10-15 12:46:57 +00:00
|
|
|
return 0;
|
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'i': //parent window ID
|
|
|
|
{
|
2008-09-09 21:15:30 +00:00
|
|
|
i++;
|
2010-09-13 08:30:56 +00:00
|
|
|
if ( (i + 1) <= validArguments )
|
2013-02-23 23:15:38 +00:00
|
|
|
parentWindow = atoi(argv[i++]);
|
2010-09-13 08:30:56 +00:00
|
|
|
else {
|
|
|
|
error = true;
|
|
|
|
printf("error: too few options for parent window argument.\n");
|
|
|
|
}
|
2010-10-18 06:52:10 +00:00
|
|
|
#if defined(DEBUG)
|
2008-09-09 21:15:30 +00:00
|
|
|
printf("XWindows ID = %d\n", parentWindow);
|
2010-10-18 06:52:10 +00:00
|
|
|
#endif // defined(DEBUG)
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'm': //maximum anti-aliasing (eg. 2,4,8,16)
|
|
|
|
{
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
i++;
|
2012-01-11 20:53:22 +00:00
|
|
|
samplesParFound = true;
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
if ((i+1) <= validArguments )
|
2012-01-11 20:53:22 +00:00
|
|
|
aasamples = atoi(argv[i++]);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: No argument supplied for -m");
|
|
|
|
}
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'c': //keep console (windows only)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
i++;
|
2011-05-18 06:27:32 +00:00
|
|
|
#ifdef WIN32
|
2002-10-12 11:37:38 +00:00
|
|
|
closeConsole = false;
|
2011-05-18 06:27:32 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 's': //stereo mode
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
i++;
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 1) <= validArguments)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-04-06 21:17:31 +00:00
|
|
|
stereoParFound = true;
|
|
|
|
stereoFlag = STEREO_ENABLED;
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
if (!strcmp(argv[i], "nostereo")) // may not be redundant if the file has different setting
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
|
2014-04-06 21:17:31 +00:00
|
|
|
stereoFlag = STEREO_NOSTEREO;
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// only the hardware pageflip method needs a stereo window
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "hwpageflip")) {
|
2002-10-12 11:37:38 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_QUADBUFFERED;
|
|
|
|
stereoWindow = true;
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "syncdoubling"))
|
2002-10-12 11:37:38 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_ABOVEBELOW;
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2014-01-01 23:26:15 +00:00
|
|
|
else if (!strcmp(argv[i], "3dtvtopbottom"))
|
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_3DTVTOPBOTTOM;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "anaglyph"))
|
2004-08-10 11:34:12 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_ANAGLYPH;
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "sidebyside"))
|
2004-08-10 11:34:12 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
else if (!strcmp(argv[i], "interlace"))
|
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_INTERLACED;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "vinterlace"))
|
2004-10-24 11:03:18 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_VINTERLACE;
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#if 0
|
2013-02-23 23:15:38 +00:00
|
|
|
// // future stuff
|
|
|
|
// else if (!strcmp(argv[i], "stencil")
|
|
|
|
// stereomode = RAS_STEREO_STENCIL;
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
2014-04-06 21:17:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: stereomode '%s' unrecognized.\n", argv[i]);
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: too few options for stereo argument.\n");
|
|
|
|
}
|
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
case 'D': //dome mode
|
|
|
|
{
|
2010-02-24 23:01:49 +00:00
|
|
|
stereoFlag = STEREO_DOME;
|
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
|
|
|
|
i++;
|
2010-09-13 08:30:56 +00:00
|
|
|
if ((i + 1) <= validArguments)
|
2010-02-24 23:01:49 +00:00
|
|
|
{
|
2012-03-28 05:03:24 +00:00
|
|
|
if (!strcmp(argv[i], "angle")) {
|
2010-02-24 23:01:49 +00:00
|
|
|
i++;
|
|
|
|
domeFov = atoi(argv[i++]);
|
|
|
|
}
|
2012-03-28 05:03:24 +00:00
|
|
|
if (!strcmp(argv[i], "tilt")) {
|
2010-02-24 23:01:49 +00:00
|
|
|
i++;
|
|
|
|
domeTilt = atoi(argv[i++]);
|
|
|
|
}
|
2012-03-28 05:03:24 +00:00
|
|
|
if (!strcmp(argv[i], "warpdata")) {
|
2010-02-24 23:01:49 +00:00
|
|
|
i++;
|
|
|
|
domeWarp = argv[i++];
|
|
|
|
}
|
2012-03-28 05:03:24 +00:00
|
|
|
if (!strcmp(argv[i], "mode")) {
|
2010-02-24 23:01:49 +00:00
|
|
|
i++;
|
2012-03-24 07:52:14 +00:00
|
|
|
if (!strcmp(argv[i], "fisheye"))
|
2010-02-24 23:01:49 +00:00
|
|
|
domeMode = DOME_FISHEYE;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "truncatedfront"))
|
2010-02-24 23:01:49 +00:00
|
|
|
domeMode = DOME_TRUNCATED_FRONT;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "truncatedrear"))
|
2010-02-24 23:01:49 +00:00
|
|
|
domeMode = DOME_TRUNCATED_REAR;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "cubemap"))
|
2010-02-24 23:01:49 +00:00
|
|
|
domeMode = DOME_ENVMAP;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (!strcmp(argv[i], "sphericalpanoramic"))
|
2010-02-24 23:01:49 +00:00
|
|
|
domeMode = DOME_PANORAM_SPH;
|
|
|
|
|
|
|
|
else
|
|
|
|
printf("error: %s is not a valid dome mode.\n", argv[i]);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
break;
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
|
|
|
default: //not recognized
|
|
|
|
{
|
2010-02-25 06:05:56 +00:00
|
|
|
printf("Unknown argument: %s\n", argv[i++]);
|
2004-08-10 11:34:12 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-10 11:34:12 +00:00
|
|
|
i++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if ((windowWidth < kMinWindowWidth) || (windowHeight < kMinWindowHeight))
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
printf("error: window size too small.\n");
|
|
|
|
}
|
|
|
|
|
2007-08-07 16:34:45 +00:00
|
|
|
if (error )
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2010-09-13 08:30:56 +00:00
|
|
|
usage(argv[0], isBlenderPlayer);
|
2007-06-27 15:08:31 +00:00
|
|
|
return 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2007-06-27 15:08:31 +00:00
|
|
|
|
2004-12-01 08:35:38 +00:00
|
|
|
#ifdef WIN32
|
2007-06-27 15:08:31 +00:00
|
|
|
if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION)
|
2004-12-01 08:35:38 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
// Create the system
|
2013-02-23 23:15:38 +00:00
|
|
|
if (GHOST_ISystem::createSystem() == GHOST_kSuccess) {
|
2002-10-12 11:37:38 +00:00
|
|
|
GHOST_ISystem* system = GHOST_ISystem::getSystem();
|
|
|
|
assertd(system);
|
|
|
|
|
2004-08-10 11:34:12 +00:00
|
|
|
if (!fullScreenWidth || !fullScreenHeight)
|
|
|
|
system->getMainDisplayDimensions(fullScreenWidth, fullScreenHeight);
|
2002-10-12 11:37:38 +00:00
|
|
|
// process first batch of events. If the user
|
2013-02-23 23:15:38 +00:00
|
|
|
// drops a file on top off the blenderplayer icon, we
|
2010-07-20 10:41:08 +00:00
|
|
|
// receive an event with the filename
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
system->processEvents(0);
|
|
|
|
|
|
|
|
// this bracket is needed for app (see below) to get out
|
|
|
|
// of scope before GHOST_ISystem::disposeSystem() is called.
|
|
|
|
{
|
|
|
|
int exitcode = KX_EXIT_REQUEST_NO_REQUEST;
|
|
|
|
STR_String exitstring = "";
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPG_Application app(system);
|
2002-10-12 11:37:38 +00:00
|
|
|
bool firstTimeRunning = true;
|
2011-11-26 04:07:38 +00:00
|
|
|
char filename[FILE_MAX];
|
|
|
|
char pathname[FILE_MAX];
|
2008-05-11 18:45:30 +00:00
|
|
|
char *titlename;
|
2008-09-12 16:06:17 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
get_filename(argc_py_clamped, argv, filename);
|
2012-03-24 07:52:14 +00:00
|
|
|
if (filename[0])
|
2010-03-09 17:36:23 +00:00
|
|
|
BLI_path_cwd(filename);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-09-11 05:54:07 +00:00
|
|
|
|
|
|
|
// fill the GlobalSettings with the first scene files
|
|
|
|
// those may change during the game and persist after using Game Actuator
|
|
|
|
GlobalSettings gs;
|
|
|
|
|
2013-02-23 23:15:38 +00:00
|
|
|
do {
|
2002-10-12 11:37:38 +00:00
|
|
|
// Read the Blender file
|
|
|
|
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)
|
|
|
|
{
|
2012-01-16 06:43:58 +00:00
|
|
|
char basedpath[FILE_MAX];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-10-11 00:56:49 +00:00
|
|
|
// base the actuator filename relative to the last file
|
2011-10-19 23:10:54 +00:00
|
|
|
BLI_strncpy(basedpath, exitstring.Ptr(), sizeof(basedpath));
|
2010-03-09 17:36:23 +00:00
|
|
|
BLI_path_abs(basedpath, pathname);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-29 10:51:02 +00:00
|
|
|
bfd = load_game_data(basedpath);
|
2008-05-11 18:45:30 +00:00
|
|
|
|
2013-02-23 23:15:38 +00:00
|
|
|
if (!bfd) {
|
2008-05-11 18:45:30 +00:00
|
|
|
// just add "//" in front of it
|
2013-07-23 12:49:30 +00:00
|
|
|
char temppath[FILE_MAX] = "//";
|
|
|
|
BLI_strncpy(temppath + 2, basedpath, FILE_MAX - 2);
|
2013-02-23 23:15:38 +00:00
|
|
|
|
2010-03-09 17:36:23 +00:00
|
|
|
BLI_path_abs(temppath, pathname);
|
2008-05-11 18:45:30 +00:00
|
|
|
bfd = load_game_data(temppath);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
else {
|
2011-10-21 17:37:38 +00:00
|
|
|
bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2014-04-06 21:17:31 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
printf("Game data loaded from %s\n", filename);
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!bfd) {
|
2010-09-13 08:30:56 +00:00
|
|
|
usage(argv[0], isBlenderPlayer);
|
2002-10-12 11:37:38 +00:00
|
|
|
error = true;
|
|
|
|
exitcode = KX_EXIT_REQUEST_QUIT_GAME;
|
2013-02-23 23:15:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-04-06 21:17:31 +00:00
|
|
|
/* Setting options according to the blend file if not overriden in the command line */
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef WIN32
|
2010-10-18 06:52:10 +00:00
|
|
|
#if !defined(DEBUG)
|
2013-02-23 23:15:38 +00:00
|
|
|
if (closeConsole) {
|
2012-03-29 01:40:19 +00:00
|
|
|
system->toggleConsole(0); // Close a console window
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-10-18 06:52:10 +00:00
|
|
|
#endif // !defined(DEBUG)
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif // WIN32
|
|
|
|
Main *maggie = bfd->main;
|
|
|
|
Scene *scene = bfd->curscene;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
G.main = maggie;
|
2008-10-04 16:42:36 +00:00
|
|
|
|
2011-09-11 05:54:07 +00:00
|
|
|
if (firstTimeRunning) {
|
2008-10-04 16:42:36 +00:00
|
|
|
G.fileflags = bfd->fileflags;
|
2006-02-13 03:37:00 +00:00
|
|
|
|
2011-09-11 05:54:07 +00:00
|
|
|
gs.matmode= scene->gm.matmode;
|
|
|
|
gs.glslflag= scene->gm.flag;
|
|
|
|
}
|
|
|
|
|
2007-01-08 04:22:23 +00:00
|
|
|
//Seg Fault; icon.c gIcons == 0
|
|
|
|
BKE_icons_init(1);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
titlename = maggie->name;
|
|
|
|
|
|
|
|
// Check whether the game should be displayed full-screen
|
2013-02-23 23:15:38 +00:00
|
|
|
if ((!fullScreenParFound) && (!windowParFound)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
// Only use file settings when command line did not override
|
2012-01-11 20:53:22 +00:00
|
|
|
if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
//printf("fullscreen option found in Blender file\n");
|
|
|
|
fullScreen = true;
|
2009-11-28 01:26:14 +00:00
|
|
|
fullScreenWidth= scene->gm.xplay;
|
|
|
|
fullScreenHeight= scene->gm.yplay;
|
|
|
|
fullScreenFrequency= scene->gm.freqplay;
|
|
|
|
fullScreenBpp = scene->gm.depth;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fullScreen = false;
|
2009-11-28 01:26:14 +00:00
|
|
|
windowWidth = scene->gm.xplay;
|
|
|
|
windowHeight = scene->gm.yplay;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
// Check whether the game should be displayed in stereo (dome included)
|
2013-02-23 23:15:38 +00:00
|
|
|
if (!stereoParFound) {
|
2014-04-06 21:17:31 +00:00
|
|
|
// Only use file settings when command line did not override
|
2012-03-28 05:03:24 +00:00
|
|
|
if (scene->gm.stereoflag == STEREO_ENABLED) {
|
2009-11-28 01:26:14 +00:00
|
|
|
stereomode = (RAS_IRasterizer::StereoMode) scene->gm.stereomode;
|
2012-05-09 11:11:35 +00:00
|
|
|
if (stereomode == RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
|
2009-11-28 01:26:14 +00:00
|
|
|
stereoWindow = true;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
else {
|
2010-02-24 23:01:49 +00:00
|
|
|
scene->gm.stereoflag = STEREO_ENABLED;
|
2013-02-23 23:15:38 +00:00
|
|
|
}
|
2010-02-24 23:01:49 +00:00
|
|
|
|
2012-01-11 20:53:22 +00:00
|
|
|
if (!samplesParFound)
|
|
|
|
aasamples = scene->gm.aasamples;
|
|
|
|
|
2014-04-06 21:17:31 +00:00
|
|
|
// Dome specific settings
|
2012-03-28 05:03:24 +00:00
|
|
|
if (stereoFlag == STEREO_DOME) {
|
2010-02-24 23:01:49 +00:00
|
|
|
stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
|
|
|
|
scene->gm.stereoflag = STEREO_DOME;
|
|
|
|
if (domeFov > 89)
|
|
|
|
scene->gm.dome.angle = domeFov;
|
|
|
|
if (domeTilt > -180)
|
|
|
|
scene->gm.dome.tilt = domeTilt;
|
|
|
|
if (domeMode > 0)
|
|
|
|
scene->gm.dome.mode = domeMode;
|
2013-02-23 23:15:38 +00:00
|
|
|
if (domeWarp) {
|
2010-02-25 06:05:56 +00:00
|
|
|
//XXX to do: convert relative to absolute path
|
2013-02-05 13:31:59 +00:00
|
|
|
domeText= BKE_text_load(G.main, domeWarp, "");
|
2012-03-24 07:52:14 +00:00
|
|
|
if (!domeText)
|
2010-02-25 06:05:56 +00:00
|
|
|
printf("error: invalid warpdata text file - %s\n", domeWarp);
|
|
|
|
else
|
|
|
|
scene->gm.dome.warptext = domeText;
|
2010-02-24 23:01:49 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// GPG_Application app (system, maggie, startscenename);
|
2011-09-11 05:54:07 +00:00
|
|
|
app.SetGameEngineData(maggie, scene, &gs, argc, argv); /* this argc cant be argc_py_clamped, since python uses it */
|
2008-10-11 00:56:49 +00:00
|
|
|
BLI_strncpy(pathname, maggie->name, sizeof(pathname));
|
2012-03-24 07:52:14 +00:00
|
|
|
if (G.main != maggie) {
|
2011-03-26 04:50:59 +00:00
|
|
|
BLI_strncpy(G.main->name, maggie->name, sizeof(G.main->name));
|
|
|
|
}
|
2010-11-05 01:47:55 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2010-10-18 06:41:16 +00:00
|
|
|
setGamePythonPath(G.main->name);
|
2010-11-05 01:47:55 +00:00
|
|
|
#endif
|
2013-02-23 23:15:38 +00:00
|
|
|
if (firstTimeRunning) {
|
2002-10-12 11:37:38 +00:00
|
|
|
firstTimeRunning = false;
|
2008-05-11 18:45:30 +00:00
|
|
|
|
2013-02-23 23:15:38 +00:00
|
|
|
if (fullScreen) {
|
2004-12-01 08:35:38 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER)
|
|
|
|
{
|
|
|
|
app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
|
2013-02-23 23:15:38 +00:00
|
|
|
stereoWindow, stereomode, aasamples);
|
2004-12-01 08:35:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
|
2013-02-23 23:15:38 +00:00
|
|
|
stereoWindow, stereomode, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION));
|
2004-12-01 08:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// on Mac's we'll show the executable name instead of the 'game.blend' name
|
|
|
|
char tempname[1024], *appstring;
|
|
|
|
::strcpy(tempname, titlename);
|
|
|
|
|
|
|
|
appstring = strstr(tempname, ".app/");
|
|
|
|
if (appstring) {
|
|
|
|
appstring[2] = 0;
|
|
|
|
titlename = &tempname[0];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Strip the path so that we have the name of the game file
|
|
|
|
STR_String path = titlename;
|
|
|
|
#ifndef WIN32
|
|
|
|
vector<STR_String> parts = path.Explode('/');
|
|
|
|
#else // WIN32
|
|
|
|
vector<STR_String> parts = path.Explode('\\');
|
|
|
|
#endif // WIN32
|
|
|
|
STR_String title;
|
2013-02-23 23:15:38 +00:00
|
|
|
if (parts.size()) {
|
2002-10-12 11:37:38 +00:00
|
|
|
title = parts[parts.size()-1];
|
|
|
|
parts = title.Explode('.');
|
|
|
|
if (parts.size() > 1)
|
|
|
|
{
|
|
|
|
title = parts[0];
|
|
|
|
}
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
else {
|
2002-10-12 11:37:38 +00:00
|
|
|
title = "blenderplayer";
|
|
|
|
}
|
2004-12-01 08:35:38 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
if (scr_saver_mode == SCREEN_SAVER_MODE_PREVIEW)
|
|
|
|
{
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode, aasamples);
|
2004-12-01 08:35:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2013-02-23 23:15:38 +00:00
|
|
|
if (parentWindow != 0)
|
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
2011-05-04 01:50:17 +00:00
|
|
|
app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aasamples);
|
2008-09-09 21:15:30 +00:00
|
|
|
else
|
|
|
|
app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
|
2013-02-23 23:15:38 +00:00
|
|
|
stereoWindow, stereomode, aasamples);
|
2014-10-07 20:46:19 +00:00
|
|
|
|
|
|
|
if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
|
|
|
|
GPU_set_mipmap(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_set_anisotropic(U.anisotropic_filter);
|
|
|
|
GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
|
2004-12-01 08:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
else {
|
2002-10-12 11:37:38 +00:00
|
|
|
app.StartGameEngine(stereomode);
|
|
|
|
exitcode = KX_EXIT_REQUEST_NO_REQUEST;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the application as event consumer
|
|
|
|
system->addEventConsumer(&app);
|
|
|
|
|
|
|
|
// Enter main loop
|
|
|
|
bool run = true;
|
2012-12-20 00:29:31 +00:00
|
|
|
char *python_main = NULL;
|
2012-09-01 21:23:05 +00:00
|
|
|
pynextframestate.state = NULL;
|
|
|
|
pynextframestate.func = NULL;
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
python_main = KX_GetPythonMain(scene);
|
|
|
|
#endif // WITH_PYTHON
|
2013-02-23 23:15:38 +00:00
|
|
|
if (python_main) {
|
2012-09-01 21:23:05 +00:00
|
|
|
char *python_code = KX_GetPythonCode(maggie, python_main);
|
2013-02-23 23:15:38 +00:00
|
|
|
if (python_code) {
|
2012-12-20 00:29:31 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2012-09-01 21:23:05 +00:00
|
|
|
gpg_nextframestate.system = system;
|
|
|
|
gpg_nextframestate.app = &app;
|
|
|
|
gpg_nextframestate.gs = &gs;
|
|
|
|
pynextframestate.state = &gpg_nextframestate;
|
2012-09-16 04:58:18 +00:00
|
|
|
pynextframestate.func = &GPG_PyNextFrame;
|
2012-09-01 21:23:05 +00:00
|
|
|
|
2012-12-20 00:29:31 +00:00
|
|
|
printf("Yielding control to Python script '%s'...\n", python_main);
|
|
|
|
PyRun_SimpleString(python_code);
|
|
|
|
printf("Exit Python script '%s'\n", python_main);
|
2012-09-16 04:58:18 +00:00
|
|
|
#endif // WITH_PYTHON
|
2012-12-20 00:29:31 +00:00
|
|
|
MEM_freeN(python_code);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "ERROR: cannot yield control to Python: no Python text data block named '%s'\n", python_main);
|
|
|
|
}
|
|
|
|
}
|
2013-02-23 23:15:38 +00:00
|
|
|
else {
|
|
|
|
while (run) {
|
2012-09-01 21:23:05 +00:00
|
|
|
run = GPG_NextFrame(system, &app, exitcode, exitstring, &gs);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
app.StopGameEngine();
|
2008-09-16 19:25:35 +00:00
|
|
|
|
2013-02-23 23:15:38 +00:00
|
|
|
/* 'app' is freed automatic when out of scope.
|
2011-03-26 08:13:42 +00:00
|
|
|
* removal is needed else the system will free an already freed value */
|
|
|
|
system->removeEventConsumer(&app);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLO_blendfiledata_free(bfd);
|
2013-07-20 03:01:50 +00:00
|
|
|
/* G.main == bfd->main, it gets referenced in free_nodesystem so we can't have a dangling pointer */
|
|
|
|
G.main = NULL;
|
2012-09-01 21:23:05 +00:00
|
|
|
if (python_main) MEM_freeN(python_main);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
} while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME);
|
|
|
|
}
|
2007-01-08 04:22:23 +00:00
|
|
|
|
|
|
|
// Seg Fault; icon.c gIcons == 0
|
|
|
|
BKE_icons_free();
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Dispose the system
|
|
|
|
GHOST_ISystem::disposeSystem();
|
2013-02-23 23:15:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-10-12 11:37:38 +00:00
|
|
|
error = true;
|
|
|
|
printf("error: couldn't create a system.\n");
|
|
|
|
}
|
|
|
|
}
|
2007-06-27 15:08:31 +00:00
|
|
|
|
2013-07-20 03:01:50 +00:00
|
|
|
/* refer to WM_exit_ext() and free_blender(),
|
|
|
|
* these are not called in the player but we need to match some of there behavior here,
|
|
|
|
* if the order of function calls or blenders state isn't matching that of blender proper,
|
|
|
|
* we may get troubles later on */
|
|
|
|
|
|
|
|
free_nodesystem();
|
|
|
|
|
2010-12-21 06:58:44 +00:00
|
|
|
// Cleanup
|
|
|
|
RNA_exit();
|
|
|
|
BLF_exit();
|
2011-09-20 14:07:40 +00:00
|
|
|
|
2011-09-26 10:35:47 +00:00
|
|
|
#ifdef WITH_INTERNATIONAL
|
2011-09-20 07:39:25 +00:00
|
|
|
BLF_free_unifont();
|
2013-03-12 07:25:53 +00:00
|
|
|
BLF_free_unifont_mono();
|
2012-10-22 14:04:40 +00:00
|
|
|
BLF_lang_free();
|
2011-09-20 14:07:40 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-31 10:56:06 +00:00
|
|
|
IMB_exit();
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_images_exit();
|
2013-12-26 11:24:42 +00:00
|
|
|
DAG_exit();
|
2014-01-29 21:39:44 +00:00
|
|
|
IMB_moviecache_destruct();
|
2010-12-21 06:58:44 +00:00
|
|
|
|
|
|
|
SYS_DeleteSystem(syshandle);
|
2008-09-14 03:51:51 +00:00
|
|
|
|
2011-03-26 04:50:59 +00:00
|
|
|
int totblock= MEM_get_memory_blocks_in_use();
|
2012-03-24 07:52:14 +00:00
|
|
|
if (totblock!=0) {
|
2011-03-26 04:50:59 +00:00
|
|
|
printf("Error Totblock: %d\n",totblock);
|
|
|
|
MEM_set_error_callback(mem_error_cb);
|
|
|
|
MEM_printmemlist();
|
|
|
|
}
|
|
|
|
|
T39690: Modifications to Blender's 'temp dir' system.
Current temporary data of Blender suffers one major issue - default 'temp' dir on Windows is never
automatically cleaned up, and can end being quite big when used by Blender, especially when we have
to store per-process data (using getpid() in file names).
To address this, this patch:
* Divides tempdir paths in two, one for 'base' temp dir (the same as previous unique tempdir path),
the other is a mkdtemp-generated sub-dir, specific to each Blender instance.
* Only uses base tempdir when we need some shallow persistance accross Blender sessions - and we always
reuse the same filename (quit.blend...) or generate small file (crash reports...).
* Uses temp sub-dir for heavy files like pointcache or renderEXRs (Save Buffer option).
* Erases temp sub-dir on quit or crash.
To get this working it also adds a working 'recursive delete' to BLI_delete() under Windows.
Note that, as in current code, the 'recover render result' hack-feature that was possible
with SaveBuffer option is still removed. A real renderresult cache feature will be added
soon, though.
Reviewers: campbellbarton, brecht, sergey
Reviewed By: campbellbarton, sergey
CC: sergey
Differential Revision: https://developer.blender.org/D531
2014-06-23 11:42:19 +00:00
|
|
|
BLI_temp_dir_session_purge();
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return error ? -1 : 0;
|
|
|
|
}
|