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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
commitbdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch)
treed00eb50b749cb001e2b08272c91791e66740b05d /source/gameengine/GamePlayer
parent78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff)
parent7e4db234cee71ead34ee81a12e27da4bd548eb4b (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')
-rw-r--r--source/gameengine/GamePlayer/CMakeLists.txt4
-rw-r--r--source/gameengine/GamePlayer/Makefile2
-rw-r--r--source/gameengine/GamePlayer/SConscript2
-rw-r--r--source/gameengine/GamePlayer/common/CMakeLists.txt3
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h24
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp30
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RawImage.cpp2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RawImage.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp538
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h179
-rw-r--r--source/gameengine/GamePlayer/common/Makefile3
-rw-r--r--source/gameengine/GamePlayer/common/SConscript96
-rw-r--r--source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h4
-rw-r--r--source/gameengine/GamePlayer/common/windows/GPW_Canvas.h2
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp159
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.h18
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp157
-rw-r--r--source/gameengine/GamePlayer/ghost/Makefile6
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript74
22 files changed, 648 insertions, 663 deletions
diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt
index ff1040bfb40..fc5912155cf 100644
--- a/source/gameengine/GamePlayer/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/CMakeLists.txt
@@ -25,3 +25,7 @@
# ***** END GPL LICENSE BLOCK *****
SUBDIRS(common ghost)
+
+IF(WITH_WEBPLUGIN)
+ SUBDIRS(xembed)
+ENDIF(WITH_WEBPLUGIN)
diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile
index 747a82fc333..c4f78f23117 100644
--- a/source/gameengine/GamePlayer/Makefile
+++ b/source/gameengine/GamePlayer/Makefile
@@ -34,7 +34,7 @@ SOURCEDIR = source/gameengine/GamePlayer
DIR = $(OCGDIR)/gameengine/GamePlayer
DIRS = common ghost
-ifneq ($(NAN_NO_PLUGIN),true)
+ifeq ($(WITH_BF_WEBPLUGIN),true)
ifeq ($(OS),$(findstring $(OS), "freebsd irix windows"))
ifneq ($(FREE_WINDOWS),true)
DIRS += netscape
diff --git a/source/gameengine/GamePlayer/SConscript b/source/gameengine/GamePlayer/SConscript
index df6d26e5d16..0b140bba8e7 100644
--- a/source/gameengine/GamePlayer/SConscript
+++ b/source/gameengine/GamePlayer/SConscript
@@ -1,3 +1,3 @@
#!/usr/bin/python
SConscript(['common/SConscript',
- 'ghost/SConscript'])
+ 'ghost/SConscript'])
diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt
index 29cdcd640f5..0c6c4179e2d 100644
--- a/source/gameengine/GamePlayer/common/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/common/CMakeLists.txt
@@ -30,7 +30,6 @@ SET(SRC
GPC_Engine.cpp
GPC_KeyboardDevice.cpp
GPC_MouseDevice.cpp
- GPC_PolygonMaterial.cpp
GPC_RawImage.cpp
GPC_RawLoadDotBlendArray.cpp
GPC_RawLogoArrays.cpp
@@ -69,6 +68,8 @@ SET(INC
../../../../source/gameengine/GamePlayer/ghost
../../../../source/blender/misc
../../../../source/blender/blenloader
+ ../../../../source/blender/gpu
+ ../../../../extern/glew/include
${PYTHON_INC}
${SOLID_INC}
${PNG_INC}
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index bd66c865988..87719041f65 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -33,18 +33,12 @@
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
-#if defined(WIN32) || defined(__APPLE__)
- #ifdef WIN32
- #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
- #include <windows.h>
- #include <GL/gl.h>
- #else // WIN32
- // __APPLE__ is defined
- #include <AGL/gl.h>
- #endif // WIN32
-#else //defined(WIN32) || defined(__APPLE__)
- #include <GL/gl.h>
-#endif //defined(WIN32) || defined(__APPLE__)
+#ifdef WIN32
+ #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
+ #include <windows.h>
+#endif // WIN32
+
+#include "GL/glew.h"
#include <map>
@@ -136,6 +130,12 @@ public:
) {
return m_displayarea;
};
+
+ RAS_Rect &
+ GetWindowArea(
+ ) {
+ return m_displayarea;
+ }
void
BeginFrame(
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
index c5064c86b5a..474df9276a7 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
@@ -29,6 +29,8 @@
#include "GPC_KeyboardDevice.h"
+#include <cstdlib>
+
/**
* NextFrame toggles currentTable with previousTable,
* and copies relevant event information from previous to current table
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
index aa2bfefb603..891589dd118 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
@@ -55,9 +55,9 @@ protected:
* System dependent keyboard codes are stored as ints.
*/
std::map<int, KX_EnumInputs> m_reverseKeyTranslateTable;
- bool m_hookesc;
public:
+ bool m_hookesc;
GPC_KeyboardDevice()
: m_hookesc(false)
{
diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
index 46fe24d8b87..b1e2b5af0e6 100644
--- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
@@ -31,23 +31,7 @@
#include <config.h>
#endif
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#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 "GPC_PolygonMaterial.h"
#include "MT_Vector3.h"
@@ -88,7 +72,6 @@ static int fDoMipMap = 1;
static int fLinearMipMap=1;
static int fAlphamode= -1;
-using namespace bgl;
/* (n&(n-1)) zeros the least significant bit of n */
static int is_pow2(int num) {
return ((num)&(num-1))==0;
@@ -154,16 +137,23 @@ int set_tpage(MTFace *tface)
fAlphamode= tface->transp;
if(fAlphamode) {
- glEnable(GL_BLEND);
-
if(fAlphamode==TF_ADD) {
+ glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
+ glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
else if(fAlphamode==TF_ALPHA) {
+ glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
+ else if (fAlphamode==TF_CLIP){
+ glDisable(GL_BLEND);
+ glEnable ( GL_ALPHA_TEST );
+ glAlphaFunc(GL_GREATER, 0.5f);
+ }
/* else { */
/* glBlendFunc(GL_ONE, GL_ONE); */
/* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */
diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
index a9cfb0a9366..e6e97cbdfd3 100644
--- a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
@@ -45,7 +45,7 @@ GPC_RawImage::GPC_RawImage()
bool GPC_RawImage::Load(
- char *srcName,
+ const char *srcName,
int destWidth, int destHeight,
TImageAlignment alignment, int offsetX, int offsetY)
{
diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.h b/source/gameengine/GamePlayer/common/GPC_RawImage.h
index 17c00d2fcc3..49a3043bffc 100644
--- a/source/gameengine/GamePlayer/common/GPC_RawImage.h
+++ b/source/gameengine/GamePlayer/common/GPC_RawImage.h
@@ -61,7 +61,7 @@ public:
* @param offsetX Amount of horzontal offset applied to the resource image.
* @param offsetY Amount of vertical offset applied to the resource image.
*/
- virtual bool Load(char *srcName,
+ virtual bool Load(const char *srcName,
int destWidth, int destHeight,
TImageAlignment alignment = alignTopLeft,
int offsetX = 0, int offsetY = 0);
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index 5912a8a10fc..78d8eaf2aa3 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -27,22 +27,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include <assert.h>
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#include <windows.h>
-#endif
-
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
-#include <iostream>
-
-#include "GPC_RenderTools.h"
+#include "GL/glew.h"
#include "RAS_IRenderTools.h"
#include "RAS_IRasterizer.h"
@@ -50,122 +35,248 @@
#include "RAS_ICanvas.h"
#include "RAS_GLExtensionManager.h"
-// next two includes/dependencies come from the shadow feature
-// it needs the gameobject and the sumo physics scene for a raycast
#include "KX_GameObject.h"
-
-#include "GPC_PolygonMaterial.h"
#include "KX_PolygonMaterial.h"
-#include "Value.h"
+#include "KX_BlenderMaterial.h"
+#include "KX_RayCast.h"
+#include "KX_IPhysicsController.h"
+
+#include "PHY_IPhysicsEnvironment.h"
-//#include "KX_BlenderGL.h" // for text printing
-//#include "KX_BlenderClientObject.h"
#include "STR_String.h"
-#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting)
-
-
-// Blender includes
-/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
-
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_bmfont.h"
+
+#include "GPU_draw.h"
+
+#include "BKE_bmfont.h" // for text printing
#include "BKE_bmfont_types.h"
-#include "BKE_main.h"
-#include "IMB_imbuf_types.h"
-// End of Blender includes
+#include "GPC_RenderTools.h"
-#include "KX_Scene.h"
-#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "KX_BlenderMaterial.h"
+unsigned int GPC_RenderTools::m_numgllights;
GPC_RenderTools::GPC_RenderTools()
{
m_font = BMF_GetFont(BMF_kHelvetica10);
+
glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights);
if (m_numgllights < 8)
m_numgllights = 8;
}
-
GPC_RenderTools::~GPC_RenderTools()
{
}
+void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
+{
+ m_clientobject = NULL;
+ m_lastlightlayer = -1;
+ m_lastlighting = false;
+ DisableOpenGLLights();
+}
void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty)
{
}
+/* ProcessLighting performs lighting on objects. the layer is a bitfield that
+ * contains layer information. There are 20 'official' layers in blender. A
+ * light is applied on an object only when they are in the same layer. OpenGL
+ * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
+ * a scene. */
-void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
+void GPC_RenderTools::ProcessLighting(int layer, const MT_Transform& viewmat)
{
- m_clientobject=NULL;
- m_modified=true;
- DisableOpenGLLights();
+ if(m_lastlightlayer == layer)
+ return;
-}
+ m_lastlightlayer = layer;
-int GPC_RenderTools::ProcessLighting(int layer)
-{
- int result = false;
+ bool enable = false;
- if (layer < 0)
- {
- DisableOpenGLLights();
- result = false;
- } else
+ if (layer >= 0)
{
if (m_clientobject)
- {
- if (applyLights(layer))
- {
- EnableOpenGLLights();
- result = true;
- } else
- {
- DisableOpenGLLights();
- result = false;
- }
+ {
+ if (layer == RAS_LIGHT_OBJECT_LAYER)
+ layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
+
+ enable = applyLights(layer, viewmat);
}
}
- return result;
+
+ if(enable)
+ EnableOpenGLLights();
+ else
+ DisableOpenGLLights();
}
void GPC_RenderTools::EnableOpenGLLights()
{
+ if(m_lastlighting == true)
+ return;
+
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
- glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
- if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2))
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
+ if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ m_lastlighting = true;
+}
+
+void GPC_RenderTools::DisableOpenGLLights()
+{
+ if(m_lastlighting == false)
+ return;
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
+ m_lastlighting = false;
+}
+
+
+void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
+ rasty->SetFrontFace(ccw);
+
+ m_clientobject = obj;
+ }
+}
+
+bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
+{
+ double* const oglmatrix = (double* const) data;
+ MT_Point3 resultpoint(result->m_hitPoint);
+ MT_Vector3 resultnormal(result->m_hitNormal);
+ MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
+ MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
+ left = (dir.cross(resultnormal)).safe_normalized();
+ // for the up vector, we take the 'resultnormal' returned by the physics
+
+ double maat[16]={
+ left[0], left[1], left[2], 0,
+ dir[0], dir[1], dir[2], 0,
+ resultnormal[0],resultnormal[1],resultnormal[2], 0,
+ 0, 0, 0, 1};
+ glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
+ //glMultMatrixd(oglmatrix);
+ glMultMatrixd(maat);
+ return true;
+}
+
+void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
+{
+ /* FIXME:
+ blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
+ MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
+
+ Program received signal SIGABRT, Aborted.
+ [Switching to Thread 16384 (LWP 1519)]
+ 0x40477571 in kill () from /lib/libc.so.6
+ (gdb) bt
+ #7 0x08334368 in MT_Vector3::normalized() const ()
+ #8 0x0833e6ec in GPC_RenderTools::applyTransform(RAS_IRasterizer*, double*, int) ()
+ */
+
+ if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
+ objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
+ {
+ // rotate the billboard/halo
+ //page 360/361 3D Game Engine Design, David Eberly for a discussion
+ // on screen aligned and axis aligned billboards
+ // assumed is that the preprocessor transformed all billboard polygons
+ // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0)
+ // when new parenting for objects is done, this rotation
+ // will be moved into the object
+
+ MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ MT_Point3 campos = rasty->GetCameraPosition();
+ MT_Vector3 dir = (campos - objpos).safe_normalized();
+ MT_Vector3 up(0,0,1.0);
+
+ KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
+ // get scaling of halo object
+ MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
+
+ bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
+ if (screenaligned)
+ {
+ up = (up - up.dot(dir) * dir).safe_normalized();
+ } else
+ {
+ dir = (dir - up.dot(dir)*up).safe_normalized();
+ }
+
+ MT_Vector3 left = dir.normalized();
+ dir = (left.cross(up)).normalized();
+
+ // we have calculated the row vectors, now we keep
+ // local scaling into account:
+
+ left *= size[0];
+ dir *= size[1];
+ up *= size[2];
+ double maat[16]={
+ left[0], left[1],left[2], 0,
+ dir[0], dir[1],dir[2],0,
+ up[0],up[1],up[2],0,
+ 0,0,0,1};
+ glTranslated(objpos[0],objpos[1],objpos[2]);
+ glMultMatrixd(maat);
+
+ } else
+ {
+ if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
+ {
+ // shadow must be cast to the ground, physics system needed here!
+ MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
+ MT_Vector3 direction = MT_Vector3(0,0,-1);
+
+ direction.normalize();
+ direction *= 100000;
+
+ MT_Point3 topoint = frompoint + direction;
+
+ KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
+ PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
+ KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
+
+ KX_GameObject *parent = gameobj->GetParent();
+ if (!physics_controller && parent)
+ physics_controller = parent->GetPhysicsController();
+ if (parent)
+ parent->Release();
+
+ KX_RayCast::Callback<GPC_RenderTools> callback(this, physics_controller, oglmatrix);
+ if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
+ {
+ // couldn't find something to cast the shadow on...
+ glMultMatrixd(oglmatrix);
+ }
+ } else
+ {
+
+ // 'normal' object
+ glMultMatrixd(oglmatrix);
+ }
+ }
}
-void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
+
+void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height)
{
STR_String tmpstr(text);
int lines;
@@ -238,21 +349,19 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
glDisable(GL_LIGHTING);
}
-/**
- * Copied from KX_BlenderRenderTools.cpp in KX_blenderhook
- * Renders text into a (series of) polygon(s), using a texture font,
- * Each character consists of one polygon (one quad or two triangles)
- */
+/* Render Text renders text into a (series of) polygon, using a texture font,
+ * Each character consists of one polygon (one quad or two triangles) */
+
void GPC_RenderTools::RenderText(
int mode,
RAS_IPolyMaterial* polymat,
- float v1[3], float v2[3], float v3[3], float v4[3])
+ float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
{
STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
const unsigned int flag = polymat->GetFlag();
struct MTFace* tface = 0;
- unsigned int* col = 0;
+ unsigned int *col = 0;
if(flag & RAS_BLENDERMAT) {
KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
@@ -263,110 +372,29 @@ void GPC_RenderTools::RenderText(
tface = blenderpoly->GetMTFace();
col = blenderpoly->GetMCol();
}
-
- BL_RenderText(mode, mytext, mytext.Length(), tface, col, v1, v2, v3, v4);
+
+ GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
}
-
-/**
- * Copied from KX_BlenderGL.cpp in KX_blenderhook
- */
-void GPC_RenderTools::BL_RenderText(
- int mode,
- const char* textstr,
- int textlen,
- struct MTFace* tface,
- unsigned int* col,
- float v1[3],float v2[3],float v3[3],float v4[3])
+void GPC_RenderTools::PushMatrix()
{
- struct Image* ima;
-
- if (mode & TF_BMFONT) {
- //char string[MAX_PROPSTRING];
-// float tmat[4][4];
- int characters, index, character;
- float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
-
-// bProperty *prop;
-
- // string = "Frank van Beek";
-
- characters = textlen;
-
- ima = (struct Image*) tface->tpage;
- if (ima == NULL) {
- characters = 0;
- }
-
- if(!col) glColor3f(1.0f, 1.0f, 1.0f);
-
- glPushMatrix();
- for (index = 0; index < characters; index++) {
- // lets calculate offset stuff
- character = textstr[index];
-
- // space starts at offset 1
- // character = character - ' ' + 1;
-
- matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
-
- glBegin(GL_POLYGON);
- // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], );
- // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
- glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
-
- if(col) BL_spack(col[0]);
- // glVertex3fv(v1);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
-
- glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
- if(col) BL_spack(col[1]);
- // glVertex3fv(v2);
- glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
-
- glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
- if(col) BL_spack(col[2]);
- // glVertex3fv(v3);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
-
- if(v4) {
- // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy);
- glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
- if(col) BL_spack(col[3]);
- // glVertex3fv(v4);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
- }
- glEnd();
-
- glTranslatef(advance, 0.0, 0.0);
- }
- glPopMatrix();
-
- }
+ glPushMatrix();
}
-
-RAS_IPolyMaterial* GPC_RenderTools::CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant, bool zsort,
- int lightlayer,bool bIsTriangle,void* clientobject,void* tface)
+void GPC_RenderTools::PopMatrix()
{
- assert(!"Deprecated");
-/* return new GPC_PolygonMaterial(texname, ba,matname,tile,tilexrep,tileyrep,
- mode,transparant,zsort,lightlayer,bIsTriangle,clientobject,tface);
- */
- return NULL;
+ glPopMatrix();
}
-int GPC_RenderTools::applyLights(int objectlayer)
+int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat)
{
-// taken from blender source, incompatibility between Blender Object / GameObject
-
- int count;
+ // taken from blender source, incompatibility between Blender Object / GameObject
+ float glviewmat[16];
+ unsigned int count;
float vec[4];
-
+
vec[3]= 1.0;
for(count=0; count<m_numgllights; count++)
@@ -375,23 +403,20 @@ int GPC_RenderTools::applyLights(int objectlayer)
//std::vector<struct RAS_LightObject*> m_lights;
std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
+ viewmat.getValue(glviewmat);
+ glPushMatrix();
+ glLoadMatrixf(glviewmat);
for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
{
RAS_LightObject* lightdata = (*lit);
if (lightdata->m_layer & objectlayer)
{
-
- glPushMatrix();
- glLoadMatrixf(m_viewmat);
-
-
vec[0] = (*(lightdata->m_worldmatrix))(0,3);
vec[1] = (*(lightdata->m_worldmatrix))(1,3);
vec[2] = (*(lightdata->m_worldmatrix))(2,3);
vec[3] = 1;
-
if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) {
vec[0] = (*(lightdata->m_worldmatrix))(0,2);
@@ -447,126 +472,16 @@ int GPC_RenderTools::applyLights(int objectlayer)
}
glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec);
glEnable((GLenum)(GL_LIGHT0+count));
-
- count++;
- glPopMatrix();
+ count++;
}
}
+ glPopMatrix();
return count;
}
-bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
-{
- double* const oglmatrix = (double* const) data;
- MT_Point3 resultpoint(hit_point);
- MT_Vector3 resultnormal(hit_normal);
- MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
- MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
- left = (dir.cross(resultnormal)).safe_normalized();
- // for the up vector, we take the 'resultnormal' returned by the physics
-
- double maat[16]={
- left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- resultnormal[0],resultnormal[1],resultnormal[2], 0,
- 0, 0, 0, 1};
- glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
- return true;
-}
-
-void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
-{
- if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
- objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
- {
- // rotate the billboard/halo
- //page 360/361 3D Game Engine Design, David Eberly for a discussion
- // on screen aligned and axis aligned billboards
- // assumed is that the preprocessor transformed all billboard polygons
- // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0)
- // when new parenting for objects is done, this rotation
- // will be moved into the object
-
- MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- MT_Point3 campos = rasty->GetCameraPosition();
- MT_Vector3 dir = (campos - objpos).safe_normalized();
- MT_Vector3 up(0,0,1.0);
-
- KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
- // get scaling of halo object
- MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
-
- bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
- if (screenaligned)
- {
- up = (up - up.dot(dir) * dir).safe_normalized();
- } else
- {
- dir = (dir - up.dot(dir)*up).safe_normalized();
- }
-
- MT_Vector3 left = dir.normalized();
- dir = (left.cross(up)).normalized();
-
- // we have calculated the row vectors, now we keep
- // local scaling into account:
-
- left *= size[0];
- dir *= size[1];
- up *= size[2];
- double maat[16]={
- left[0], left[1],left[2], 0,
- dir[0], dir[1],dir[2],0,
- up[0],up[1],up[2],0,
- 0,0,0,1};
- glTranslated(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
-
- } else
- {
- if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
- {
- // shadow must be cast to the ground, physics system needed here!
- MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
- MT_Vector3 direction = MT_Vector3(0,0,-1);
-
- direction.normalize();
- direction *= 100000;
-
- MT_Point3 topoint = frompoint + direction;
-
- KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
- PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
- KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
-
- KX_GameObject *parent = gameobj->GetParent();
- if (!physics_controller && parent)
- physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
- MT_Point3 resultpoint;
- MT_Vector3 resultnormal;
- if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback<GPC_RenderTools>(this, oglmatrix)))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixd(oglmatrix);
- }
- } else
- {
-
- // 'normal' object
- glMultMatrixd(oglmatrix);
- }
- }
-}
-
void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
{
int state = rasterizer->GetMotionBlurState();
@@ -590,4 +505,13 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
}
}
-unsigned int GPC_RenderTools::m_numgllights;
+void GPC_RenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+{
+ m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
+}
+
+void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas)
+{
+ m_filtermanager.RenderFilters(canvas);
+}
+
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
index f62aafff7c2..382956e73ea 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
@@ -30,146 +30,79 @@
#ifndef __GPC_RENDERTOOLS_H
#define __GPC_RENDERTOOLS_H
-#if defined(WIN32) || defined(__APPLE__)
- #ifdef WIN32
- #include <windows.h>
- #include <GL/gl.h>
- #else // WIN32
- // __APPLE__ is defined
- #include <AGL/gl.h>
- #endif // WIN32
-#else //defined(WIN32) || defined(__APPLE__)
- #include <GL/gl.h>
-#endif //defined(WIN32) || defined(__APPLE__)
-
+#ifdef WIN32
+// don't show stl-warnings
+#pragma warning (disable:4786)
+#include <windows.h>
+#endif // WIN32
#include "RAS_IRenderTools.h"
#include "BMF_Api.h"
struct KX_ClientObjectInfo;
+class KX_RayCast;
+/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
+ * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
+ * text, lighting.
+ *
+ * Most of this code is duplicated in KX_BlenderRenderTools, so this should be
+ * moved to some common location to avoid duplication. */
class GPC_RenderTools : public RAS_IRenderTools
{
+ int m_lastlightlayer;
+ bool m_lastlighting;
+ static unsigned int m_numgllights;
+
+ BMF_Font* m_font;
+
public:
- GPC_RenderTools();
- virtual ~GPC_RenderTools();
-
- virtual void EndFrame(RAS_IRasterizer* rasty);
- virtual void BeginFrame(RAS_IRasterizer* rasty);
-
- void DisableOpenGLLights()
- {
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
- }
-
- void EnableOpenGLLights();
-
- int ProcessLighting(int layer);
-
- void Perspective(int a, int width, int height, float mat[4][4], float viewmat[4][4])
- {
- if(a== 0)
- {
- glMatrixMode(GL_PROJECTION);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- else
- {
- if(a== 1)
- {
- glMatrixMode(GL_PROJECTION);
- glMatrixMode(GL_MODELVIEW);
- }
- }
- }
-
- /**
- * @attention mode is ignored here
- */
- virtual void RenderText2D(
- RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height);
-
- /**
- * Renders text into a (series of) polygon(s), using a texture font,
- * Each character consists of one polygon (one quad or two triangles)
- */
- virtual void RenderText(
- int mode,
- RAS_IPolyMaterial* polymat,
- float v1[3],
- float v2[3],
- float v3[3],
- float v4[3]);
-
- void Render(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode)
- {
- glPopMatrix();
- glPushMatrix();
- glMultMatrixd(oglmatrix);
- }
-
- void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
-
- virtual void PushMatrix()
- {
- glPushMatrix();
- }
-
- virtual void PopMatrix()
- {
- glPopMatrix();
- }
-
- virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- void* tface);
-
- int applyLights(int objectlayer);
-
- bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
+ GPC_RenderTools();
+ virtual ~GPC_RenderTools();
+
+ void EndFrame(RAS_IRasterizer* rasty);
+ void BeginFrame(RAS_IRasterizer* rasty);
+
+ void EnableOpenGLLights();
+ void DisableOpenGLLights();
+ void ProcessLighting(int layer, const MT_Transform& viewmat);
+
+ /* @attention mode is ignored here */
+ void RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height);
+ void RenderText(int mode,
+ class RAS_IPolyMaterial* polymat,
+ float v1[3],
+ float v2[3],
+ float v3[3],
+ float v4[3],
+ int glattrib);
+
+ void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
+ int applyLights(int objectlayer, const MT_Transform& viewmat);
+
+ void PushMatrix();
+ void PopMatrix();
+
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo* client) { return true; }
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
-protected:
- /**
- * Copied from KX_BlenderGL.cpp in KX_blenderhook
- */
- void BL_RenderText(
- int mode,
- const char* textstr,
- int textlen,
- struct MTFace* tface,
- unsigned int* col,
- float v1[3],float v2[3],float v3[3],float v4[3]);
- void BL_spack(unsigned int ucol)
- {
- char *cp = (char *)&ucol;
- glColor3ub(cp[3], cp[2], cp[1]);
- }
+ virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
- BMF_Font* m_font;
- static unsigned int m_numgllights;
+ virtual void Render2DFilters(RAS_ICanvas* canvas);
+
+ virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
};
#endif // __GPC_RENDERTOOLS_H
+
diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile
index b4800878704..6a12e659be6 100644
--- a/source/gameengine/GamePlayer/common/Makefile
+++ b/source/gameengine/GamePlayer/common/Makefile
@@ -35,6 +35,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I../../../blender/blenkernel
@@ -42,6 +43,7 @@ CPPFLAGS += -I../../../blender/blenloader
CPPFLAGS += -I../../../blender/blenlib
CPPFLAGS += -I../../../blender/imbuf
CPPFLAGS += -I../../../blender/makesdna
+CPPFLAGS += -I../../../blender/gpu
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
@@ -60,6 +62,7 @@ CPPFLAGS += -I../../../gameengine/Converter
CPPFLAGS += -I../../../gameengine/Expressions
CPPFLAGS += -I../../../gameengine/GameLogic
CPPFLAGS += -I../../../gameengine/Converter
+CPPFLAGS += -I../../../gameengine/BlenderRoutines
CPPFLAGS += -I../../../gameengine/Ketsji
CPPFLAGS += -I../../../gameengine/Ketsji/KXNetwork
CPPFLAGS += -I../../../gameengine/Network
diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript
index b6e373b4f92..30f20a670d3 100644
--- a/source/gameengine/GamePlayer/common/SConscript
+++ b/source/gameengine/GamePlayer/common/SConscript
@@ -4,60 +4,62 @@ Import ('env')
source_files = ['bmfont.cpp',
- 'GPC_Canvas.cpp',
- 'GPC_Engine.cpp',
- 'GPC_KeyboardDevice.cpp',
- 'GPC_MouseDevice.cpp',
- 'GPC_PolygonMaterial.cpp',
- 'GPC_RawImage.cpp',
- 'GPC_RawLoadDotBlendArray.cpp',
- 'GPC_RawLogoArrays.cpp',
- 'GPC_RenderTools.cpp',
- 'GPC_System.cpp']
+ 'GPC_Canvas.cpp',
+ 'GPC_Engine.cpp',
+ 'GPC_KeyboardDevice.cpp',
+ 'GPC_MouseDevice.cpp',
+ 'GPC_RawImage.cpp',
+ 'GPC_RawLoadDotBlendArray.cpp',
+ 'GPC_RawLogoArrays.cpp',
+ 'GPC_RenderTools.cpp',
+ 'GPC_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',
- '#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/ghost',
- '#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',
+ '#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/ghost',
+ '#source/blender/misc',
+ '#source/blender/blenloader',
+ '#source/blender/gpu',
+ '#extern/glew/include']
+
#This is all plugin stuff!
#if sys.platform=='win32':
# source_files += ['windows/GPW_Canvas.cpp',
-# 'windows/GPW_Engine.cpp',
-# 'windows/GPW_KeyboardDevice.cpp',
-# 'windows/GPW_System.cpp']
+# 'windows/GPW_Engine.cpp',
+# 'windows/GPW_KeyboardDevice.cpp',
+# 'windows/GPW_System.cpp']
# gp_common_env.Append ( CPPPATH = ['windows'])
#elif sys.platform=='linux2' or sys.platform=='linux-i386':
# source_files += ['unix/GPU_Canvas.cpp',
-# 'unix/GPU_Engine.cpp',
-# 'unix/GPU_KeyboardDevice.cpp',
-# 'unix/GPU_System.cpp']
+# 'unix/GPU_Engine.cpp',
+# 'unix/GPU_KeyboardDevice.cpp',
+# 'unix/GPU_System.cpp']
# gp_common_env.Append ( CPPPATH = ['unix'])
incs += Split(env['BF_PYTHON_INC'])
@@ -67,6 +69,6 @@ incs += Split(env['BF_ZLIB_INC'])
cflags=[]
if env['OURPLATFORM']=='win32-vc':
- cflags = ['/GR']
+ cflags = ['/GR']
env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = [], libtype='player', priority=5, compileflags=cflags)
diff --git a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
index fee729a84ac..e5ed7f39811 100644
--- a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
+++ b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
@@ -37,9 +37,9 @@ class GPU_PolygonMaterial : public BP_PolygonMaterial
public:
GPUPolygonMaterial(const STR_String& texname, bool ba,const STR_String& matname,
int tile, int tileXrep, int tileYrep, int mode, int transparant,
- int lightlayer,bool bIsTriangle,void* clientobject,void* tpage) :
+ int lightlayer,,void* tpage) :
BP_PolygonMaterial(texname, ba,matname, tile, tileXrep, tileYrep,
- mode, transparant, lightlayer, bIsTriangle, clientobject),
+ mode, transparant, lightlayer),
m_tface(tpage)
{
}
diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
index bb1abd71505..bf8cb720811 100644
--- a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
+++ b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
@@ -36,7 +36,7 @@
#include <iostream>
#include <windows.h>
-#include <gl/gl.h>
+//#include <gl/gl.h>
#include "GPC_Canvas.h"
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)