BGE Video Texture: fix constant initializer problem with Exception description. Unifo...
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 1 Nov 2008 12:48:46 +0000 (12:48 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 1 Nov 2008 12:48:46 +0000 (12:48 +0000)
source/gameengine/VideoTexture/Exception.cpp
source/gameengine/VideoTexture/Exception.h
source/gameengine/VideoTexture/ImageMix.cpp
source/gameengine/VideoTexture/ImageRender.cpp
source/gameengine/VideoTexture/Texture.cpp
source/gameengine/VideoTexture/VideoFFmpeg.cpp
source/gameengine/VideoTexture/blendVideoTex.cpp

index a326430b27aee819811e8cd9b1b2f24e109a9c47..c576cebddc8aae6cf4592f257f3aff5b7576510a 100644 (file)
@@ -44,7 +44,6 @@ ExpDesc errNFoundDesc (ErrNotFound, "Error description not found");
 ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres) 
 : m_expID(exp), m_hRslt(hres), m_description(desc)
 {
-       m_expDescs.push_back(this);
 }
 
 // destructor
@@ -196,3 +195,15 @@ void Exception::copy (const Exception & xpt)
        m_fileName = xpt.m_fileName;
        m_line = xpt.m_line;
 }
+
+void registerAllExceptions(void)
+{
+    errGenerDesc.registerDesc();
+    errNFoundDesc.registerDesc();
+    MaterialNotAvailDesc.registerDesc();
+    ImageSizesNotMatchDesc.registerDesc();
+    SceneInvalidDesc.registerDesc();
+    CameraInvalidDesc.registerDesc();
+    SourceVideoEmptyDesc.registerDesc();
+    SourceVideoCreationDesc.registerDesc();
+}
index 85865fb3654f5012ad66055deb33f269b0836d13..5345e87f199663f1679563c5566e2650f9ff3859 100644 (file)
@@ -27,6 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt.
 #include <exception>
 #include <vector>
 #include <string>
+#include <algorithm>
 
 #include "Common.h"
 
@@ -117,6 +118,11 @@ public:
                desc = m_description;
        }
 
+    void registerDesc(void)
+    {
+        if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end())
+            m_expDescs.push_back(this);
+    }
        // list of exception descriptions
        static std::vector<ExpDesc*> m_expDescs;
 
@@ -192,4 +198,13 @@ protected:
 
 };
 
+extern ExpDesc MaterialNotAvailDesc;
+extern ExpDesc ImageSizesNotMatchDesc;
+extern ExpDesc SceneInvalidDesc;
+extern ExpDesc CameraInvalidDesc;
+extern ExpDesc SourceVideoEmptyDesc;
+extern ExpDesc SourceVideoCreationDesc;
+
+
+void registerAllExceptions(void);
 #endif
index 5650306616130012af7faf2507d9709d3e2d12f7..71250005129fbc70127342a6657ae31b9d7f4d02 100644 (file)
@@ -58,9 +58,9 @@ bool ImageMix::setWeight (const char * id, short weight)
        return true;
 }
 
-static ExceptionID ImageSizesNotMatch;
+ExceptionID ImageSizesNotMatch;
 
-static ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different");
+ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different");
 
 // calculate image from sources and set its availability
 void ImageMix::calcImage (unsigned int texId)
index c800b92e71da08e273f81f11283595d5ff6848a8..ce27a24d35a39f0ab86ea2cf599ca53bbd07b98c 100644 (file)
@@ -94,6 +94,10 @@ void ImageRender::calcImage (unsigned int texId)
        ImageViewport::calcImage(texId);
 }
 
+void ImageRender::Render()
+{
+    //
+}
 
 // refresh lights
 void ImageRender::refreshLights (void)
@@ -120,9 +124,9 @@ BlendType<KX_Scene> sceneType ("KX_Scene");
 BlendType<KX_Camera> cameraType ("KX_Camera");
 
 
-static ExceptionID SceneInvalid, CameraInvalid;
-static ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid");
-static ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid");
+ExceptionID SceneInvalid, CameraInvalid;
+ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid");
+ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid");
 
 // object initialization
 static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
index d208802675c799ef6c4a920de91fe104d0daf708..243c5f31db00a98fc9ef53618db25793fc828f87 100644 (file)
@@ -165,8 +165,8 @@ void Texture_dealloc (Texture * self)
 }
 
 
-static ExceptionID MaterialNotAvail;
-static ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available");
+ExceptionID MaterialNotAvail;
+ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available");
 
 // Texture object initialization
 int Texture_init (Texture *self, PyObject *args, PyObject *kwds)
index b12bad4b416dfa5aa4d88d51fec97f43a95457cb..65bd5f4cbf489ba267bd0e118eef77e710cfab5e 100644 (file)
@@ -265,7 +265,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
        AVInputFormat           *inputFormat;
        AVFormatParameters      formatParams;
        AVRational                      frameRate;
-       char                            *p, filename[28], rateStr[20];
+       char                            filename[28], rateStr[20];
 
        do_init_ffmpeg();
 
index 0f15a26db2f62c58991063882ba0dc3e279301f3..d08762b1d7c3b41c7bda7b9c857765295400fbf5 100644 (file)
@@ -174,6 +174,7 @@ PyObject* initVideoTexture(void)
 
        // prepare classes
        registerAllTypes();
+    registerAllExceptions();
 
        if (!pyImageTypes.ready()) 
                return NULL;