improvement of 2d-filter custom shader,
[blender.git] / source / gameengine / BlenderRoutines / KX_BlenderRenderTools.cpp
index 6b0df44cb1696fa07f3d72c322c51bc4cc9bc7ef..220d174d464c00966be6991a3a28a749cf6a3374 100644 (file)
 
 #include "KX_BlenderRenderTools.h"
 
-#ifdef WIN32
-// OpenGL gl.h needs 'windows.h' on windows platforms 
-#include <windows.h>
-#endif //WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
+#include "GL/glew.h"
 
 #include "RAS_IRenderTools.h"
 #include "RAS_IRasterizer.h"
@@ -91,6 +82,10 @@ int  KX_BlenderRenderTools::ProcessLighting(int layer)
        {
                if (m_clientobject)
                {
+                       if (layer == RAS_LIGHT_OBJECT_LAYER)
+                       {
+                               layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
+                       }
                        if (applyLights(layer))
                        {
                                EnableOpenGLLights();
@@ -121,6 +116,22 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
 
 }
 
+void KX_BlenderRenderTools::SetClientObject(void* obj)
+{
+       if (m_clientobject != obj)
+       {
+               if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
+               {
+                       glFrontFace(GL_CCW);
+               } else 
+               {
+                       glFrontFace(GL_CW);
+               }
+               m_clientobject = obj;
+               m_modified = true;
+       }
+}
+
 bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
 {
        double* const oglmatrix = (double* const) data;
@@ -297,7 +308,7 @@ void KX_BlenderRenderTools::EnableOpenGLLights()
        glEnable(GL_COLOR_MATERIAL);
        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
-       if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2))
+       if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
                glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
 
 }
@@ -472,9 +483,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
        }
 }
 
-void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
 {
-       m_filtermanager.EnableFilter(filtermode, pass, text);
+       m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
 }
 
 void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)