Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / gameengine / GamePlayer / ghost / GPG_Application.cpp
index 0fd1812cb3cfd4f3dd46a060112575b919697825..b5ebffb93784e3652ddcfee0920dd460e04d1899 100644 (file)
@@ -1,15 +1,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * 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
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  * GHOST Blender Player application implementation file.
  */
 
        #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 "GPG_Application.h"
 
@@ -137,7 +123,8 @@ 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)
 {
        fSystem = system;
 }
@@ -490,7 +477,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
 {
        if (!m_engineInitialized)
        {
-               bgl::InitExtensions(1);
+               glewInit();
+               bgl::InitExtensions(true);
 
                // get and set the preferences
                SYS_SystemHandle syshandle = SYS_GetSystem();
@@ -508,29 +496,12 @@ 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);
 
-#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT)
-               if (!getenv("WITHOUT_GLEXT")) {
+               if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) {
                        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;
+                       m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0);
                }
-#else
-                       m_blendermat=0;
-#endif//GL_ARB_multitexture
-               // ----------------------------------
        
                // create the canvas, rasterizer and rendertools
                m_canvas = new GPG_Canvas(window);
@@ -542,16 +513,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
                if (!m_rendertools)
                        goto initFailed;
                
-               if(useLists)
-                       if (useVertexArrays) {
+               if(useLists) {
+                       if(GLEW_VERSION_1_1)
                                m_rasterizer = new RAS_ListRasterizer(m_canvas, true);
-                       } else {
+                       else
                                m_rasterizer = new RAS_ListRasterizer(m_canvas);
-                       }
-               else if (useVertexArrays && bgl::QueryVersion(1, 1))
+               }
+               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;
@@ -658,6 +630,8 @@ bool GPG_Application::startEngine(void)
                //              sceneconverter->SetAlwaysUseExpandFraming(true);
                if(m_blendermat)
                        m_sceneconverter->SetMaterials(true);
+               if(m_blenderglslmat)
+                       m_sceneconverter->SetGLSLMaterials(true);
 
                KX_Scene* startscene = new KX_Scene(m_keyboard,
                        m_mouse,
@@ -670,7 +644,7 @@ bool GPG_Application::startEngine(void)
                PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest);
                m_ketsjiengine->SetPythonDictionary(dictionaryobject);
                initRasterizer(m_rasterizer, m_canvas);
-               PyObject *gameLogic = initGameLogic(startscene);
+               PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module
                initGameKeys();
                initPythonConstraintBinding();