Revision: 17333
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17333
Author:   ben2610
Date:     2008-11-05 14:22:10 +0100 (Wed, 05 Nov 2008)

Log Message:
-----------
VideoTexture: Add support for GLSL. FIx small printout bug in Exception printout

Modified Paths:
--------------
    trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.h
    trunk/blender/source/gameengine/VideoTexture/Exception.cpp
    trunk/blender/source/gameengine/VideoTexture/Texture.cpp
    trunk/blender/source/gameengine/VideoTexture/Texture.h

Modified: trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.h 2008-11-05 
11:42:34 UTC (rev 17332)
+++ trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.h 2008-11-05 
13:22:10 UTC (rev 17333)
@@ -70,6 +70,9 @@
        BL_Texture * getTex (unsigned int idx) { 
                return (idx < MAXTEX) ? mTextures + idx : NULL; 
        }
+       Image * getImage (unsigned int idx) { 
+               return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : 
NULL; 
+       }
 
        // for ipos
        void UpdateIPO(

Modified: trunk/blender/source/gameengine/VideoTexture/Exception.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Exception.cpp  2008-11-05 
11:42:34 UTC (rev 17332)
+++ trunk/blender/source/gameengine/VideoTexture/Exception.cpp  2008-11-05 
13:22:10 UTC (rev 17333)
@@ -168,15 +168,15 @@
                }
                // add result code
                // length of result code
-               const size_t rsltSize = 10;
+               const size_t rsltSize = 11;
                // delimit description
                const char delimRslt[] = ": ";
                // set text of description
                char rsltTxt[rsltSize];
                std::ostrstream os(rsltTxt, rsltSize);
-               os << std::hex << m_hRslt << delimRslt;
+               os << std::hex << m_hRslt << delimRslt << '\0';
                // copy result to description
-               m_desc.insert(0, rsltTxt, rsltSize);
+               m_desc.insert(0, rsltTxt);
                // copy exception description to last exception string
                m_lastError = m_desc;
        }

Modified: trunk/blender/source/gameengine/VideoTexture/Texture.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Texture.cpp    2008-11-05 
11:42:34 UTC (rev 17332)
+++ trunk/blender/source/gameengine/VideoTexture/Texture.cpp    2008-11-05 
13:22:10 UTC (rev 17333)
@@ -54,9 +54,6 @@
 { exp.report(); }
 
 
-// are Blender materials used
-bool blendMats = false;
-
 // Blender GameObject type
 BlendType<KX_GameObject> gameObjectType ("KX_GameObject");
 
@@ -198,15 +195,22 @@
                        if (mat != NULL)
                        {
                                // is it blender material or polygon material
-                               blendMats = (mat->GetFlag() & RAS_BLENDERMAT) 
!= 0;
-                               if (blendMats)
+                               if (mat->GetFlag() & RAS_BLENDERGLSL) 
+                               {
+                                       self->m_imgTexture = 
static_cast<KX_BlenderMaterial*>(mat)->getImage(texID);
+                                       self->m_useMatTexture = false;
+                               } else if (mat->GetFlag() & RAS_BLENDERMAT)
+                               {
                                        // get blender material texture
                                        self->m_matTexture = 
static_cast<KX_BlenderMaterial*>(mat)->getTex(texID);
+                                       self->m_useMatTexture = true;
+                               }
                                else
                                {
                                        // get texture pointer from polygon 
material
                                        MTFace * tface = 
static_cast<KX_PolygonMaterial*>(mat)->GetMTFace();
                                        self->m_imgTexture = 
(Image*)tface->tpage;
+                                       self->m_useMatTexture = false;
                                }
                        }
                        // check if texture is available, if not, 
initialization failed
@@ -246,7 +250,7 @@
        {
                self->m_orgSaved = false;
                // restore original texture code
-               if (blendMats)
+               if (self->m_useMatTexture)
                        self->m_matTexture->swapTexture(self->m_orgTex);
                else
                        self->m_imgTexture->bindcode = self->m_orgTex;
@@ -292,7 +296,7 @@
                                {
                                        self->m_orgSaved = true;
                                        // save original image code
-                                       if (blendMats)
+                                       if (self->m_useMatTexture)
                                                self->m_orgTex = 
self->m_matTexture->swapTexture(self->m_actTex);
                                        else
                                        {

Modified: trunk/blender/source/gameengine/VideoTexture/Texture.h
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Texture.h      2008-11-05 
11:42:34 UTC (rev 17332)
+++ trunk/blender/source/gameengine/VideoTexture/Texture.h      2008-11-05 
13:22:10 UTC (rev 17333)
@@ -39,9 +39,11 @@
 {
        PyObject_HEAD
 
+       // texture is using blender material
+       bool m_useMatTexture;
+
        // video texture bind code
        unsigned int m_actTex;
-
        // original texture bind code
        unsigned int m_orgTex;
        // original texture saved
@@ -70,9 +72,6 @@
 // Texture type description
 extern PyTypeObject TextureType;
 
-// usage of Blender materials
-extern bool blendMats;
-
 // load texture
 void loadTexture (unsigned int texId, unsigned int * texture, short * size,
                                  bool mipmap = false);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to