diff --git a/dependencies/scripts/android/android-boost_gil_extension.config b/dependencies/scripts/android/android-boost_gil_extension.config deleted file mode 100644 --- a/dependencies/scripts/android/android-boost_gil_extension.config +++ /dev/null @@ -1,3 +0,0 @@ -ONLY_SETUP=1 -# Copy the files here. -cp -v -R boost $ECHO_LIB_DIR/include diff --git a/dependencies/scripts/linux/linux-boost.config b/dependencies/scripts/linux/linux-boost.config --- a/dependencies/scripts/linux/linux-boost.config +++ b/dependencies/scripts/linux/linux-boost.config @@ -1,2 +1,22 @@ -#Skipping boost because it is available in the repositories and we do not need a specific version. +source "$ECHO_DEP_SCRIPTS_DIR/$ECHO_PLATFORM/linux.config" +#Skip boost as we will build using bjam here. ONLY_SETUP=1 + +chmod +x bootstrap.sh +./bootstrap.sh --prefix=$ECHO_LIB_DIR --without-libraries=python,mpi +./bjam -q \ + target-os=linux \ + toolset=gcc \ + link=shared \ + threading=multi \ + --layout=system \ + --prefix=$ECHO_LIB_DIR \ + --with-date_time \ + --with-filesystem \ + --with-chrono \ + --with-random \ + --with-regex \ + --with-system \ + --with-thread \ + --with-timer \ + install 2>&1 diff --git a/dependencies/scripts/linux/linux-boost_gil_extension.config b/dependencies/scripts/linux/linux-boost_gil_extension.config deleted file mode 100644 --- a/dependencies/scripts/linux/linux-boost_gil_extension.config +++ /dev/null @@ -1,3 +0,0 @@ -ONLY_SETUP=1 -# Copy the files here. -cp -v -R boost $ECHO_LIB_DIR/include diff --git a/dependencies/scripts/wii/wii-boost_gil_extension.config b/dependencies/scripts/wii/wii-boost_gil_extension.config deleted file mode 100644 --- a/dependencies/scripts/wii/wii-boost_gil_extension.config +++ /dev/null @@ -1,3 +0,0 @@ -ONLY_SETUP=1 -# Copy the files here. -cp -v -R boost $ECHO_LIB_DIR/include diff --git a/dependencies/scripts/windows/windows-boost_gil_extension.config b/dependencies/scripts/windows/windows-boost_gil_extension.config deleted file mode 100644 --- a/dependencies/scripts/windows/windows-boost_gil_extension.config +++ /dev/null @@ -1,3 +0,0 @@ -ONLY_SETUP=1 -# Copy the files here. -cp -v -R boost $ECHO_LIB_DIR/include diff --git a/dependencies/scripts/windowscross/windowscross-boost_gil_extension.config b/dependencies/scripts/windowscross/windowscross-boost_gil_extension.config deleted file mode 100644 --- a/dependencies/scripts/windowscross/windowscross-boost_gil_extension.config +++ /dev/null @@ -1,3 +0,0 @@ -ONLY_SETUP=1 -# Copy the files here. -cp -v -R boost $ECHO_LIB_DIR/include diff --git a/include/echo/Types.h b/include/echo/Types.h --- a/include/echo/Types.h +++ b/include/echo/Types.h @@ -1,165 +1,165 @@ #ifndef _ECHO_TYPES_H_ #define _ECHO_TYPES_H_ #ifndef BOOST_VERSION #include // If this include path is not found, install Boost using the instructions below. #endif #ifndef BOOST_VERSION #error Please install the Boost C++ libraries. Refer to instructions here: \ developer.emblem.net.au/w/technical_documents/installing_or_upgrading_boost/ #else #define ECHO_MINIMUM_SUPPORTED_BOOST_VERSION 104700 #if BOOST_VERSION < ECHO_MINIMUM_SUPPORTED_BOOST_VERSION #error Please update the Boost C++ libraries to a newer version. Refer to instructions here: \ developer.emblem.net.au/w/technical_documents/installing_or_upgrading_boost/ #endif #endif -#include +#include -#ifdef BOOST_BIG_ENDIAN +#ifdef BOOST_ENDIAN_BIG_BYTE #define ECHO_BIG_ENDIAN #define ECHO_ENDIAN_DETECTED #endif -#ifdef BOOST_LITTLE_ENDIAN +#ifdef BOOST_ENDIAN_LITTLE_BYTE #define ECHO_LITTLE_ENDIAN #define ECHO_ENDIAN_DETECTED #endif #define ECHO_BYTE_ORDER BOOST_BYTE_ORDER #if defined(ECHO_PLATFORM_NINTENDO_GAMECUBE) || defined(ECHO_PLATFORM_NINTENDO_WII) #include #endif #include namespace Echo { //-------------------------------------------- typedef boost::uint8_t u8; typedef boost::uint16_t u16; typedef boost::uint32_t u32; typedef boost::uint64_t u64; typedef boost::int8_t s8; typedef boost::int16_t s16; typedef boost::int32_t s32; typedef boost::int64_t s64; typedef float f32; typedef double f64; } #ifndef ECHO_ENDIAN_DETECTED #error Could not determine platform endian format. Please define ECHO_BIG_ENDIAN or ECHO_LITTLE_ENDIAN on the commandline. #endif namespace Echo { typedef size_t Size; typedef f32 Real; typedef f32 Scalar; typedef u32 UTF32Code; typedef u16 UTF16Code; } //This file should be included for everything so it is an ideal place to add some simple C++11 support // of classes, keywords and identifiers for use in ancient C++. // Microsoft C++ compiler versions which support C++11 don't have the right value for __cplusplus #if (defined(_MSC_VER) && _MSC_VER >= 1700) #ifdef __cplusplus #undef __cplusplus #define __cplusplus 201103L #endif #endif #if (__cplusplus > 199711L) // C++ ISO/IEC 14882:2011 supported by the compiler ("C++11") #define if_cplusplus11(x) x #include namespace Echo { using std::unique_ptr; using std::shared_ptr; using std::weak_ptr; using std::make_shared; using std::dynamic_pointer_cast; using std::static_pointer_cast; using std::enable_shared_from_this; } #else // C++ ISO/IEC 14882:1998 supported by the compiler (hopefully) #define ECHO_USE_BOOST_FOR_STANDARDS #include #include #include #include #include namespace Echo { using boost::shared_ptr; using boost::weak_ptr; using boost::make_shared; using boost::dynamic_pointer_cast; using boost::static_pointer_cast; using boost::enable_shared_from_this; } #define if_cplusplus11(x) // Placeholder for http://en.cppreference.com/w/cpp/language/final #ifndef final //#define final // breaks boost #endif // Placeholder for http://en.cppreference.com/w/cpp/language/override #ifndef override #define override #endif namespace Echo { // Placeholder for http://en.cppreference.com/w/cpp/language/nullptr // from http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr const class nullptr_t { public: template inline operator T*(void) const { return 0; } template inline operator T C::*(void) const { return 0; } // nullptr_t support for boost::shared_ptr in lieu of std::shared_ptr template inline operator shared_ptr(void) const { return shared_ptr(); } private: void operator &(void) const; } nullptr = {}; } #endif #ifndef overload #define overload #endif #if defined(ECHO_PLATFORM_WINDOWS) #include #endif #include #include #endif diff --git a/nbproject/Package-Debug.bash b/nbproject/Package-Debug.bash --- a/nbproject/Package-Debug.bash +++ b/nbproject/Package-Debug.bash @@ -1,148 +1,152 @@ #!/bin/bash -x # # Generated - do not edit! # # Macros TOP=`pwd` CND_PLATFORM=GNU-Linux CND_CONF=Debug CND_DISTDIR=dist CND_BUILDDIR=build CND_DLIB_EXT=so NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging TMPDIRNAME=tmp-packaging OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libecho3.${CND_DLIB_EXT} OUTPUT_BASENAME=libecho3.${CND_DLIB_EXT} PACKAGE_TOP_DIR=libecho3.so/ # Functions function checkReturnCode { rc=$? if [ $rc != 0 ] then exit $rc fi } function makeDirectory # $1 directory path # $2 permission (optional) { mkdir -p "$1" checkReturnCode if [ "$2" != "" ] then chmod $2 "$1" checkReturnCode fi } function copyFileToTmpDir # $1 from-file path # $2 to-file path # $3 permission { cp "$1" "$2" checkReturnCode if [ "$3" != "" ] then chmod $3 "$2" checkReturnCode fi } # Setup cd "${TOP}" mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package rm -rf ${NBTMPDIR} mkdir -p ${NBTMPDIR} # Copy files and create directories and links cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 +cd "${TOP}" +makeDirectory "${NBTMPDIR}/libecho3.so/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + # Generate tar file cd "${TOP}" rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/libecho3.so.tar cd ${NBTMPDIR} tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/libecho3.so.tar * checkReturnCode # Cleanup cd "${TOP}" rm -rf ${NBTMPDIR} diff --git a/nbproject/Package-Release.bash b/nbproject/Package-Release.bash --- a/nbproject/Package-Release.bash +++ b/nbproject/Package-Release.bash @@ -1,148 +1,152 @@ #!/bin/bash -x # # Generated - do not edit! # # Macros TOP=`pwd` CND_PLATFORM=GNU-Linux CND_CONF=Release CND_DISTDIR=dist CND_BUILDDIR=build CND_DLIB_EXT=so NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging TMPDIRNAME=tmp-packaging OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libecho3.${CND_DLIB_EXT} OUTPUT_BASENAME=libecho3.${CND_DLIB_EXT} PACKAGE_TOP_DIR=libecho3.so/ # Functions function checkReturnCode { rc=$? if [ $rc != 0 ] then exit $rc fi } function makeDirectory # $1 directory path # $2 permission (optional) { mkdir -p "$1" checkReturnCode if [ "$2" != "" ] then chmod $2 "$1" checkReturnCode fi } function copyFileToTmpDir # $1 from-file path # $2 to-file path # $3 permission { cp "$1" "$2" checkReturnCode if [ "$3" != "" ] then chmod $3 "$2" checkReturnCode fi } # Setup cd "${TOP}" mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package rm -rf ${NBTMPDIR} mkdir -p ${NBTMPDIR} # Copy files and create directories and links cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 cd "${TOP}" makeDirectory "${NBTMPDIR}/libecho3.so/lib" copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 +cd "${TOP}" +makeDirectory "${NBTMPDIR}/libecho3.so/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + # Generate tar file cd "${TOP}" rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/libecho3.so.tar cd ${NBTMPDIR} tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/libecho3.so.tar * checkReturnCode # Cleanup cd "${TOP}" rm -rf ${NBTMPDIR} diff --git a/src/Network/NetworkExecutionModel.cpp b/src/Network/NetworkExecutionModel.cpp --- a/src/Network/NetworkExecutionModel.cpp +++ b/src/Network/NetworkExecutionModel.cpp @@ -1,149 +1,151 @@ #include #include #include #include #include #include #include #include namespace Echo { NetworkExecutionModel::NetworkExecutionModel(Kernel& kernel) : ExecutionModel(ExecutionModel::Models::CONTROLLER), mKernel(kernel), mUseCommandProcessing(true), mUpdateFrame(false), mUpdateFrequency(5) { SetDefaultCommandProcessorFunction(bind(&NetworkExecutionModel::DefaultCommandProcessor,this)); } NetworkExecutionModel::~NetworkExecutionModel() { } void NetworkExecutionModel::SetUseCommandProcessing(bool useCommandProcessing) { mUseCommandProcessing = useCommandProcessing; } void NetworkExecutionModel::SetUpdateFrequency(Seconds updateFrequency) { mUpdateFrequency = updateFrequency; mKernel.GetFrameRateLimiter().SetMaxFrameTime(updateFrequency); } void NetworkExecutionModel::OnNetworkEvent(NetworkEventType eventType) { mUpdateFrame = true; mUpdateCondition.notify_all(); } bool NetworkExecutionModel::SupportsModel(Models::ModelEnum model) { switch (model) { case Models::CONTROLLER: return true; case Models::EXTERNAL_CONTROLLER: case Models::COOPERATE: case Models::NONE: return false; } return false; } bool NetworkExecutionModel::ProcessEvents(f32) { return false; } bool NetworkExecutionModel::EnterSystemEventManager() { if(mUseCommandProcessing) { std::string command; std::cout << "Type 'quit' to quit" << std::endl; while(command!="quit") { std::getline(std::cin,command); if(!std::cin.good()) { // The process might be launched with a detached stdin which means cin will be bad. // If that is the case we'll sleep and check back every 10 seconds (this is just arbitrary). Thread::Sleep(Seconds(10)); } size_t space = command.find_first_of(' '); std::string parameters; if(space!=std::string::npos) { parameters = command.substr(space+1); command = command.substr(0,space); } ProcessorMap::iterator it = mProcessors.find(command); if(it!=mProcessors.end()) { it->second(parameters); }else { mDefaultCommandProcessorFunction(command,parameters); } } }else { SetupAndStartUpdateTimer(); mServiceThread=std::thread([this]{ mIOService.run(); }); bool kernelActive = true; while(kernelActive) { std::unique_lock lock(mUpdateMutex); mUpdateCondition.wait(lock, [this](){return mUpdateFrame;}); mUpdateFrame = false; kernelActive = mKernel.ProcessFrame(); } mIOService.stop(); mServiceThread.join(); } return true; } bool NetworkExecutionModel::SendUpdateRequest() { return true; } void NetworkExecutionModel::SetCommandProcessor(const std::string& command, CommandProcessorFunction func) { mProcessors[command] = func; } void NetworkExecutionModel::SetDefaultCommandProcessorFunction(DefaultCommandProcessorFunction func) { mDefaultCommandProcessorFunction = func; } void NetworkExecutionModel::DefaultCommandProcessor() { } void NetworkExecutionModel::SetupAndStartUpdateTimer() { - mUpdateTimer.reset(new boost::asio::deadline_timer(mIOService, boost::posix_time::seconds(mUpdateFrequency.count()))); + size_t ms = mUpdateFrequency.count() * 1000; + mUpdateTimer.reset(new boost::asio::deadline_timer(mIOService, boost::posix_time::milliseconds(ms))); mUpdateTimer->async_wait(bind(&NetworkExecutionModel::OnUpdateTimer,this)); } void NetworkExecutionModel::OnUpdateTimer() { if(mKernel.HasAtLeastOneTask()) { OnNetworkEvent(NetworkEventType::UNKNOWN); - mUpdateTimer->expires_at(mUpdateTimer->expires_at() + boost::posix_time::seconds(mUpdateFrequency.count())); + size_t ms = mUpdateFrequency.count() * 1000; + mUpdateTimer->expires_at(mUpdateTimer->expires_at() + boost::posix_time::milliseconds(ms)); mUpdateTimer->async_wait(bind(&NetworkExecutionModel::OnUpdateTimer,this)); } } } diff --git a/src/Util/Texture.cpp b/src/Util/Texture.cpp --- a/src/Util/Texture.cpp +++ b/src/Util/Texture.cpp @@ -1,305 +1,305 @@ #include #include -#include +#include #include #include namespace boost { namespace gil { struct luminance_t {}; typedef mpl::vector2 luminance_alpha_t; typedef layout luminance_alpha_layout_t; - GIL_DEFINE_ALL_TYPEDEFS(8,luminance_alpha) - GIL_DEFINE_ALL_TYPEDEFS(32f,luminance_alpha) + GIL_DEFINE_ALL_TYPEDEFS(8,uint8_t,luminance_alpha) + GIL_DEFINE_ALL_TYPEDEFS(32f,uint32_t,luminance_alpha) }} namespace Echo { namespace Utils { template void ResizeWithGIL(const Texture& texture, Texture& destTexture) { using namespace boost::gil; ViewType sourceData = interleaved_view(texture.GetWidth(),texture.GetHeight(),(PixelType*)texture.GetBuffer().get(),texture.GetWidth()*texture.GetBytesPerPixel()); ViewType destView = interleaved_view(destTexture.GetWidth(),destTexture.GetHeight(),(PixelType*)destTexture.GetBuffer().get(),destTexture.GetBytesPerPixel()*destTexture.GetWidth()); resize_view(sourceData,destView, bilinear_sampler()); } template void CopyWithGIL(const Texture& texture, Texture& destTexture) { using namespace boost::gil; SourceViewType sourceData = interleaved_view(texture.GetWidth(),texture.GetHeight(),(SourcePixelType*)texture.GetBuffer().get(),texture.GetWidth()*texture.GetBytesPerPixel()); DestinationViewType destView = interleaved_view(destTexture.GetWidth(),destTexture.GetHeight(),(DestinationPixelType*)destTexture.GetBuffer().get(),destTexture.GetBytesPerPixel()*destTexture.GetWidth()); copy_pixels(sourceData,destView); } template bool CopySmallerTextureIntoLargerWithGIL(const Texture& texture, Texture& destTexture, bool centre) { if( texture.GetWidth()>destTexture.GetWidth() || texture.GetHeight()>destTexture.GetHeight()) { return false; } Size x=0; Size y=0; if(centre) { x = (destTexture.GetWidth() - texture.GetWidth()) / 2; y = (destTexture.GetHeight() - texture.GetHeight()) / 2; } using namespace boost::gil; ViewType sourceData = interleaved_view(texture.GetWidth(),texture.GetHeight(),(PixelType*)texture.GetBuffer().get(),texture.GetWidth()*texture.GetBytesPerPixel()); ViewType destView = subimage_view( interleaved_view(destTexture.GetWidth(),destTexture.GetHeight(),(PixelType*)destTexture.GetBuffer().get(),destTexture.GetBytesPerPixel()*destTexture.GetWidth()), x,y,texture.GetWidth(),texture.GetHeight()); copy_pixels(sourceData,destView); return true; } #define DEFINE_GIL_PACKED_PIXEL_16BIT_TYPES(channelFormat,layout,distribution) \ typedef boost::gil::packed_pixel_type::type layout##distribution##_pixel_t; \ typedef layout##distribution##_pixel_t* layout##distribution##_ptr_t; \ typedef boost::gil::memory_based_2d_locator > layout##distribution##_loc_t; \ typedef boost::gil::image_view layout##distribution##_view_t; using namespace boost::gil; typedef boost::mpl::vector3_c FORMAT565; DEFINE_GIL_PACKED_PIXEL_16BIT_TYPES(FORMAT565,rgb,565); typedef boost::mpl::vector4_c FORMAT5551; DEFINE_GIL_PACKED_PIXEL_16BIT_TYPES(FORMAT5551,rgba,5551); typedef boost::mpl::vector4_c FORMAT4444; DEFINE_GIL_PACKED_PIXEL_16BIT_TYPES(FORMAT4444,rgba,4444); shared_ptr CreateResizedTexture(const Texture& texture, size_t newWidth, size_t newHeight) { shared_ptr newTexture(new Texture(newWidth,newHeight,texture.GetFormat())); switch(texture.GetFormat()) { case Texture::Formats::R8G8B8A8: case Texture::Formats::R8G8B8X8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::R8G8B8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::R5G6B5: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::R5G5B5A1: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::R4G4B4A4: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::B8G8R8A8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::B8G8R8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE8_ALPHA8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE8: case Texture::Formats::GREYSCALE8: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::GREYSCALE16: { ResizeWithGIL(texture,*newTexture); }break; case Texture::Formats::UNKNOWN: default: newTexture.reset(); break; } return newTexture; } shared_ptr CreateFloatTexture(const Texture& texture) { Texture::Format format = Texture::Formats::HasAlpha(texture.GetFormat()) ? Texture::Formats::RGBA_F32 : Texture::Formats::RGB_F32; shared_ptr newTexture(new Texture(texture.GetWidth(),texture.GetHeight(),format)); switch(texture.GetFormat()) { case Texture::Formats::R8G8B8A8: case Texture::Formats::R8G8B8X8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::R8G8B8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::R5G6B5: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::R5G5B5A1: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::R4G4B4A4: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::B8G8R8A8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::B8G8R8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE8_ALPHA8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE32_ALPHA32: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::LUMINANCE32: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::RGBA_F32: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::RGB_F32: { CopyWithGIL(texture,*newTexture); } case Texture::Formats::GREYSCALE8: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::GREYSCALE16: { CopyWithGIL(texture,*newTexture); }break; case Texture::Formats::UNKNOWN: default: newTexture.reset(); break; } return newTexture; } shared_ptr CreatePaddedTexture(const Texture& texture, Size newWidth, Size newHeight, bool centre) { if(texture.GetWidth()>=newWidth && texture.GetHeight()>=newHeight) { return nullptr; } // We can create a new texture. shared_ptr newTexture(new Texture(newWidth,newHeight,texture.GetFormat())); ZeroTexture(*newTexture); bool copyResult=false; switch(texture.GetFormat()) { case Texture::Formats::R8G8B8A8: case Texture::Formats::R8G8B8X8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::R8G8B8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::R5G6B5: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::R5G5B5A1: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::R4G4B4A4: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::B8G8R8A8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::B8G8R8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::LUMINANCE8_ALPHA8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::LUMINANCE8: case Texture::Formats::GREYSCALE8: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::GREYSCALE16: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::LUMINANCE32_ALPHA32: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::LUMINANCE32: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::RGBA_F32: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::RGB_F32: { copyResult = CopySmallerTextureIntoLargerWithGIL(texture,*newTexture,centre); }break; case Texture::Formats::UNKNOWN: default: break; } if(!copyResult) { newTexture.reset(); } return newTexture; } bool ZeroTexture(Texture& texture) { // Fill with zeros. u8* buffer=texture.GetBuffer().get(); if(!buffer) { return false; } Size bufferSize=texture.GetDataSize(); for(Size i=0;i