BGE: Fix for [#34781] "bge.texture.ImageRender does not show Font object" reported...
authorMitchell Stokes <mogurijin@gmail.com>
Thu, 20 Jun 2013 03:50:02 +0000 (03:50 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Thu, 20 Jun 2013 03:50:02 +0000 (03:50 +0000)
This fix is mostly based off of HG1's patch from the bug report, which had ImageRender::Render() call KX_KetsjiEngine::RenderFonts(). However, I have moved RenderFonts() from KX_KetsjiEngine to KX_Scene where all of the other font and rendering functions are. The real fix for this mess would be to not have ImageRender::Render() have so much duplicate code from KX_KetsjiEngine::Render(), but that's a code cleanup problem for another day.

source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/VideoTexture/ImageRender.cpp

index f02e842ad2e8bbbe65fddc257a06e99b0493beed..1061e9fd571ff85a5b2513dcb7e3dad43a8294ea 100644 (file)
@@ -54,7 +54,6 @@
 #include "MT_Transform.h"
 #include "SCA_IInputDevice.h"
 #include "KX_Camera.h"
-#include "KX_FontObject.h"
 #include "KX_Dome.h"
 #include "KX_Light.h"
 #include "KX_PythonInit.h"
@@ -340,7 +339,7 @@ void KX_KetsjiEngine::RenderDome()
                                // do the rendering
                                m_dome->RenderDomeFrame(scene,cam, i);
                                //render all the font objects for this scene
-                               RenderFonts(scene);
+                               scene->RenderFonts();
                        }
                        
                        list<class KX_Camera*>* cameras = scene->GetCameras();
@@ -358,7 +357,7 @@ void KX_KetsjiEngine::RenderDome()
                                        // do the rendering
                                        m_dome->RenderDomeFrame(scene, (*it),i);
                                        //render all the font objects for this scene
-                                       RenderFonts(scene);
+                                       scene->RenderFonts();
                                }
                                
                                it++;
@@ -1339,23 +1338,12 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
        scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
 
        //render all the font objects for this scene
-       RenderFonts(scene);
+       scene->RenderFonts();
        
        if (scene->GetPhysicsEnvironment())
                scene->GetPhysicsEnvironment()->debugDrawWorld();
 }
 
-void KX_KetsjiEngine::RenderFonts(KX_Scene* scene)
-{
-       list<class KX_FontObject*>* fonts = scene->GetFonts();
-       
-       list<KX_FontObject*>::iterator it = fonts->begin();
-       while (it != fonts->end()) {
-               (*it)->DrawText();
-               ++it;
-       }
-}
-
 /*
  * To run once per scene
  */
index 3cba3558db30b5357bf821f639f84873a891731d..4e69c7d35f7826ed0d7ba4a45ce5e7b7f0b6f103 100644 (file)
@@ -205,7 +205,6 @@ private:
        void                                    RenderDebugProperties();
        void                                    RenderShadowBuffers(KX_Scene *scene);
        void                                    SetBackGround(KX_WorldInfo* worldinfo);
-       void                                    RenderFonts(KX_Scene* scene);
 
 public:
        KX_KetsjiEngine(class KX_ISystem* system);
index 8bb9eaeef104716cc800ee7e17e005e644435260..13fb168221df5f6b10c4193a9d644558eec22182 100644 (file)
@@ -40,6 +40,7 @@
 #include "MT_assert.h"
 #include "KX_KetsjiEngine.h"
 #include "KX_BlenderMaterial.h"
+#include "KX_FontObject.h"
 #include "RAS_IPolygonMaterial.h"
 #include "ListValue.h"
 #include "SCA_LogicManager.h"
@@ -352,11 +353,6 @@ list<class KX_Camera*>* KX_Scene::GetCameras()
        return &m_cameras;
 }
 
-list<class KX_FontObject*>* KX_Scene::GetFonts()
-{
-       return &m_fonts;
-}
-
 void KX_Scene::SetFramingType(RAS_FrameSettings & frame_settings)
 {
        m_frame_settings = frame_settings;
@@ -1639,6 +1635,15 @@ void KX_Scene::RenderBuckets(const MT_Transform & cameratransform,
        KX_BlenderMaterial::EndFrame();
 }
 
+void KX_Scene::RenderFonts()
+{
+       list<KX_FontObject*>::iterator it = m_fonts.begin();
+       while (it != m_fonts.end()) {
+               (*it)->DrawText();
+               ++it;
+       }
+}
+
 void KX_Scene::UpdateObjectActivity(void) 
 {
        if (m_activity_culling) {
index 632e1bf9b509404f120be37352e64ac59d761723..7c3ea946044abb3741741c5cce6f075d777a8abb 100644 (file)
@@ -381,10 +381,6 @@ public:
        );
 
        /** Font Routines */
-               
-               std::list<class KX_FontObject*>*
-       GetFonts(
-       );
 
        /** Find a font in the scene by pointer. */
                KX_FontObject*              
@@ -398,6 +394,10 @@ public:
                KX_FontObject*
        );
 
+       /** Render the fonts in this scene. */
+               void
+       RenderFonts(
+       );
 
        /** Camera Routines */
 
index d251f4f7bcbc383d255b4496f7f64a570085011d..f184ab9bd1d8b4a5a2fdff6d47b8ea6dbb66bb1b 100644 (file)
@@ -275,6 +275,8 @@ void ImageRender::Render()
 
        m_scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
 
+       m_scene->RenderFonts();
+
        // restore the canvas area now that the render is completed
        m_canvas->GetWindowArea() = area;
 }