[Python-ogre-commit] SF.net SVN: python-ogre:[776] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-10-27 12:54:12
|
Revision: 776 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=776&view=rev Author: andy_miller Date: 2008-10-27 12:54:04 +0000 (Mon, 27 Oct 2008) Log Message: ----------- Updates to Hydrax (0.4) and QuickGui Move Hikari into Thirdparty to make it easier Modified Paths: -------------- trunk/python-ogre/PythonOgreConfig_nt.py trunk/python-ogre/PythonOgreConfig_posix.py trunk/python-ogre/ThirdParty/quickgui/QuickGUIButton.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIButton.h trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIComponentWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIComponentWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIContainerWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIContainerWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIEventTypes.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIExportDLL.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIHScrollBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIHScrollBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIImage.h trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIListItem.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIListItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIListTextItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenu.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenu.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuPanel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIModalWindow.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMouseCursor.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIProgressBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIRoot.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIRoot.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialBase.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialReader.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialReader.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialWriter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialWriter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISize.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinElement.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIStringConverter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextArea.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextCursor.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextCursor.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextLine.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextLine.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBarItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIVScrollBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIVScrollBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWindow.cpp trunk/python-ogre/code_generators/hikari/generate_code.py trunk/python-ogre/code_generators/quickgui/generate_code.py trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/ThirdParty/Hikari/ trunk/python-ogre/ThirdParty/Hikari/Delegate.h trunk/python-ogre/ThirdParty/Hikari/FlashControl.cpp trunk/python-ogre/ThirdParty/Hikari/FlashControl.h trunk/python-ogre/ThirdParty/Hikari/FlashSite.h trunk/python-ogre/ThirdParty/Hikari/FlashValue.cpp trunk/python-ogre/ThirdParty/Hikari/FlashValue.h trunk/python-ogre/ThirdParty/Hikari/Hikari.cpp trunk/python-ogre/ThirdParty/Hikari/Hikari.h trunk/python-ogre/ThirdParty/Hikari/HikariPlatform.h trunk/python-ogre/ThirdParty/Hikari/KeyboardHook.cpp trunk/python-ogre/ThirdParty/Hikari/KeyboardHook.h trunk/python-ogre/ThirdParty/Hikari/Position.cpp trunk/python-ogre/ThirdParty/Hikari/Position.h trunk/python-ogre/ThirdParty/Hikari/RenderBuffer.cpp trunk/python-ogre/ThirdParty/Hikari/RenderBuffer.h trunk/python-ogre/ThirdParty/Hikari/ViewportOverlay.cpp trunk/python-ogre/ThirdParty/Hikari/ViewportOverlay.h trunk/python-ogre/ThirdParty/Hikari/flashhandler.h trunk/python-ogre/ThirdParty/Hydrax/ trunk/python-ogre/ThirdParty/Hydrax/CfgFileManager.cpp trunk/python-ogre/ThirdParty/Hydrax/CfgFileManager.h trunk/python-ogre/ThirdParty/Hydrax/DecalsManager.cpp trunk/python-ogre/ThirdParty/Hydrax/DecalsManager.h trunk/python-ogre/ThirdParty/Hydrax/Enums.cpp trunk/python-ogre/ThirdParty/Hydrax/Enums.h trunk/python-ogre/ThirdParty/Hydrax/GPUNormalMapManager.cpp trunk/python-ogre/ThirdParty/Hydrax/GPUNormalMapManager.h trunk/python-ogre/ThirdParty/Hydrax/GodRaysManager.cpp trunk/python-ogre/ThirdParty/Hydrax/GodRaysManager.h trunk/python-ogre/ThirdParty/Hydrax/Help.cpp trunk/python-ogre/ThirdParty/Hydrax/Help.h trunk/python-ogre/ThirdParty/Hydrax/Hydrax.cpp trunk/python-ogre/ThirdParty/Hydrax/Hydrax.h trunk/python-ogre/ThirdParty/Hydrax/Image.cpp trunk/python-ogre/ThirdParty/Hydrax/Image.h trunk/python-ogre/ThirdParty/Hydrax/MaterialManager.cpp trunk/python-ogre/ThirdParty/Hydrax/MaterialManager.h trunk/python-ogre/ThirdParty/Hydrax/Mesh.cpp trunk/python-ogre/ThirdParty/Hydrax/Mesh.h trunk/python-ogre/ThirdParty/Hydrax/Module.cpp trunk/python-ogre/ThirdParty/Hydrax/Module.h trunk/python-ogre/ThirdParty/Hydrax/Noise.cpp trunk/python-ogre/ThirdParty/Hydrax/Noise.h trunk/python-ogre/ThirdParty/Hydrax/Perlin.cpp trunk/python-ogre/ThirdParty/Hydrax/Perlin.h trunk/python-ogre/ThirdParty/Hydrax/Prerequisites.cpp trunk/python-ogre/ThirdParty/Hydrax/Prerequisites.h trunk/python-ogre/ThirdParty/Hydrax/ProjectedGrid.cpp trunk/python-ogre/ThirdParty/Hydrax/ProjectedGrid.h trunk/python-ogre/ThirdParty/Hydrax/RttManager.cpp trunk/python-ogre/ThirdParty/Hydrax/RttManager.h trunk/python-ogre/ThirdParty/Hydrax/SimpleGrid.cpp trunk/python-ogre/ThirdParty/Hydrax/SimpleGrid.h trunk/python-ogre/ThirdParty/Hydrax/TextureManager.cpp trunk/python-ogre/ThirdParty/Hydrax/TextureManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIForwardDeclaredDesc.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIForwardDeclaredDesc.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITab.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITab.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITabControl.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITabControl.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITabPage.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITabPage.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextInputValidator.h Removed Paths: ------------- trunk/python-ogre/ThirdParty/quickgui/QuickGUIButtonStates.h Modified: trunk/python-ogre/PythonOgreConfig_nt.py =================================================================== --- trunk/python-ogre/PythonOgreConfig_nt.py 2008-10-27 06:40:23 UTC (rev 775) +++ trunk/python-ogre/PythonOgreConfig_nt.py 2008-10-27 12:54:04 UTC (rev 776) @@ -81,8 +81,8 @@ PATH_particleuniverse = os.path.join(PATH_Ogre, 'PlugIns', 'ParticleUniverse' ) PATH_ogrepcz = os.path.join(PATH_Ogre, 'PlugIns', 'PCZSceneManager' ) -PATH_hydrax = os.path.join(PATH_THIRDPARTY, 'hydrax') -PATH_hikari = os.path.join(BASE_DIR, 'hikari', 'hikari') +PATH_hydrax = os.path.join(PATH_THIRDPARTY, 'Hydrax') +PATH_hikari = os.path.join(PATH_THIRDPARTY, 'Hikari' ) #BASE_DIR, 'hikari', 'hikari') # it's time for the SDK version if SDK: @@ -129,7 +129,7 @@ PATH_LIB_CEGUI = os.path.join( PATH_Ogre, 'lib' ) PATH_LIB_opensteer = os.path.join(PATH_opensteer, 'win32','release') -PATH_LIB_hikari = os.path.join(PATH_hikari, 'lib') +PATH_LIB_hikari = os.path.join(PATH_hikari ) # , 'lib') PATH_INCLUDE_Ogre= os.path.join(PATH_Ogre,'OgreMain/include') @@ -179,7 +179,7 @@ PATH_INCLUDE_particleuniverse = os.path.join(PATH_particleuniverse, 'include' ) PATH_INCLUDE_ogrepcz = os.path.join(PATH_ogrepcz,'include') PATH_INCLUDE_hydrax= PATH_hydrax -PATH_INCLUDE_hikari = os.path.join(PATH_hikari, 'include') +PATH_INCLUDE_hikari = os.path.join(PATH_hikari ) #, 'include') PATH_INCLUDE_OggVorbisTheora = [ os.path.join(BASE_DIR,'ogg','include') ,os.path.join(BASE_DIR, 'vorbis', 'include') Modified: trunk/python-ogre/PythonOgreConfig_posix.py =================================================================== --- trunk/python-ogre/PythonOgreConfig_posix.py 2008-10-27 06:40:23 UTC (rev 775) +++ trunk/python-ogre/PythonOgreConfig_posix.py 2008-10-27 12:54:04 UTC (rev 776) @@ -79,8 +79,8 @@ PATH_cadunetree= os.path.join(PATH_THIRDPARTY, 'cadunetree') PATH_opensteer = os.path.join(BASE_DIR, 'opensteer', 'trunk') PATH_ogrepcz = os.path.join(PATH_Ogre, 'PlugIns', 'PCZSceneManager' ) -PATH_hydrax = os.path.join(PATH_THIRDPARTY, 'hydrax') -PATH_hikari = os.path.join(BASE_DIR, 'hikari', 'hikari') +PATH_hydrax = os.path.join(PATH_THIRDPARTY, 'Hydrax') +PATH_hikari = os.path.join(PATH_THIRDPARTY, 'Hikari' ) # BASE_DIR, 'hikari', 'hikari') ### ### these paths assume you've left all the directory structure as standard @@ -119,7 +119,7 @@ PATH_LIB_navi= os.path.join(PATH_navi, 'lib') PATH_LIB_particleuniverse = os.path.join(PATH_particleuniverse, 'bin', 'release') PATH_LIB_opensteer = os.path.join(LOCAL_LIB) -PATH_LIB_hikari = os.path.join(PATH_hikari, 'lib') +PATH_LIB_hikari = os.path.join(PATH_hikari ) #, 'lib') PATH_INCLUDE_Ogre= os.path.join(LOCAL_INCLUDE,'OGRE') # os.path.join(PATH_Ogre,'OgreMain/include') PATH_INCLUDE_Ogre_Dependencies = PATH_INCLUDE_Ogre # os.path.join( PATH_Ogre, 'Dependencies/include') @@ -190,5 +190,5 @@ PATH_INCLUDE_opensteer_opensteer = os.path.join(LOCAL_INCLUDE, 'OpenSteer') PATH_INCLUDE_ogrepcz = os.path.join(PATH_ogrepcz,'include') PATH_INCLUDE_hydrax= PATH_hydrax -PATH_INCLUDE_hikari = os.path.join(PATH_hikari, 'include') +PATH_INCLUDE_hikari = os.path.join(PATH_hikari ) #, 'include') Added: trunk/python-ogre/ThirdParty/Hikari/Delegate.h =================================================================== --- trunk/python-ogre/ThirdParty/Hikari/Delegate.h (rev 0) +++ trunk/python-ogre/ThirdParty/Hikari/Delegate.h 2008-10-27 12:54:04 UTC (rev 776) @@ -0,0 +1,481 @@ +/* + FastDelegate.h v1.5, author: Don Clugston, Mar 2004 + Efficient delegates in C++ that generate only two lines of asm code! + Documentation is found at http://www.codeproject.com/cpp/FastDelegate.asp + + AJS: Modified for use with Hikari: trimmed out stuff we don't use. +*/ + +#ifndef __DELEGATE_H__ +#define __DELEGATE_H__ + +#include <memory.h> +#include "FlashValue.h" + +#define FASTDELEGATE_USESTATICFUNCTIONHACK +#if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__VECTOR_C) && !defined(__ICL) && !defined(__BORLANDC__) +#define FASTDLGT_ISMSVC +#if (_MSC_VER <1300) +#define FASTDLGT_VC6 +#pragma warning(disable:4786) +#endif +#endif +#if defined(_MSC_VER) && !defined(__MWERKS__) +#define FASTDLGT_MICROSOFT_MFP +#if !defined(__VECTOR_C) +#define FASTDLGT_HASINHERITANCE_KEYWORDS +#endif +#endif +#ifdef __GNUC__ + +#define FASTDELEGATE_GCC_BUG_8271 +#endif +namespace Hikari { +namespace Impl { +namespace fastdelegate { + namespace detail { + template <class OutputClass, class InputClass> + inline OutputClass implicit_cast(InputClass input){ + return input; + } + template <class OutputClass, class InputClass> + union horrible_union{ + OutputClass out; + InputClass in; + }; + template <class OutputClass, class InputClass> + inline OutputClass horrible_cast(const InputClass input){ + horrible_union<OutputClass, InputClass> u; + + typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u) + && sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1]; + u.in = input; + return u.out; + } +#define FASTDELEGATEDECLARE(CLASSNAME) class CLASSNAME; +#ifdef __MEDIUM__ +#undef FASTDELEGATE_USESTATICFUNCTIONHACK +#endif +#ifdef FASTDLGT_VC6 + typedef const void * DefaultVoid; +#else + typedef void DefaultVoid; +#endif + template <class T> + struct DefaultVoidToVoid { typedef T type; }; + template <> + struct DefaultVoidToVoid<DefaultVoid> { typedef void type; }; + template <class T> + struct VoidToDefaultVoid { typedef T type; }; + template <> + struct VoidToDefaultVoid<void> { typedef DefaultVoid type; }; +#ifdef FASTDLGT_MICROSOFT_MFP +#ifdef FASTDLGT_HASINHERITANCE_KEYWORDS + + class __single_inheritance GenericClass; +#endif + class GenericClass {}; +#else + class GenericClass; +#endif + const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)()); + template <int N> + struct SimplifyMemFunc { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { + + + typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100]; + return 0; + } + }; + template <> + struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE> { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { +#if defined __DMC__ + + + + bound_func = horrible_cast<GenericMemFuncType>(function_to_bind); +#else + bound_func = reinterpret_cast<GenericMemFuncType>(function_to_bind); +#endif + return reinterpret_cast<GenericClass *>(pthis); + } + }; +#ifdef FASTDLGT_MICROSOFT_MFP + template<> + struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(int) > { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { + + + union { + XFuncType func; + struct { + GenericMemFuncType funcaddress; + int delta; + }s; + } u; + + typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)? 1 : -1]; + u.func = function_to_bind; + bound_func = u.s.funcaddress; + return reinterpret_cast<GenericClass *>(reinterpret_cast<char *>(pthis) + u.s.delta); + } + }; + struct MicrosoftVirtualMFP { + void (GenericClass::*codeptr)(); + int delta; + int vtable_index; + }; + struct GenericVirtualClass : virtual public GenericClass + { + typedef GenericVirtualClass * (GenericVirtualClass::*ProbePtrType)(); + GenericVirtualClass * GetThis() { return this; } + }; + template <> + struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2*sizeof(int) > + { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { + union { + XFuncType func; + GenericClass* (X::*ProbeFunc)(); + MicrosoftVirtualMFP s; + } u; + u.func = function_to_bind; + bound_func = reinterpret_cast<GenericMemFuncType>(u.s.codeptr); + union { + GenericVirtualClass::ProbePtrType virtfunc; + MicrosoftVirtualMFP s; + } u2; + + typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s) + && sizeof(function_to_bind)==sizeof(u.ProbeFunc) + && sizeof(u2.virtfunc)==sizeof(u2.s) ? 1 : -1]; + u2.virtfunc = &GenericVirtualClass::GetThis; + u.s.codeptr = u2.s.codeptr; + return (pthis->*u.ProbeFunc)(); + } + }; +#if (_MSC_VER <1300) + template <> + struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) > + { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { + + typedef char ERROR_VC6CompilerBug[-100]; + return 0; + } + }; +#else + template <> + struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) > + { + template <class X, class XFuncType, class GenericMemFuncType> + inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, + GenericMemFuncType &bound_func) { + + + union { + XFuncType func; + + + struct { + GenericMemFuncType m_funcaddress; + int delta; + int vtordisp; + int vtable_index; + } s; + } u; + + typedef int ERROR_CantUsehorrible_cast[sizeof(XFuncType)==sizeof(u.s)? 1 : -1]; + u.func = function_to_bind; + bound_func = u.s.funcaddress; + int virtual_delta = 0; + if (u.s.vtable_index) { + + + const int * vtable = *reinterpret_cast<const int *const*>( + reinterpret_cast<const char *>(pthis) + u.s.vtordisp ); + + virtual_delta = u.s.vtordisp + *reinterpret_cast<const int *>( + reinterpret_cast<const char *>(vtable) + u.s.vtable_index); + } + return reinterpret_cast<GenericClass *>( + reinterpret_cast<char *>(pthis) + u.s.delta + virtual_delta); + }; + }; +#endif +#endif + } + class DelegateMemento { + protected: + + typedef void (detail::GenericClass::*GenericMemFuncType)(); + detail::GenericClass *m_pthis; + GenericMemFuncType m_pFunction; +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + typedef void (*GenericFuncPtr)(); + GenericFuncPtr m_pStaticFunction; +#endif + public: +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + DelegateMemento() : m_pthis(0), m_pFunction(0), m_pStaticFunction(0) {}; + void clear() { + m_pthis=0; m_pFunction=0; m_pStaticFunction=0; + } +#else + DelegateMemento() : m_pthis(0), m_pFunction(0) {}; + void clear() { m_pthis=0; m_pFunction=0; } +#endif + public: +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + inline bool IsEqual (const DelegateMemento &x) const{ + + if (m_pFunction!=x.m_pFunction) return false; + + if (m_pStaticFunction!=x.m_pStaticFunction) return false; + if (m_pStaticFunction!=0) return m_pthis==x.m_pthis; + else return true; + } +#else + inline bool IsEqual (const DelegateMemento &x) const{ + return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction; + } +#endif + + inline bool IsLess(const DelegateMemento &right) const { + +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0) + return m_pStaticFunction < right.m_pStaticFunction; +#endif + if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis; + + + + return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0; + } + + inline bool operator ! () const + { return m_pthis==0 && m_pFunction==0; } + inline bool empty() const + { return m_pthis==0 && m_pFunction==0; } + public: + DelegateMemento & operator = (const DelegateMemento &right) { + SetMementoFrom(right); + return *this; + } + inline bool operator <(const DelegateMemento &right) { + return IsLess(right); + } + inline bool operator >(const DelegateMemento &right) { + return right.IsLess(*this); + } + DelegateMemento (const DelegateMemento &right) : + m_pFunction(right.m_pFunction), m_pthis(right.m_pthis) +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + , m_pStaticFunction (right.m_pStaticFunction) +#endif + {} + protected: + void SetMementoFrom(const DelegateMemento &right) { + m_pFunction = right.m_pFunction; + m_pthis = right.m_pthis; +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + m_pStaticFunction = right.m_pStaticFunction; +#endif + } + }; + namespace detail { + template < class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr> + class ClosurePtr : public DelegateMemento { + public: + + template < class X, class XMemFunc > + inline void bindmemfunc(X *pthis, XMemFunc function_to_bind ) { + m_pthis = SimplifyMemFunc< sizeof(function_to_bind) > + ::Convert(pthis, function_to_bind, m_pFunction); +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + m_pStaticFunction = 0; +#endif + } + + template < class X, class XMemFunc> + inline void bindconstmemfunc(const X *pthis, XMemFunc function_to_bind) { + m_pthis= SimplifyMemFunc< sizeof(function_to_bind) > + ::Convert(const_cast<X*>(pthis), function_to_bind, m_pFunction); +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + m_pStaticFunction = 0; +#endif + } +#ifdef FASTDELEGATE_GCC_BUG_8271 + template < class X, class XMemFunc> + inline void bindmemfunc(const X *pthis, XMemFunc function_to_bind) { + bindconstmemfunc(pthis, function_to_bind); +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + m_pStaticFunction = 0; +#endif + } +#endif + + inline GenericClass *GetClosureThis() const { return m_pthis; } + inline GenericMemFunc GetClosureMemPtr() const { return reinterpret_cast<GenericMemFunc>(m_pFunction); } +#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) + public: + + template< class DerivedClass > + inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &x) { + SetMementoFrom(x); + if (m_pStaticFunction!=0) { + + m_pthis=reinterpret_cast<GenericClass *>(pParent); + } + } + + template < class DerivedClass, class ParentInvokerSig > + inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, + StaticFuncPtr function_to_bind ) { + if (function_to_bind==0) { + m_pFunction=0; + } else { + bindmemfunc(pParent, static_function_invoker); + } + m_pStaticFunction=reinterpret_cast<GenericFuncPtr>(function_to_bind); + } + inline UnvoidStaticFuncPtr GetStaticFunction() const { + return reinterpret_cast<UnvoidStaticFuncPtr>(m_pStaticFunction); + } +#else + template< class DerivedClass > + inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &right) { + SetMementoFrom(right); + } + + template < class DerivedClass, class ParentInvokerSig> + inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, + StaticFuncPtr function_to_bind) { + if (function_to_bind==0) { + m_pFunction=0; + } else { + + + bindmemfunc(pParent, static_function_invoker); + } + + typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1]; + m_pthis = horrible_cast<GenericClass *>(function_to_bind); + } + + inline UnvoidStaticFuncPtr GetStaticFunction() const { + + typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1]; + return horrible_cast<UnvoidStaticFuncPtr>(this); + } +#endif + + inline bool IsEqualToStaticFuncPtr(StaticFuncPtr funcptr){ + if (funcptr==0) return empty(); + + + else return funcptr==reinterpret_cast<StaticFuncPtr>(GetStaticFunction()); + } + }; + } + template<class Param1, class Param2, class RetType=detail::DefaultVoid> + class FastDelegate2 { + private: + typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType; + typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2); + typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2); + typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2); + typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType; + ClosureType m_Closure; + public: + + typedef FastDelegate2 type; + + FastDelegate2() { clear(); } + FastDelegate2(const FastDelegate2 &x) { + m_Closure.CopyFrom(this, x.m_Closure); } + void operator = (const FastDelegate2 &x) { + m_Closure.CopyFrom(this, x.m_Closure); } + bool operator ==(const FastDelegate2 &x) const { + return m_Closure.IsEqual(x.m_Closure); } + bool operator !=(const FastDelegate2 &x) const { + return !m_Closure.IsEqual(x.m_Closure); } + bool operator <(const FastDelegate2 &x) const { + return m_Closure.IsLess(x.m_Closure); } + bool operator >(const FastDelegate2 &x) const { + return x.m_Closure.IsLess(m_Closure); } + + template < class X, class Y > + FastDelegate2(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) ) { + m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } + template < class X, class Y > + inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2)) { + m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } + + template < class X, class Y > + FastDelegate2(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) { + m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); } + template < class X, class Y > + inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) { + m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); } + + + FastDelegate2(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) { + bind(function_to_bind); } + + void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) { + bind(function_to_bind); } + inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2)) { + m_Closure.bindstaticfunc(this, &FastDelegate2::InvokeStaticFunction, + function_to_bind); } + + RetType operator() (Param1 p1, Param2 p2) const { + return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2); } + + private: + typedef struct SafeBoolStruct { + int a_data_pointer_to_this_is_0_on_buggy_compilers; + StaticFunctionPtr m_nonzero; + } UselessTypedef; + typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; + public: + operator unspecified_bool_type() const { + return empty()? 0: &SafeBoolStruct::m_nonzero; + } + + inline bool operator==(StaticFunctionPtr funcptr) { + return m_Closure.IsEqualToStaticFuncPtr(funcptr); } + inline bool operator!=(StaticFunctionPtr funcptr) { + return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } + inline bool operator ! () const { + return !m_Closure; } + inline bool empty() const { + return !m_Closure; } + void clear() { m_Closure.clear();} + + const DelegateMemento & GetMemento() { return m_Closure; } + void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } + private: + RetType InvokeStaticFunction(Param1 p1, Param2 p2) const { + return (*(m_Closure.GetStaticFunction()))(p1, p2); } + }; +} +} + class FlashControl; + + typedef Impl::fastdelegate::FastDelegate2<FlashControl*, const Arguments&, FlashValue> FlashDelegate; +} +#endif Added: trunk/python-ogre/ThirdParty/Hikari/FlashControl.cpp =================================================================== --- trunk/python-ogre/ThirdParty/Hikari/FlashControl.cpp (rev 0) +++ trunk/python-ogre/ThirdParty/Hikari/FlashControl.cpp 2008-10-27 12:54:04 UTC (rev 776) @@ -0,0 +1,670 @@ +/* + This file is part of Hikari, a library that allows developers + to use Flash in their Ogre3D applications. + + Copyright (C) 2008 Adam J. Simmons + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "FlashControl.h" +#include "FlashSite.h" +#include "FlashHandler.h" +#include "RenderBuffer.h" +#include "ViewportOverlay.h" +#include "Hikari.h" +#include "OgreBitwise.h" + +using namespace Hikari; +using namespace Ogre; + +FlashControl::FlashControl(const Ogre::String& name, Ogre::Viewport* viewport, int width, int height, const Position& position, Ogre::uchar zOrder, Ogre::uchar tier) +: name(name), + site(0), + handler(0), + flashInterface(0), + oleObject(0), windowlessObject(0), + width(width), height(height), + state(0), + comCount(0), + mainContext(0), mainBitmap(0), mainBuffer(0), + altContext(0), altBitmap(0), altBuffer(0), + renderBuffer(0), + usingAlphaHack(false), + isClean(true), isTotallyDirty(false), + overlay(0), + lastDirtyWidth(0), lastDirtyHeight(0), + texWidth(width), texHeight(height), texDepth(0), texPitch(0), texUnit(0), + compensateNPOT(false), isTransparent(false), okayToDelete(false), isDraggable(true), + isIgnoringTransparent(true), transThreshold(0.04) +{ + renderBuffer = new Impl::RenderBuffer(width, height); + createControl(); + createMaterial(); + overlay = new Impl::ViewportOverlay(name, viewport, width, height, position, materialName, zOrder, tier); + if(compensateNPOT) + overlay->panel->setUV(0, 0, (Real)width/(Real)texWidth, (Real)height/(Real)texHeight); +} + +FlashControl::FlashControl(const Ogre::String& name, int width, int height) +: name(name), + site(0), + handler(0), + flashInterface(0), + oleObject(0), windowlessObject(0), + width(width), height(height), + state(0), + comCount(0), + mainContext(0), mainBitmap(0), mainBuffer(0), + altContext(0), altBitmap(0), altBuffer(0), + renderBuffer(0), + usingAlphaHack(false), + isClean(true), isTotallyDirty(false), + overlay(0), + lastDirtyWidth(0), lastDirtyHeight(0), + texWidth(width), texHeight(height), texDepth(0), texPitch(0), texUnit(0), + compensateNPOT(false), isTransparent(false), okayToDelete(false), isDraggable(false), + isIgnoringTransparent(false), transThreshold(0) +{ + renderBuffer = new Impl::RenderBuffer(width, height); + createControl(); + createMaterial(); +} + +FlashControl::~FlashControl() +{ + if(overlay) delete overlay; + texture.setNull(); + MaterialManager::getSingletonPtr()->remove(name + "Material"); + TextureManager::getSingletonPtr()->remove(name + "Texture"); + + if(windowlessObject) windowlessObject->Release(); + if(flashInterface) flashInterface->Release(); + if(handler) + { + handler->Shutdown(); + handler->Release(); + } + + if(oleObject) + { + oleObject->Close(OLECLOSE_NOSAVE); + oleObject->Release(); + } + + if(site) site->Release(); + + if(comCount) + LogManager::getSingleton().logMessage("WARNING: Hikari::FlashControl is leaking COM objects!"); + + if(mainContext) ::DeleteDC(mainContext); + if(mainBitmap) ::DeleteObject(mainBitmap); + if(altContext) ::DeleteDC(altContext); + if(altBitmap) ::DeleteObject(altBitmap); + if(renderBuffer) delete renderBuffer; +} + +typedef HRESULT (__stdcall *GetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppv); + +void FlashControl::createControl() +{ + site = new Impl::FlashSite(); + site->AddRef(); + site->Init(this); + + HMODULE flashLib = HikariManager::Get().flashLib; + + // Try to load from user-supplied Flash OCX first + if(flashLib) + { + IClassFactory* factory = 0; + GetClassObject getClassFunc = (GetClassObject)GetProcAddress(flashLib, "DllGetClassObject"); + HRESULT result = getClassFunc(ShockwaveFlashObjects::CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&factory); + if(SUCCEEDED(result)) + { + factory->CreateInstance(NULL, IID_IOleObject, (void**)&oleObject); + factory->Release(); + } + } + + // If we still don't have the object, try loading from registry + if(!oleObject) + { + HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject); + if(FAILED(result)) + OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "FlashControl::createControl"); + } + + IOleClientSite* clientSite = 0; + site->QueryInterface(__uuidof(IOleClientSite), (void**)&clientSite); + oleObject->SetClientSite(clientSite); + clientSite->Release(); + + IOleInPlaceObject* inPlaceObject = 0; + oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject); + + if(inPlaceObject) + { + invalidateTotally(); + + inPlaceObject->SetObjectRects(&dirtyBounds, &dirtyBounds); + inPlaceObject->Release(); + } + + oleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&flashInterface); + + flashInterface->PutWMode("opaque"); + + oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, clientSite, 0, 0, 0); + clientSite->Release(); + + oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (LPVOID*)&windowlessObject); + + handler = new Impl::FlashHandler(); + handler->AddRef(); + handler->Init(this); + + IViewObject* curView = 0; + flashInterface->QueryInterface(IID_IViewObject, (void**)&curView); +} + +void FlashControl::createMaterial() +{ + texture.setNull(); + MaterialManager::getSingletonPtr()->remove(name + "Material"); + TextureManager::getSingletonPtr()->remove(name + "Texture"); + + texWidth = width; + texHeight = height; + if(!Bitwise::isPO2(width) || !Bitwise::isPO2(height)) + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_NON_POWER_OF_2_TEXTURES)) + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->getNonPOW2TexturesLimited()) + compensateNPOT = true; + } + else compensateNPOT = true; + + if(compensateNPOT) + { + texWidth = Bitwise::firstPO2From(width); + texHeight = Bitwise::firstPO2From(height); + } + } + + // Create the texture + texture = TextureManager::getSingleton().createManual( + name + "Texture", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + TEX_TYPE_2D, (uint)texWidth, (uint)texHeight, 0, isTransparent? PF_BYTE_BGRA : PF_BYTE_BGR, + TU_DYNAMIC_WRITE_ONLY_DISCARDABLE, this); + + HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer(); + pixelBuffer->lock(HardwareBuffer::HBL_DISCARD); + const PixelBox& pixelBox = pixelBuffer->getCurrentLock(); + texDepth = Ogre::PixelUtil::getNumElemBytes(pixelBox.format); + texPitch = (pixelBox.rowPitch*texDepth); + + uint8* pDest = static_cast<uint8*>(pixelBox.data); + + memset(pDest, 128, texHeight*texPitch); + + pixelBuffer->unlock(); + + materialName = name + "Material"; + + MaterialPtr material = MaterialManager::getSingleton().create(materialName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + Pass* matPass = material->getTechnique(0)->getPass(0); + matPass->setSceneBlending(SBT_TRANSPARENT_ALPHA); + matPass->setDepthWriteEnabled(false); + + texUnit = matPass->createTextureUnitState(name + "Texture"); + texUnit->setTextureFiltering(FO_NONE, FO_NONE, FO_NONE); + + invalidateTotally(); + + if(overlay) + { + overlay->panel->setMaterialName(materialName); + if(compensateNPOT) + overlay->panel->setUV(0, 0, (Real)width/(Real)texWidth, (Real)height/(Real)texHeight); + } +} + +void FlashControl::load(const Ogre::String& movieFilename) +{ + std::string moviePath = HikariManager::Get().basePath + movieFilename; + + FILE* file = fopen(moviePath.c_str(), "r"); + if(file) + { + fclose(file); + flashInterface->PutMovie((moviePath).c_str()); + } + else + { + OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND, "Could not load '" + moviePath + "', the file was not found.", "FlashControl::load"); + } +} + +void FlashControl::play() +{ + flashInterface->Play(); +} + +void FlashControl::stop() +{ + flashInterface->Stop(); +} + +void FlashControl::rewind() +{ + flashInterface->Rewind(); +} + +void FlashControl::gotoFrame(long frameNum) +{ + flashInterface->raw_GotoFrame(frameNum); +} + +void FlashControl::setLoop(bool shouldLoop) +{ + flashInterface->PutLoop(shouldLoop); +} + +void FlashControl::setTransparent(bool isTransparent, bool useAlphaHack) +{ + this->isTransparent = isTransparent; + if(isTransparent) + { + flashInterface->PutWMode("transparent"); + usingAlphaHack = useAlphaHack; + } + else + { + flashInterface->PutWMode("opaque"); + usingAlphaHack = false; + } + + createMaterial(); +} + +void FlashControl::setQuality(short renderQuality) +{ + switch(renderQuality) + { + case RQ_LOW: + flashInterface->PutQuality2("low"); + break; + case RQ_MEDIUM: + flashInterface->PutQuality2("medium"); + break; + case RQ_HIGH: + flashInterface->PutQuality2("high"); + break; + case RQ_BEST: + flashInterface->PutQuality2("best"); + break; + case RQ_AUTOLOW: + flashInterface->PutQuality2("autolow"); + break; + case RQ_AUTOHIGH: + flashInterface->PutQuality2("autohigh"); + break; + } +} + +void FlashControl::setScaleMode(short scaleMode) +{ + flashInterface->PutScaleMode(scaleMode); +} + +void FlashControl::setDraggable(bool isDraggable) +{ + this->isDraggable = isDraggable; +} + +void FlashControl::setIgnoreTransparentPixels(bool shouldIgnore, Ogre::Real threshold) +{ + isIgnoringTransparent = shouldIgnore; + transThreshold = threshold; +} + +const Ogre::String & FlashControl::getName() const +{ + return name; +} + +const Ogre::String & FlashControl::getMaterialName() const +{ + return materialName; +} + +void FlashControl::bind(const Ogre::DisplayString& funcName, const FlashDelegate& callback) +{ + if(funcName.empty() || callback.empty()) + return; + + delegateMap[funcName] = callback; +} + +void FlashControl::unbind(const Ogre::DisplayString& funcName) +{ + DelegateIter i = delegateMap.find(funcName); + if(i != delegateMap.end()) + delegateMap.erase(i); +} + +FlashValue FlashControl::callFunction(Ogre::DisplayString funcName, const Arguments& args) +{ + BSTR returnVal = 0; + HRESULT result = flashInterface->raw_CallFunction(_bstr_t(Impl::serializeInvocation(funcName, args).c_str()), &returnVal); + +#ifdef _DEBUG + if(FAILED(result)) + OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, + "Failed to call ActionScript function '" + funcName + "' from FlashControl '" + name + "'", + "FlashControl::callFunction"); +#endif + + return Impl::deserializeValue((wchar_t*)returnVal); +} + +void FlashControl::hide() +{ + if(overlay) + overlay->hide(); +} +void FlashControl::show() +{ + if(overlay) + overlay->show(); +} +bool FlashControl::getVisibility() const +{ + if(overlay) + return overlay->isVisible; + else + return false; +} +void FlashControl::setOpacity(Ogre::Real opacity) +{ + if(texUnit) + texUnit->setAlphaOperation(LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, 1, opacity); +} + +void FlashControl::focus() +{ + HikariManager::Get().focusControl(0, 0, this); +} + +void FlashControl::move(int deltaX, int deltaY) +{ + if(overlay) + overlay->move(deltaX, deltaY); +} + +void FlashControl::setPosition(const Position& position) +{ + if(overlay) + overlay->setPosition(position); +} + +void FlashControl::resetPosition() +{ + if(overlay) + overlay->resetPosition(); +} + +void FlashControl::getCoordinates(int& x, int& y) +{ + if(overlay) + { + x = overlay->getX(); + y = overlay->getY(); + } +} + +void FlashControl::getExtents(unsigned short &width, unsigned short &height) const +{ + width = this->width; + height = this->height; +} + +void FlashControl::getUVScale(Ogre::Real &uScale, Ogre::Real &vScale) const +{ + uScale = vScale = 1; + + if(compensateNPOT) + { + uScale = (Real)width/(Real)texWidth; + vScale = (Real)height/(Real)texHeight; + } +} + +void FlashControl::injectMouseMove(int xPos, int yPos) +{ + LRESULT result; + windowlessObject->OnWindowMessage(WM_MOUSEMOVE, 0, MAKELPARAM(xPos, yPos), &result); +} + +void FlashControl::injectMouseDown(int xPos, int yPos) +{ + LRESULT result; + windowlessObject->OnWindowMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(xPos, yPos), &result); +} + +void FlashControl::injectMouseUp(int xPos, int yPos) +{ + LRESULT result; + windowlessObject->OnWindowMessage(WM_LBUTTONUP, 0, MAKELPARAM(xPos, yPos), &result); +} + +#ifndef WM_MOUSEWHEEL +# define WM_MOUSEWHEEL 0x020A +#endif + +void FlashControl::injectMouseWheel(int relScroll, int xPos, int yPos) +{ + LRESULT result; + windowlessObject->OnWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, relScroll), MAKELPARAM(xPos, yPos), &result); +} + +bool FlashControl::isPointOverMe(int screenX, int screenY) +{ + if(!overlay) + return false; + + if(!overlay->isVisible) + return false; + + if(overlay->isWithinBounds(screenX, screenY)) + { + if(isTransparent && isIgnoringTransparent) + return renderBuffer->buffer[overlay->getRelativeY(screenY)*renderBuffer->rowSpan+overlay->getRelativeX(screenX)*4+3] > transThreshold * 255; + else + return true; + } + + return false; +} + +void FlashControl::invalidateTotally() +{ + isClean = false; + isTotallyDirty = true; + dirtyBounds.left = 0; + dirtyBounds.top = 0; + dirtyBounds.right = width; + dirtyBounds.bottom = height; +} + +void FlashControl::handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam) +{ + LRESULT aResult; + windowlessObject->OnWindowMessage(msg, wParam, lParam, &aResult); +} + +void FlashControl::handleFlashCall(const std::wstring& xmlString) +{ + std::wstring funcName; + Arguments args; + + if(!Impl::deserializeInvocation(xmlString, funcName, args)) + return; + + DelegateIter i = delegateMap.find(funcName); + if(i != delegateMap.end()) + { + FlashValue retval = i->second(this, args); + flashInterface->SetReturnValue(Impl::serializeValue(retval).c_str()); + } +} + +void FlashControl::update() +{ + if(isClean) + return; + + if(overlay) + if(!overlay->isVisible) + return; + + int dirtyWidth = dirtyBounds.right - dirtyBounds.left; + int dirtyHeight = dirtyBounds.bottom - dirtyBounds.top; + int dirtyBufSize = dirtyWidth * dirtyHeight * 4; + + IViewObject* curView = 0; + flashInterface->QueryInterface(IID_IViewObject, (void**)&curView); + + if(!oleObject || !curView) + return; + + if(!mainContext || dirtyWidth != lastDirtyWidth || dirtyHeight != lastDirtyHeight) + { + if(mainContext) + { + DeleteDC(mainContext); + mainContext = 0; + } + if(mainBitmap) + { + DeleteObject(mainBitmap); + mainBitmap = 0; + } + + lastDirtyWidth = dirtyWidth; + lastDirtyHeight = dirtyHeight; + + HDC hdc = GetDC(0); + BITMAPINFOHEADER bih = {0}; + bih.biSize = sizeof(BITMAPINFOHEADER); + bih.biBitCount = 32; + bih.biCompression = BI_RGB; + bih.biPlanes = 1; + bih.biWidth = dirtyWidth; + bih.biHeight = -dirtyHeight; + mainContext = CreateCompatibleDC(hdc); + mainBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&mainBuffer, 0, 0); + SelectObject(mainContext, mainBitmap); + + if(usingAlphaHack) + { + if(altContext) + { + DeleteDC(altContext); + altContext = 0; + } + if(altBitmap) + { + DeleteObject(altBitmap); + altBitmap = 0; + } + + altContext = CreateCompatibleDC(hdc); + altBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&altBuffer, 0, 0); + SelectObject(altContext, altBitmap); + } + + ReleaseDC(0, hdc); + } + + RECT local; + local.left = -dirtyBounds.left; + local.top = -dirtyBounds.top; + local.right = local.left + dirtyBounds.right; + local.bottom = local.top + dirtyBounds.bottom; + + if(!usingAlphaHack) + { + memset(mainBuffer, 0, dirtyBufSize); + + HRESULT hr = OleDraw(curView, DVASPECT_TRANSPARENT, mainContext, &local); + } + else + { + memset(mainBuffer, 0, dirtyBufSize); + memset(altBuffer, 255, dirtyBufSize); + + OleDraw(curView, DVASPECT_TRANSPARENT, mainContext, &local); + OleDraw(curView, DVASPECT_TRANSPARENT, altContext, &local); + + // We've rendered the dirty area twice: once on black and once + // on white. Now we compare the red channels of each to determine + // the alpha value of each pixel. + BYTE *blackBuffer, *whiteBuffer; + blackBuffer = mainBuffer; + whiteBuffer = altBuffer; + BYTE blackRed, whiteRed; + int size = dirtyWidth * dirtyHeight; + for(int i = 0; i < size; i++) + { + blackRed = *blackBuffer; + whiteRed = *whiteBuffer; + blackBuffer += 3; + whiteBuffer += 4; + *blackBuffer++ = 255 - (whiteRed - blackRed); + } + } + + renderBuffer->copyArea(dirtyBounds, mainBuffer, dirtyWidth * 4); + + HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer(); + pixelBuffer->lock(HardwareBuffer::HBL_DISCARD); + const PixelBox& pixelBox = pixelBuffer->getCurrentLock(); + + uint8* destBuffer = static_cast<uint8*>(pixelBox.data); + + renderBuffer->blitBGR(destBuffer, (int)texPitch, (int)texDepth); + + pixelBuffer->unlock(); + + isClean = true; + isTotallyDirty = false; +} + +void FlashControl::loadResource(Ogre::Resource* resource) +{ + Texture *tex = static_cast<Texture*>(resource); + + tex->setTextureType(TEX_TYPE_2D); + tex->setWidth(texWidth); + tex->setHeight(texHeight); + tex->setNumMipmaps(0); + tex->setFormat(isTransparent? PF_BYTE_BGRA : PF_BYTE_BGR); + tex->setUsage(TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); + tex->createInternalResources(); + + invalidateTotally(); +} \ No newline at end of file Added: trunk/python-ogre/ThirdParty/Hikari/FlashControl.h =================================================================== --- trunk/python-ogre/ThirdParty/Hikari/FlashControl.h (rev 0) +++ trunk/python-ogre/ThirdParty/Hikari/FlashControl.h 2008-10-27 12:54:04 UTC (rev 776) @@ -0,0 +1,398 @@ +/* + This file is part of Hikari, a library that allows developers + to use Flash in their Ogre3D applications. + + Copyright (C) 2008 Adam J. Simmons + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __FlashControl_H__ +#define __FlashControl_H__ + +#include "Position.h" +#include <windows.h> +#include "Ogre.h" +#include "Delegate.h" + +namespace ShockwaveFlashObjects { struct IShockwaveFlash; } +struct IOleObject; +class IOleInPlaceObjectWindowless; + +namespace Hikari { + +namespace Impl { + class FlashSite; + class FlashHandler; + class RenderBuffer; + class ViewportOverlay; +} + +/** +* Used by FlashControl::setQuality, defines the Flash rendering quality. +* +* <ul> +* <li>RQ_LOW - Favors playback speed over appearance and never uses anti-aliasing. +* <li>RQ_MEDIUM - Applies some anti-aliasing and does not smooth bitmaps. It produces a better quality than the Low setting, but lower quality than the High setting. +* <li>RQ_HIGH - Favors appearance over playback speed and always applies anti-aliasing. If the movie does not contain animation, bitmaps are smoothed; if the movie has animation, bitmaps are not smoothed. +* <li>RQ_BEST - Provides the best display quality and does not consider playback speed. All output is anti-aliased and all bitmaps are smoothed. +* <li>RQ_AUTOLOW - Emphasizes speed at first but improves appearance whenever possible. Playback begins with anti-aliasing turned off. If the Flash Player detects that the processor can handle it, anti-aliasing is turned on. +* <li>RQ_AUTOHIGH - Emphasizes playback speed and appearance equally at first but sacrifices appearance for playback speed if necessary. Playback begins with anti-aliasing turned on. If the actual frame rate drops below the specified frame rate, anti-aliasing is turned off to improve playback speed. +* </ul> +*/ +enum RenderQuality +{ + RQ_LOW, + RQ_MEDIUM, + RQ_HIGH, + RQ_BEST, + RQ_AUTOLOW, + RQ_AUTOHIGH +}; + +/** +* Used by FlashControl::setScaleMode, defines the scaling mode to use when the aspect ratio of the control does not match that of the movie. +* +* <ul> +* <li>SM_SHOWALL - Preserves the movie's aspect ratio by adding borders. (Default) +* <li>SM_NOBORDER - Preserves the movie's aspect ratio by cropping the sides. +* <li>SM_EXACTFIT - Does not preserve the movie's aspect ratio, scales the movie to the dimensions of the control. +*/ +enum ScaleMode +{ + SM_SHOWALL, + SM_NOBORDER, + SM_EXACTFIT +}; + +/** +* The FlashControl class is an instance of the Flash Player that is rendered dynamically to a texture and +* wrapped in an optional movable overlay using the Ogre3D engine. +*/ +class _HikariExport FlashControl : public Ogre::ManualResourceLoader +{ + friend class Impl::FlashSite; + friend class Impl::FlashHandler; + friend class HikariManager; +protected: + Impl::FlashSite* site; + Impl::FlashHandler* handler; + ShockwaveFlashObjects::IShockwaveFlash* flashInterface; + IOleObject* oleObject; + IOleInPlaceObjectWindowless* windowlessObject; + + Ogre::String name; + int width, height; + int state; + int comCount; + HDC mainContext, altContext; + HBITMAP mainBitmap, altBitmap; + BYTE *mainBuffer, *altBuffer; + Impl::RenderBuffer* renderBuffer; + bool usingAlphaHack; + RECT dirtyBounds; + int lastDirtyWidth, lastDirtyHeight; + bool isClean, isTotallyDirty; + + Impl::ViewportOverlay* overlay; + size_t texWidth, texHeight, texDepth, texPitch; + Ogre::TexturePtr texture; + Ogre::TextureUnitState* texUnit; + Ogre::String materialName; + bool compensateNPOT; + bool isTransparent; + bool isDraggable; + bool isIgnoringTransparent; + Ogre::Real transThreshold; + + typedef std::map<Ogre::DisplayString, FlashDelegate> DelegateMap; + typedef DelegateMap::iterator DelegateIter; + DelegateMap delegateMap; + bool okayToDelete; + + void createControl(); + void createMaterial(); + bool isPointOverMe(int screenX, int screenY); + void invalidateTotally(); + void handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam); + void handleFlashCall(const std::wstring& xmlString); + void update(); + + FlashControl(const Ogre::String& name, Ogre::Viewport* viewport, int width, int height, const Position& position, Ogre::uchar zOrder, Ogre::uchar tier); + FlashControl(const Ogre::String& name, int width, int height); + +public: + ~FlashControl(); + + /** + * Loads a movie (a .swf file) into this FlashControl and begins playing. + * + * @param movieFilename The filename of the movie to load. + * + * @note The specified movie should reside in the "assetsDirectory" that + * was declared when the HikariManager was instantiated. + */ + void load(const Ogre::String& movieFilename); + + /** + * Plays the currently-loaded movie. + */ + void play(); + + /** + * Stops the currently-loaded movie. + */ + void stop(); + + /** + * Rewinds the currently-loaded movie to the beginning. + */ + void rewind(); + + /** + * Navigates the currently-loaded movie to a certain frame and stops there. + */ + void gotoFrame(long frameNum); + + /** + * Sets whether or not the currently-loaded movie should restart when + * it reaches the end. + * + * @param shouldLoop Whether the currently-loaded movie should loop. + */ + void setLoop(bool shouldLoop); + + /** + * Sets whether or not the currently-loaded movie should use a + * transparent background instead of the default background-color. + * + * @param isTransparent Whether or not the movie should use "transparent" rendering. + * @param useAlphaHack With some Flash versions, there are certain glitches with + * transparent rendering (usually with text and aliased geometry). + * Set this parameter to 'true' to use an alternative alpha-rendering + * hack that may mitigate these issues at the cost of some performance. + */ + void setTransparent(bool isTransparent, bool useAlphaHack = false); + + /** + * Sets the Flash rendering quality for the currently-loaded movie. + * + * @param renderQuality The RenderQuality to use. + */ + void setQuality(short renderQuality); + + /** + * Sets the scaling mode to use when the aspect ratio of the movie and control do not match. + * + * @param scaleMode The ScaleMode to use. + */ + void setScaleMode(short scaleMode); + + /** + * Sets whether this FlashControl is draggable via the right-mouse-button, + * this is only applicable to FlashControls created as an overlay. + * + * @param isDraggable Whether or not this FlashControl should be draggable. + */ + void setDraggable(bool isDraggable); + + /** + * Sets whether or not mouse-clicks over transparent pixels should be ignored (this is on by default), + * this is only applicable to transparent FlashControls created as an overlay. + * + * @param shouldIgnore Whether or not transparent pixels should be ignored. + * @param threshold The opacity threshold (in percent, 0 to 1.0), pixels with + * opacities less than this amount will be ignored. + */ + void setIgnoreTransparentPixels(bool shouldIgnore, Ogre::Real threshold = 0.04); + + /** + * Returns the name of this FlashControl. + */ + const Ogre::String & getName() const; + + /** + * Retrieves the name of the Ogre::Material used by this FlashControl. + */ + const Ogre::String & getMaterialName() const; + + /** + * Binds a local callback to a certain function name so that your Flash movie can call the function + * from ActionScript using ExternalInterface.call('functionName'). + * + * @param funcName The name to bind this callback to. + * @param callback The local function to call, see below for examples of declaring a FlashDelegate. + * + * \code + * // Example declaration of a compatible function (static function): + * FlashValue myStaticFunction(FlashControl* caller, const Arguments& args) + * { + * // Handle the callback here + * return FLASH_VOID; + * } + * + * // Example declaration of a compatible function (member function): + * FlashValue MyClass::myMemberFunction(FlashControl* caller, const Arguments& args) + * { + * // Handle the callback here + * return "Some return value!"; + * } + * + * // FlashDelegate (member function) instantiation: + * FlashDelegate callback(this, &MyClass::myMemberFunction); // within a class + * FlashDelegate callback2(pointerToClassInstance, &MyClass::myMemberFunction); + * + * // FlashDelegate (static function) instantiation: + * FlashDelegate callback(&myStaticFunction); + * \endcode + */ + void bind(const Ogre::DisplayString& funcName, const FlashDelegate& callback); + + /** + * Un-binds the specified callback. + * + * @param funcName The name that the callback was bound to. + */ + void unbind(const Ogre::DisplayString& funcName); + + /** + * Attempts to call a function declared as a callback in the ActionScript of the currently-loaded movie. + * + * @param funcName The name of the callback that was declared using 'ExternalInterface.addCallback(funcName, function)' + * in the ActionScript of the currently-loaded movie. + * @param args The arguments to pass to the ActionScript function. + * + * @return If the invocation was successful and the ActionScript function returned a value, returns a FlashValue with a non-null type. + * + * @note It is highly recommended to use the 'Args(arg1)(arg2)(arg3)...' helper class to pass arguments. + */ + FlashValue callFunction(Ogre::DisplayString funcName, const Arguments& args = Args()); + + /** + * If this FlashControl was created as an overlay, hides the overlay. + */ + void hide(); + + /** + * If this FlashControl was created as an overlay, shows the overlay. + */ + void show(); + + /** + * Returns whether or not the FlashControl overlay is currently visible. (See FlashControl::hide and FlashControl::show) + * If this FlashControl was not created as an overlay, always returns false. + */ + bool getVisibility() const; + + /** + * Sets the opacity of this FlashControl. + * + * @param opacity The opacity as a Real value; 0 is totally transparent, 1 is totally opaque. + */ + void setOpacity(Ogre::Real opacity); + + /** + * Gives this FlashControl keyboard focus. Additionally, if this FlashControl is an overlay, pops it to the front. + */ + void focus(); + + /** + * If this FlashControl was created as an overlay, moves the overlay in relative amounts. + * + * @param deltaX The amount (in pixels) to move the overlay in the X-axis. + * @param deltaY The amount (in pixels) to move the overlay in the Y-axis. + */ + void move(int deltaX, int deltaY); + + /** + * Changes the current position and sets it as the default. Only applicable if this FlashControl was created as an overlay. + * + * @param position The new position. + */ + void setPosition(const Position& position); + + /** + * Resets the current position to the default. Only applicable if this FlashControl was created as an overlay. + */ + void resetPosition(); + + /** + * Retrieves the current screen coordinates (in relation to the render-window) of the overlay. Only applicable if this + * FlashControl was created as an overlay. + * + * @param[out] x The integer to store the current x-coordinate in. + * @param[out] y The integer to store the current y-coordinate in. + */ + void getCoordinates(int& x, int& y); + + /** + * Retrieves the width and height that this FlashControl was created with. + * + * @param[out] width The unsigned short that will be used to store the retrieved width. + * + * @param[out] height The unsigned short that will be used to store the retrieved height. + */ + void getExtents(unsigned short &width, unsigned short &height) const; + + /** + * Gets the UV scale of this FlashControl's internal texture. On certain systems we must compensate for lack of + * NPOT-support on the videocard by using the next-highest POT texture. Normally, FlashControl overlays compensate + * their texture coordinates automatically however FlashControls created as pure materials will need to adjust + * their own by use of this function. + * + * @param[out] uScale The Ogre::Real that will be used to store the retrieved U-scale. + * @param[out] vScale The Ogre::Real that will be used to store the retrieved V-scale. + */ + void getUVScale(Ogre::Real &uScale, Ogre::Real &vScale) const; + + /** + * Injects a mouse-move event into this FlashControl (in the control's local coordinate-space). + * + * @param xPos The local X-coordinate. + * @param yPos The local Y-coordinate. + */ + void injectMouseMove(int xPos, int yPos); + + /** + * Injects a mouse-down event into this FlashControl (in the control's local coordinate-space). + * + * @param xPos The local X-coordinate. + * @param yPos The local Y-coordinate. + */ + void injectMouseDown(int xPos, int yPos); + + /** + * Injects a mouse-up event into this FlashControl (in the control's local coordinate-space). + * + * @param xPos The local X-coordinate. + * @param yPos The local Y-coordinate. + */ + void injectMouseUp(int xPos, int yPos); + + /** + * Injects a mouse-wheel event into this FlashControl (in the control's local coordinate-space). + * + * @param relScroll The relative scroll amount of the mouse-wheel. + * @param xPos The local X-coordinate of the mouse. + * @param yPos The local Y-coordinate of the mouse. + */ + void injectMouseWheel(int relScroll, int xPos, int yPos); + + void loadResource(Ogre::Resource* res... [truncated message content] |