⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrepythonframelistener.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
#ifndef __PythonFrameListener_H__
#define __PythonFrameListener_H__

#include "OgrePrerequisites.h"
#include "OgreFrameListener.h"
#include <boost/python.hpp>

using namespace boost::python;

namespace Ogre {

    /** Subclass of FrameListener to enable callbacks
        into Python code. */
    class PythonFrameListener : public FrameListener
    {
    public:
        // constructor storing initial self_ parameter
        PythonFrameListener(PyObject* self_)
            : self(self_) {}

        bool frameStarted(const FrameEvent& evt)
        {
            // Have to hardcode this
            // VC++6 falls over trying to use callback<bool>::call_method<Framevent>
            //  with an internal compiler error (ouch)
            //  Must be too templatey for it's liking
//            ref p1(to_python(evt));
//            ref result(PyEval_CallMethod(self, const_cast<char*>("frameStarted"),
//                                         const_cast<char*>("(O)"),
//                                         p1.get()));
//            detail::callback_adjust_refcount(result.get(), type<bool>());
//            return from_python(result.get(), type<bool>());
            return call_method<bool>(self, "frameStarted", evt);

            //return callback<bool>::call_method<const FrameEvent&>(self, "frameStarted", evt);
        }
        bool frameEnded(const FrameEvent& evt)
        {
            // Have to hardcode this
            // VC++6 falls over trying to use callback<bool>::call_method<Framevent>
            //  with an internal compiler error (ouch)
            //  Must be too templatey for it's liking
//            ref p1(to_python(evt));
//            ref result(PyEval_CallMethod(self, const_cast<char*>("frameEnded"),
//                                         const_cast<char*>("(O)"),
//                                         p1.get()));
//            detail::callback_adjust_refcount(result.get(), type<bool>());
//            return from_python(result.get(), type<bool>());
            return call_method<bool>(self, "frameEnded", evt);
            //return boost::python::callback<bool>::call_method<const FrameEvent&>(self, "frameEnded", evt);
        }

        // Supplies the default implementation of methods
        static bool default_frameStarted(FrameListener* self_, const FrameEvent& evt)
            { 
                return self_->FrameListener::frameStarted(evt); 
            }
        static bool default_frameEnded(FrameListener* self_, const FrameEvent& evt)
            { 
                return self_->FrameListener::frameEnded(evt); 
            }
     private:
        PyObject* self;
    };
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -