bool CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage ) {GUCEF_TRACE; CEGUI::Window* rootWindow = NULL; CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr(); GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" ); try { CORE::CDynamicBuffer memBuffer( layoutStorage ); CEGUI::RawDataContainer container; container.setData( (CEGUI::uint8*) memBuffer.GetBufferPtr() ); container.setSize( (size_t) memBuffer.GetDataSize() ); rootWindow = wmgr->loadLayoutFromContainer( container ); container.setData( (CEGUI::uint8*) NULL ); container.setSize( (size_t) 0 ); } catch ( CEGUI::Exception& e ) { GUCEF_ERROR_LOG( 0, CString( "CEGUI Exception while attempting to load form layout: " ) + e.what() ); return false; } // Now that we completed loading lets see what we got from CEGUI if ( NULL != rootWindow ) { // Begin by providing a wrapper for the root window m_rootWindow = CreateAndHookWrapperForWindow( rootWindow ); if ( NULL != m_rootWindow ) { CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false ); m_widgetMap[ localWidgetName ] = m_rootWindow; WrapAndHookChildWindows( rootWindow ); // We will directly add the form as a child of the root for now // Note: This assumes that you have a GUISheet already set, otherwise this will result in a segfault! CEGUI::Window* globalRootWindow = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow(); if ( NULL != globalRootWindow ) { globalRootWindow->addChild( rootWindow ); GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" ); return true; } else { GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" ); } } rootWindow->hide(); } GUCEF_DEBUG_LOG( 0, "Failed to load a GUI Form layout" ); return false; }
bool CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage ) {GUCE_TRACE; CEGUI::Window* rootWindow = NULL; CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr(); GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" ); try { // provide hacky access to the given data m_dummyArchive->AddResource( layoutStorage, "currentFile" ); // Now we can load the window layout from the given storage // Note that if CEGUI ever provides an interface to do this directly // clean up this mess !!! rootWindow = wmgr->loadWindowLayout( "currentFile" , m_widgetNamePrefix.C_String() , m_resourceGroupName.C_String() ); m_dummyArchive->ClearResourceList(); } catch ( Ogre::Exception& e ) { GUCEF_ERROR_LOG( 0, CString( "Ogre Exception while attempting to load form layout: " ) + e.getFullDescription().c_str() ); return false; } // Now that we completed loading lets see what we got from CEGUI if ( NULL != rootWindow ) { // Begin by providing a wrapper for the root window m_rootWindow = CreateAndHookWrapperForWindow( rootWindow ); if ( NULL != m_rootWindow ) { CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false ); m_widgetMap[ localWidgetName ] = m_rootWindow; WrapAndHookChildWindows( rootWindow ); // We will directly add the form as a child of the root for now CEGUI::Window* globalRootWindow = wmgr->getWindow( "root" ); if ( NULL != globalRootWindow ) { globalRootWindow->addChildWindow( rootWindow ); GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" ); return true; } else { GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" ); } } rootWindow->hide(); } GUCEF_DEBUG_LOG( 0, "Failed to loaded a GUI Form layout" ); return false; }
bool CreateAndroidMakefileOnDiskForEachModule( const TModuleInfoEntryPairVector& mergeLinks , bool addGeneratorCompileTimeToOutput , TStringSet& ndkModulesUsed ) {GUCEF_TRACE; TModuleInfoEntryPairVector::const_iterator i = mergeLinks.begin(); while ( i != mergeLinks.end() ) { const TModuleInfoEntry& moduleInfoEntry = (*(*i).first); const TModuleInfo& moduleInfo = (*(*i).second); if ( !CreateAndroidMakefileOnDiskForModule( mergeLinks , moduleInfo , moduleInfoEntry.rootDir , addGeneratorCompileTimeToOutput , ndkModulesUsed ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Failed to create an Android makefile for all modules because of the following module " + moduleInfo.name ); return false; } ++i; } return true; }
void CLogSvcServer::OnClientConnectionDataReceived( CORE::CNotifier* notifier , const CORE::CEvent& eventid , CORE::CICloneable* eventdata ) {GUCEF_TRACE; // Get access to the event data COMCORE::CTCPServerConnection::TDataRecievedEventData* eData = static_cast< COMCORE::CTCPServerConnection::TDataRecievedEventData* >( eventdata ); const CORE::CDynamicBuffer& buffer = eData->GetData(); // Get access to the connection object & client info COMCORE::CTCPServerConnection* connection = static_cast< COMCORE::CTCPServerConnection* >( notifier ); TClientInfo& clientInfo = m_clientInfoMap[ connection->GetConnectionIndex() ]; // Handle the tcp stream, take into account message concatonation // First we copy the data recieved into our recieve buffer where we // can properly segment data because we retain whatever data we need if ( !( buffer.GetDataSize() == clientInfo.receiveBuffer.Write( buffer, 0 ) ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to write all data recieved into a receive buffer for processsing" ); } // Use the received data as a trigger to process whatever we can on this connection ProcessReceivedData( clientInfo , connection ); }
void VfsResourceProvider::loadRawDataContainer( const CEGUI::String& filename , CEGUI::RawDataContainer& output , const CEGUI::String& resourceGroup ) {GUCEF_TRACE; // everything in CEGUI works based on resource groups // make sure we dont use an empty one const CEGUI::String* rscGroup = &resourceGroup; if ( resourceGroup.empty() ) { rscGroup = &m_defaultResourceGroup; } CORE::CString filePath; CORE::CString fileName = filename; TCEStringMap::iterator i = m_groupMap.find( *rscGroup ); if ( i != m_groupMap.end() ) { filePath = (*i).second; } filePath = CORE::CombinePath( filePath, fileName ); VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); VFS::CVFS::CVFSHandlePtr file = vfs.GetFile( filePath, "rb", false ); if ( !file.IsNULL() ) { CORE::CIOAccess* fileAccess = file->GetAccess(); if ( NULL != fileAccess ) { CORE::CDynamicBuffer memBuffer( *fileAccess ); void* buffer = NULL; UInt32 dataSize = 0; memBuffer.RelinquishDataOwnership( buffer, dataSize ); output.setData( (CEGUI::uint8*) buffer ); output.setSize( dataSize ); DataContainerInfoPtr info = new TDataContainerInfo; info->fileHandle = file; info->requestFilename = fileName; info->requestresourceGroup = resourceGroup; info->ceContainer = output; m_containerMap[ buffer ] = info; } else { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VfsResourceProvider:loadRawDataContainer: Unable to load resource from path: " + filePath ); } } }
bool CreateAndroidMakefileOnDiskForModule( const TModuleInfoEntryPairVector& mergeLinks , const TModuleInfo& moduleInfo , const CORE::CString& moduleRoot , bool addGeneratorCompileTimeToOutput , TStringSet& ndkModulesUsed ) {GUCEF_TRACE; if ( ( MODULETYPE_HEADER_INCLUDE_LOCATION == moduleInfo.moduleType ) || ( MODULETYPE_HEADER_INTEGRATE_LOCATION == moduleInfo.moduleType ) || ( MODULETYPE_CODE_INTEGRATE_LOCATION == moduleInfo.moduleType ) ) { // this module type does not require processing here return true; } GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Generating Android makefile content for module " + moduleInfo.name ); // First we generate the content for the makefile based on the given module information CORE::CString makefileContent = GenerateContentForAndroidMakefile( mergeLinks , moduleInfo , moduleRoot , addGeneratorCompileTimeToOutput , ndkModulesUsed ); // Now we write the makefile to the root location of the module since everything is relative to that CORE::CString makefilePath = moduleRoot; CORE::AppendToPath( makefilePath, "Android.mk" ); // Do not change the file on disk unless we have to. // the NDK build system will rebuild if the timestamp on the file changed which can take a long time if ( DidMakefileContentChange( makefilePath, makefileContent ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Writing Android makefile content for module " + moduleInfo.name + " to " + makefilePath ); if ( CORE::WriteStringAsTextFile( makefilePath , makefileContent , true , "\n" ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Successfully created Android makefile for module " + moduleInfo.name + " at " + makefilePath ); return true; } GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Failed to create an Android makefile for module " + moduleInfo.name + " at " + makefilePath ); return false; } else { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Skipping creation of Android makefile for module " + moduleInfo.name + " at " + makefilePath + " since there already is a makefile with identical content" ); return true; } }
bool COgrePluginAdapter::Link( void* modulePtr , CORE::TPluginMetaDataPtr pluginMetaData ) {GUCEF_TRACE; if ( IsLoaded() ) return false; m_moduleHandle = modulePtr; if ( NULL != m_moduleHandle ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "COgrePluginAdapter: Linking API using module pointer: " + CORE::PointerToString( modulePtr ) ); // We have now successfully loaded the module itself // We will now try to lookup the function pointers m_funcPointers[ OGREPLUGINFUNCPTR_STARTPLUGIN ] = CORE::GetFunctionAddress( m_moduleHandle , "dllStartPlugin" , 0 ).funcPtr; m_funcPointers[ OGREPLUGINFUNCPTR_STOPPLUGIN ] = CORE::GetFunctionAddress( m_moduleHandle , "dllStopPlugin" , 0 ).funcPtr; // Verify that all function pointers are loaded correctly if ( ( NULL != m_funcPointers[ OGREPLUGINFUNCPTR_STARTPLUGIN ] ) && ( NULL != m_funcPointers[ OGREPLUGINFUNCPTR_STOPPLUGIN ] ) ) { // Call the module's dllStartPlugin() reinterpret_cast< TOGREPLUGFPTR_StartPlugin >( m_funcPointers[ OGREPLUGINFUNCPTR_STARTPLUGIN ] )(); // We have loaded & linked our plugin module GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "COgrePluginAdapterCORE::: Successfully loaded module and invoked dllStartPlugin() using module: " + CORE::PointerToString( modulePtr ) ); // Copy the given metadata m_metaData = new CORE::CPluginMetaData( *pluginMetaData ); return true; } else { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "COgrePluginAdapter: Failed to locate the required exports in module: " + CORE::PointerToString( modulePtr ) ); } // We failed to link the functions :( memset( m_funcPointers, 0, OGREPLUGINFUNCPTR_COUNT ); m_moduleHandle = NULL; return false; } // Unloading->Loading must be done explicitly return false; }
bool CX11Window::WindowCreate( const Int32 xPosition , const Int32 yPosition , const UInt32 width , const UInt32 height , ::Window parentWindow ) {GUCEF_TRACE; // If we already have a window destroy it WindowDestroy(); if ( NULL == m_display ) { m_display = CX11EventDispatcher::Instance()->GetDisplay(); } if ( NULL == m_display ) { GUCEF_ERROR_LOG( LOGLEVEL_IMPORTANT, "CX11Window::WindowCreate(): Failed to open display" ); return false; } m_screenNr = DefaultScreen( m_display ); if ( 0 == parentWindow ) { // no parent window was provided so we will make this window a child of the default display's root parentWindow = RootWindow( m_display, m_screenNr ); } m_window = ::XCreateSimpleWindow( m_display, parentWindow, xPosition, yPosition, width, height, 1, BlackPixel( m_display, m_screenNr ), WhitePixel( m_display, m_screenNr ) ); // Subscribe to window events at the centralized dispatcher CX11EventDispatcher::Instance()->SubscribeOnBehalfOfWindow( AsObserver(), m_window ); // register interest in the delete window message // m_wmDeleteWindow = ::XInternAtom( m_display, "WM_DELETE_WINDOW", False ); // ::XSetWMProtocols( m_display, m_window, &m_wmDeleteWindow, 1 ); Show(); Repaint(); return true; }
bool CreateAndroidProjectMakefileOnDisk( const CORE::CString& projectName , const TModuleInfoEntryPairVector& mergeLinks , const CORE::CString& outputDir , bool addGeneratorCompileTimeToOutput , const TStringSet& ndkModulesUsed ) {GUCEF_TRACE; GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Generating Android makefile content for overall project file regarding project \"" + projectName + "\"" ); // First we generate the content for the makefile based on the given module information CORE::CString makefileContent = GenerateContentForAndroidProjectMakefile( projectName , mergeLinks , outputDir , addGeneratorCompileTimeToOutput , ndkModulesUsed ); // Now we write the makefile to the root location of the project since everything is relative to that CORE::CString makefilePath = outputDir; CORE::AppendToPath( makefilePath, "Android.mk" ); // Do not change the file on disk unless we have to. // the NDK build system will rebuild if the timestamp on the file changed which can take a long time if ( DidMakefileContentChange( makefilePath, makefileContent ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Writing Android makefile content for project \"" + projectName + "\" to " + makefilePath ); if ( CORE::WriteStringAsTextFile( makefilePath , makefileContent , true , "\n" ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Successfully created Android makefile for project \"" + projectName + "\" at " + makefilePath ); return true; } GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Failed to create an Android makefile for project \"" + projectName + "\" at " + makefilePath ); return false; } else { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Skipping creation of overall project Android makefile for project \"" + projectName + "\" at " + makefilePath + " since there already is a makefile with identical content" ); return true; } }
void CRefAppSubSystem::OnUpdate( const GUCEF::CORE::UInt64 tickCount , const GUCEF::CORE::Float64 updateDeltaInMilliSecs ) {GUCE_TRACE; try { if ( !Ogre::Root::getSingletonPtr()->renderOneFrame() ) { GUCE::CORE::CGUCEApplication::Instance()->Stop(); return; } } catch ( Ogre::Exception& /* e */ ) { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CRefAppSubSystem::OnUpdate(): Exception during Ogre frame rendering" ); } }
void CGUIManager::UnregisterGUIDriver( const CString& driverName ) {GUCE_TRACE; TDriverMap::iterator i = m_drivers.find( driverName ); if ( i != m_drivers.end() ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "GUCE CGUIManager: Unregistering GUI driver: " + driverName ); if ( (*i).second->Shutdown() ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "GUCE CGUIManager: GUI driver successfully shutdown. Reason: because it is being unregistered. Name: " + driverName ); } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_IMPORTANT, "GUCE CGUIManager: GUI driver failed to shutdown. Reason: Shutdown because it is being unregistered. Name: " + driverName ); } m_drivers.erase( i ); } }
bool CWin32WindowContext::Initialize( const GUI::CString& title , const GUI::CVideoSettings& videoSettings ) {GUCEF_TRACE; // Do not initialize twice Shutdown(); if ( !CORE::CMsWin32Window::RegisterWindowClass( GetClassTypeName() ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Win32WindowContext: Could not register window class" ); return false; } // First create a regular Win32 window if ( m_window.WindowCreate( GetClassTypeName() , title , 0 , 0 , videoSettings.GetResolutionWidthInPixels() , videoSettings.GetResolutionHeightInPixels() ) ) { // Display the new window m_window.Show(); m_window.SendToForegound(); m_window.GrabFocus(); // Grab the main app pulse generator and set the update interval for the context to the desired refresh rate CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator(); pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() ); SubscribeTo( &pulseGenerator ); GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "Win32WindowContext: Succesfully created Win32 window" ); return true; } return false; }
CORE::CString GenerateContentForAndroidMakefile( const TModuleInfoEntryPairVector& mergeLinks , const TModuleInfo& moduleInfo , const CORE::CString& moduleRoot , bool addGeneratorCompileTimeToOutput , TStringSet& ndkModulesUsed ) {GUCEF_TRACE; CORE::CString contentPrefix = makefileHeader; if ( addGeneratorCompileTimeToOutput ) { contentPrefix += "#" "# The project generator version used was compiled on " __TIME__ __DATE__ "\n" "#\n\n"; } contentPrefix += "ifndef MY_MODULE_PATH\n" " MY_MODULE_PATH := $(call my-dir)\n" "endif\n" "LOCAL_PATH := $(MY_MODULE_PATH)\n\n" "include $(CLEAR_VARS)\n\n" "@echo Module path: $(MY_MODULE_PATH)\n" "LOCAL_MODULE := " + moduleInfo.name + "\n"; if ( ( MODULETYPE_SHARED_LIBRARY == moduleInfo.moduleType ) || ( MODULETYPE_STATIC_LIBRARY == moduleInfo.moduleType ) ) { contentPrefix += "LOCAL_MODULE_FILENAME := lib" + moduleInfo.name + "\n"; } contentPrefix += "@echo Module name: $(LOCAL_MODULE)\n\n"; // Generate the source files section CORE::CString srcFilesSection = "LOCAL_SRC_FILES := \\\n"; bool firstLoop = true; TStringVectorMap::const_iterator i = moduleInfo.sourceDirs.begin(); while ( i != moduleInfo.sourceDirs.end() ) { const CORE::CString& srcDir = (*i).first; const TStringVector& srcFiles = (*i).second; TStringVector::const_iterator n = srcFiles.begin(); while ( n != srcFiles.end() ) { if ( !firstLoop ) { srcFilesSection += " \\\n"; } firstLoop = false; CORE::CString relFilePath = srcDir; CORE::AppendToPath( relFilePath, (*n) ); srcFilesSection += " " + relFilePath.ReplaceChar( '\\', '/' ); ++n; } ++i; } // Add some spacing for readability srcFilesSection += "\n\n"; // Generate the included files section // for android make files we only need the path // it will locate the header file on its own CORE::CString includeFilesSection = "LOCAL_C_INCLUDES := \\\n"; i = moduleInfo.includeDirs.begin(); firstLoop = true; while ( i != moduleInfo.includeDirs.end() ) { if ( !firstLoop ) { includeFilesSection += " \\\n"; } firstLoop = false; const CORE::CString& dir = (*i).first; if ( !dir.IsNULLOrEmpty() ) { includeFilesSection += " $(MY_MODULE_PATH)/" + dir.ReplaceChar( '\\', '/' ); } else { // Support the use-case where the include dir is empty because the moduleinfo dir == include dir includeFilesSection += " $(MY_MODULE_PATH)"; } ++i; } // We also need to add the include paths required to find headers // refered to because of dependencies TStringSet::const_iterator n = moduleInfo.dependencyIncludeDirs.begin(); while ( n != moduleInfo.dependencyIncludeDirs.end() ) { if ( !firstLoop ) { includeFilesSection += " \\\n"; } firstLoop = false; includeFilesSection += " $(MY_MODULE_PATH)/" + (*n).ReplaceChar( '\\', '/' ); ++n; } // Add some spacing for readability includeFilesSection += "\n\n"; // Now we add the preprocessor definitions CORE::CString preprocessorSection; if ( !moduleInfo.preprocessorSettings.defines.empty() ) { preprocessorSection = "LOCAL_CFLAGS :="; TStringSet::const_iterator m = moduleInfo.preprocessorSettings.defines.begin(); while ( m != moduleInfo.preprocessorSettings.defines.end() ) { preprocessorSection += " -D" + (*m); ++m; } // Add some spacing for readability preprocessorSection += "\n\n"; } // Now we add the compiler flags, if any // For Android we only support the GCC compilers CORE::CString compilerSection; TStringMap::const_iterator p = moduleInfo.compilerSettings.compilerFlags.find( "GCC" ); if ( p != moduleInfo.compilerSettings.compilerFlags.end() ) { compilerSection = "LOCAL_CFLAGS +=" + (*p).second + "\n\n"; } p = moduleInfo.compilerSettings.compilerFlags.find( "G++" ); if ( p != moduleInfo.compilerSettings.compilerFlags.end() ) { compilerSection = "LOCAL_CPPFLAGS +=" + (*p).second + "\n\n"; } // Now we will add all the dependency linking instructions. // For some reason it matters, at specification time, to Android's build // system whether the module you are linking to is a dynamically linked module // or a statically linked module. As such we have to figure out which is which. // // We make an alphabetical list instead of creating the section right away because // we dont want the order to vary in the makefile because such changes cause the NDK // to build the code again for no reason. CORE::CString linkingErrorSection; TStringSet linkedSharedLibraries; TStringSet linkedStaticLibraries; TStringSet linkedRuntimeLibraries; TModuleTypeMap::const_iterator m = moduleInfo.linkerSettings.linkedLibraries.begin(); while ( m != moduleInfo.linkerSettings.linkedLibraries.end() ) { const CORE::CString& linkedLibName = (*m).first; TModuleType linkedLibType = (*m).second; switch ( linkedLibType ) { case MODULETYPE_EXECUTABLE: { // This is really nasty but the best option for now... // It is possible to link to exported symbols from an executable // under linux and as such we will leverage this here linkedSharedLibraries.insert( linkedLibName ); break; } case MODULETYPE_SHARED_LIBRARY: { linkedSharedLibraries.insert( linkedLibName ); break; } case MODULETYPE_STATIC_LIBRARY: { linkedStaticLibraries.insert( linkedLibName ); break; } case MODULETYPE_CODE_INTEGRATE_LOCATION: case MODULETYPE_HEADER_INTEGRATE_LOCATION: case MODULETYPE_HEADER_INCLUDE_LOCATION: { // Skip this, no linking required break; } default: { // Since the depedendency module type was not predefined we will investigate among // the other modules to try to determine the nature of the linked module const TModuleInfo* linkedDependency = FindModuleByName( mergeLinks, linkedLibName ); if ( NULL != linkedDependency ) { // The module we are linking too is part of this project. // As such we can simply check the other module's info // to find out wheter its a dynamically linked module or not // which in turn tells us how to instruct the Android build system // to link. switch( linkedDependency->moduleType ) { case MODULETYPE_SHARED_LIBRARY: { linkedSharedLibraries.insert( linkedLibName ); break; } case MODULETYPE_STATIC_LIBRARY: { linkedStaticLibraries.insert( linkedLibName ); break; } case MODULETYPE_EXECUTABLE: { // This is really nasty but the best option for now... // It is possible to link to exported symbols from an executable // under linux and as such we will leverage this here linkedSharedLibraries.insert( linkedLibName ); break; } case MODULETYPE_HEADER_INTEGRATE_LOCATION: case MODULETYPE_CODE_INTEGRATE_LOCATION: { // Dont do anything. // The files for this 'module' have already been merged into the dependent module break; } case MODULETYPE_HEADER_INCLUDE_LOCATION: { // Don't have to do anything. // Due to the auto-dependency tracking of include paths the header paths will have been added to // whatever module depends on this 'module' break; } default: { linkingErrorSection += "# *** ERROR *** Finish me\n" "# Unable to determing module type from the source information\n" "# Please edit the line below to manually set the correct linking method for this dependency\n"; linkingErrorSection += "#LOCAL_<(LDLIBS???)> += " + moduleInfo.name + "\n\n"; GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Error: the module " + moduleInfo.name + " does not have a useable module type set, you will have to manually edit the file to correct the error" ); break; } } } else { // If we get here then this dependency is not on a module which is part of the project // As such we cannot build this module thus the only approriote linking method would seem // to be the one where we simply instruct the linker to load this dependency at runtime. // This will typically be the case for any Android NDK modules we have to link to. linkedRuntimeLibraries.insert( linkedLibName ); } } } ++m; } CORE::CString linkingSection; CORE::CString linkedSharedLibrariesSection = "\nLOCAL_SHARED_LIBRARIES := \\\n"; CORE::CString linkedStaticLibrariesSection = "\nLOCAL_STATIC_LIBRARIES := \\\n"; CORE::CString linkedRuntimeLibrariesSection = "\nLOCAL_LDLIBS := \\\n"; // Based on what was found we will construct the linking section bool first = true; n = linkedSharedLibraries.begin(); while ( n != linkedSharedLibraries.end() ) { if ( !first ) { linkedSharedLibrariesSection += " \\\n"; } linkedSharedLibrariesSection += " " + (*n); first = false; ++n; } first = true; n = linkedStaticLibraries.begin(); while ( n != linkedStaticLibraries.end() ) { if ( !first ) { linkedStaticLibrariesSection += " \\\n"; } linkedStaticLibrariesSection += " " + (*n); first = false; ++n; } first = true; n = linkedRuntimeLibraries.begin(); while ( n != linkedRuntimeLibraries.end() ) { if ( !first ) { linkedRuntimeLibrariesSection += " \\\n"; } linkedRuntimeLibrariesSection += " -l" + (*n); first = false; ++n; } if ( !linkedSharedLibraries.empty() ) { linkingSection += linkedSharedLibrariesSection + "\n\n"; } if ( !linkedStaticLibraries.empty() ) { linkingSection += linkedStaticLibrariesSection + "\n\n"; } if ( !linkedRuntimeLibraries.empty() ) { linkingSection += linkedRuntimeLibrariesSection + "\n\n"; } linkingSection += linkingErrorSection; // Check if we have a file on disk of information which is to be inserted into // our automatically generated make file CORE::CString manualContent; CORE::CString manualContentFilePath = moduleRoot; CORE::AppendToPath( manualContentFilePath, "AndroidAddition.mk" ); if ( CORE::FileExists( manualContentFilePath ) ) { if ( CORE::LoadTextFileAsString( manualContentFilePath , manualContent ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Successfully loaded manually defined content for module " + moduleInfo.name + " from addition file " + manualContentFilePath ); } else { manualContent = "# *** ERROR *** Finish me\n" "# Unable to load manually defined content from detected AndroidAddition.mk file\n" "# Please manually insert its contents here\n\n"; GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Error: the module " + moduleInfo.name + " has manually defined content in a AndroidAddition.mk file but it could not be loaded, you will have to manually edit the file to correct the error" ); } } // Now generate the latter part of the file which contains more meta data about the module CORE::CString contentSuffix; switch ( moduleInfo.moduleType ) { case MODULETYPE_SHARED_LIBRARY: { contentSuffix += "include $(BUILD_SHARED_LIBRARY)\n\n"; break; } case MODULETYPE_STATIC_LIBRARY: { contentSuffix += "include $(BUILD_STATIC_LIBRARY)\n\n"; break; } case MODULETYPE_EXECUTABLE: { contentSuffix += "include $(BUILD_EXECUTABLE)\n\n"; break; } default: { contentSuffix += "# *** ERROR *** Finish me\n" "# Unable to determine module type from the source information\n" "# Please edit the line below to manually set the correct module type to build\n" "#include $(BUILD_???)\n\n"; GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "Error: the module " + moduleInfo.name + " does not have a useable module type set, you will have to manually edit the file to correct the error" ); break; } } // Check for NDK static libraries to import if ( !linkedStaticLibraries.empty() ) { TStringSet::iterator a = linkedStaticLibraries.find( "android_native_app_glue" ); if ( a != linkedStaticLibraries.end() ) { ndkModulesUsed.insert( "android_native_app_glue" ); contentSuffix += "$(call import-module,android/native_app_glue)\n"; } a = linkedStaticLibraries.find( "cpufeatures" ); if ( a != linkedStaticLibraries.end() ) { ndkModulesUsed.insert( "cpufeatures" ); contentSuffix += "$(call import-module,android/cpufeatures)\n"; } } return contentPrefix + srcFilesSection + includeFilesSection + preprocessorSection + compilerSection + linkingSection + manualContent + contentSuffix; }
bool CDStoreCodecPlugin::Link( void* modulePtr , TPluginMetaDataPtr pluginMetaData ) {GUCEF_TRACE; if ( IsLoaded() ) return false; _sohandle = modulePtr; if ( NULL != _sohandle ) { GUCEF_SYSTEM_LOG( LOGLEVEL_NORMAL, "DStoreCodecPlugin: Linking API using module pointer: " + PointerToString( modulePtr ) ); _fptable[ DSTOREPLUG_INIT ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Init" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_SHUTDOWN ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Shutdown" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_NAME ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Name" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_COPYRIGHT ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Copyright" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_VERSION ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Version" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_TYPE ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Type" , 1*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_DEST_FILE_OPEN ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Dest_File_Open" , 3*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_DEST_FILE_CLOSE ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Dest_File_Close" , 2*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_BEGIN_NODE_STORE ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Begin_Node_Store" , 3*sizeof(void*)+8 ).funcPtr; _fptable[ DSTOREPLUG_END_NODE_STORE ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_End_Node_Store" , 3*sizeof(void*)+8 ).funcPtr; _fptable[ DSTOREPLUG_STORE_NODE_ATT ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Store_Node_Att" , 5*sizeof(void*)+12 ).funcPtr; _fptable[ DSTOREPLUG_BEGIN_NODE_CHILDREN ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Begin_Node_Children" , 3*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_END_NODE_CHILDREN ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_End_Node_Children" , 3*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_SRC_FILE_OPEN ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Src_File_Open" , 2*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_SRC_FILE_CLOSE ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Src_File_Close" , 2*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_SET_READ_HANDLERS ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Set_Read_Handlers" , 4*sizeof(void*) ).funcPtr; _fptable[ DSTOREPLUG_START_READING ] = GetFunctionAddress( _sohandle , "DSTOREPLUG_Start_Reading" , 2*sizeof(void*) ).funcPtr; if ( ( _fptable[ DSTOREPLUG_INIT ] == NULL ) || ( _fptable[ DSTOREPLUG_SHUTDOWN ] == NULL ) || ( _fptable[ DSTOREPLUG_NAME ] == NULL ) || ( _fptable[ DSTOREPLUG_COPYRIGHT ] == NULL ) || ( _fptable[ DSTOREPLUG_VERSION ] == NULL ) || ( _fptable[ DSTOREPLUG_TYPE ] == NULL ) || ( _fptable[ DSTOREPLUG_DEST_FILE_OPEN ] == NULL ) || ( _fptable[ DSTOREPLUG_DEST_FILE_CLOSE ] == NULL ) || ( _fptable[ DSTOREPLUG_BEGIN_NODE_STORE ] == NULL ) || ( _fptable[ DSTOREPLUG_END_NODE_STORE ] == NULL ) || ( _fptable[ DSTOREPLUG_STORE_NODE_ATT ] == NULL ) || ( _fptable[ DSTOREPLUG_BEGIN_NODE_CHILDREN ] == NULL ) || ( _fptable[ DSTOREPLUG_END_NODE_CHILDREN ] == NULL ) || ( _fptable[ DSTOREPLUG_SRC_FILE_OPEN ] == NULL ) || ( _fptable[ DSTOREPLUG_SRC_FILE_CLOSE ] == NULL ) || ( _fptable[ DSTOREPLUG_SET_READ_HANDLERS ] == NULL ) || ( _fptable[ DSTOREPLUG_START_READING ] == NULL ) ) { memset( _fptable, NULL, sizeof(anyPointer) * DSTOREPLUG_LASTFPTR ); _sohandle = NULL; GUCEF_ERROR_LOG( LOGLEVEL_NORMAL, "Invalid codec module: One or more functions could not be located in the module " + PointerToString( modulePtr ) ); return false; } /* * Intialize the plugin module */ UInt32 statusCode = ( (TDSTOREPLUGFPTR_Init) _fptable[ DSTOREPLUG_INIT ] )( &_plugdata ); if ( statusCode > 0 ) { // We have loaded & linked our plugin module GUCEF_SYSTEM_LOG( LOGLEVEL_NORMAL, "DStoreCodecPlugin: Successfully loaded module and invoked Init() which returned status " + Int32ToString( statusCode ) + " using module: " + PointerToString( modulePtr ) ); GUCEF_SYSTEM_LOG( LOGLEVEL_NORMAL, " - Name: " + GetName() ); GUCEF_SYSTEM_LOG( LOGLEVEL_NORMAL, " - Copyright/EULA: " + GetCopyright() ); // Copy the given metadata and update it with info from the actual module m_metaData = new CPluginMetaData( *pluginMetaData ); m_metaData->SetDescription( GetDescription() ); m_metaData->SetCopyright( GetCopyright() ); m_metaData->SetVersion( GetVersion() ); return true; } else { memset( _fptable, NULL, sizeof(anyPointer) * DSTOREPLUG_LASTFPTR ); _sohandle = NULL; _plugdata = NULL; GUCEF_ERROR_LOG( LOGLEVEL_NORMAL, "Initialization routine reported an error for module " + PointerToString( modulePtr ) ); return false; } } return false; }
bool CXWinGLWindowContext::Initialize( const GUI::CString& title , const GUI::CVideoSettings& videoSettings ) {GUCEF_TRACE; // Do not initialize twice Shutdown(); // First get access to the display ::Display* display = CORE::CX11EventDispatcher::Instance()->GetDisplay(); if ( NULL == display ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not open display" ); return false; } // Now proceed with setting up the OpenGL specifics int dummy = 0; if ( 0 == glXQueryExtension( display, &dummy, &dummy ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: X server has no OpenGL GLX extension" ); Shutdown(); return false; } // find an OpenGL-capable Color Index visual with depth buffer static int attributes[] = {GLX_RGBA, GLX_DOUBLEBUFFER, None}; //static int attributes[] = {GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None}; XVisualInfo* vi = glXChooseVisual( display, DefaultScreen( display ), attributes ); if ( NULL == vi ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not get visual info for display" ); Shutdown(); return false; } // create an OpenGL rendering context GLXContext cx = glXCreateContext( display, vi, None, GL_TRUE ); if ( NULL == cx ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not create rendering context" ); XFree( vi ); Shutdown(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Created GL context using GLX" ); // create an X colormap since probably not using default visual ::Colormap cmap = ::XCreateColormap( display, RootWindow( display, vi->screen), vi->visual, AllocNone); ::XSetWindowAttributes swa; swa.colormap = cmap; swa.border_pixel = 0; swa.event_mask = ExposureMask | EnterWindowMask | StructureNotifyMask | SubstructureNotifyMask; ::Window glwin = ::XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, videoSettings.GetResolutionWidthInPixels(), videoSettings.GetResolutionHeightInPixels(), 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa); if ( 0 == glwin ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Failed to create X11 window" ); ::XFree( vi ); Shutdown(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Created X11 Window" ); // ::XSetStandardProperties(display, glwin, "xogl", "xogl", None, 0, // 0, NULL); glXMakeCurrent( display, glwin, cx ); // Set up the default GL state. glClearColor(0, 0, 0, 1); //glEnableClientState( GL_VERTEX_ARRAY ); //glEnableClientState( GL_COLOR_ARRAY ); //glEnable( GL_BLEND ); //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, GetWidth(), GetHeight(), 0, -1, 1 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Hook up our window object to re-use its eventing capabilities m_window.SetDisplay( display ); m_window.SetScreen( vi->screen ); m_window.SetWindow( glwin ); m_window.SetText( title ); // cleanup ::XFree( vi ); // Display the new window m_window.Show(); m_window.SendToForegound(); //m_window.GrabFocus(); // Grab the main app pulse generator and set the update interval for the context to the desired refresh rate CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator(); pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() ); SubscribeTo( &pulseGenerator, CORE::CPulseGenerator::PulseEvent ); GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Succesfully created OpenGL rendering context" ); return true; }
bool CResArchive::LoadIndex( void ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Starting index load" ); CORE::CFileAccess file; if ( file.Open( m_idxPath, "rb" ) ) { CORE::UInt32 fileSize = file.GetSize(); GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Successfully opened index file of " + CORE::UInt32ToString( fileSize ) + " bytes" ); if ( 1 != file.Read( &m_index.recordType, 2, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index header at position " + CORE::UInt32ToString( file.Tell() ) ); file.Close(); return false; } // Get the nr of index entries plus do a sanity check CORE::UInt32 nrOfEntries = fileSize - 2; if ( 0 != nrOfEntries % 8 ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "CResArchive:LoadIndex: The number of bytes in the index is not what we expected, the data will probably be corrupt" ); } nrOfEntries /= 8; // read all the index entries for ( CORE::UInt32 i=0; i<nrOfEntries; ++i ) { IdxRecord idxRecord; if ( 1 != file.Read( &idxRecord.resourceNr, 4, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index entry at pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); file.Close(); return false; } if ( 1 != file.Read( &idxRecord.offset, 4, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index entry at pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); file.Close(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Read index entry: id " + CORE::Int32ToString( idxRecord.resourceNr ) + ", offset " + CORE::Int32ToString( idxRecord.offset ) + ". Pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); m_index.index.push_back( idxRecord ); } file.Close(); } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Successfully loaded " + CORE::UInt32ToString( m_index.index.size() ) + " entries from index" ); return true; }
bool CGUIManager::Init( CORE::TWindowContextPtr& windowContext ) {GUCE_TRACE; if ( !m_initialized ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Initializing GUI system" ); // Apply the loaded configuration (if any exists) if ( LoadConfig( m_guiConfig ) ) { if ( m_drivers.size() == 0 ) { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Cannot initialize GUI system because no driver is available" ); return false; } if ( m_selectedDriverName.Length() == 0 ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: No GUI driver specified in config: Using first available driver" ); m_selectedDriverName = (*m_drivers.begin()).first; } TDriverMap::iterator i = m_drivers.find( m_selectedDriverName ); if ( i != m_drivers.end() ) { GUCEF_DEBUG_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Using driver with name " + m_selectedDriverName ); CIGUIDriver* driver = (*i).second; if ( driver->LoadConfig( m_guiConfig ) ) { if ( driver->Initialize( windowContext ) ) { m_initialized = true; GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Successfully initialized the GUI system" ); TGUIInitializedEventData eData( windowContext ); NotifyObservers( GUIInitializedEvent, &eData ); return true; } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to initialize the GUI system driver" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to load the GUI system driver config" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to locate the configured GUI system driver" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to load the GUI system config" ); return false; } } return true; }
void CLogSvcServer::ProcessReceivedData( TClientInfo& clientInfo , COMCORE::CTCPServerConnection* connection ) {GUCEF_TRACE; // Cycle as long as we have buffered data and no errors occur bool noError = true; while ( clientInfo.receiveBuffer.HasBufferedData() ) { // First read the message delimiter if its fully available char msgDelimterHeader[ 5 ]; if ( 5 == clientInfo.receiveBuffer.PeekElement( msgDelimterHeader, 5 ) ) { if ( msgDelimterHeader[ 0 ] == LOGSVCMSGTYPE_DELIMITER ) { // Get the total message length from the delimiter header CORE::UInt32 msgLength = 0; memcpy( &msgLength, msgDelimterHeader+1, 4 ); // Perform a sanity check // Server side we limit the length of the message we will accept from the client if ( msgLength <= MAX_ACCEPTED_MSGLENGTH ) { // Check to see if the buffer actually has the data available already to form the complete message if ( msgLength+5 <= clientInfo.receiveBuffer.GetBufferedDataSizeInBytes() ) { // Since we already got he header data via a Peek() we will skip that data now if ( 5 != clientInfo.receiveBuffer.SkipRead( 5 ) ) { // This should not happen GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CLogSvcServer: Unable to Skip buffered data" ); connection->Close(); return; } // Make a buffer for this message and read it from the receive buffer CORE::CDynamicBuffer messageBuffer( msgLength, false ); if ( msgLength == clientInfo.receiveBuffer.Read( messageBuffer.GetBufferPtr(), msgLength, 1 ) ) { // Set the size of usefull data in the buffer messageBuffer.SetDataSize( msgLength ); // Process this single message ProcessReceivedMessage( clientInfo , connection , messageBuffer ); } else { // This should not happen GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CLogSvcServer: Unable to Read() buffered data" ); connection->Close(); return; } } else { // We don't have all the data yet to read this message, we will wait for more data to come in return; } } else { // This connection is misbehaving GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CLogSvcServer: A message was received which exceeded the max msg size, disconnecting client" ); connection->Close(); return; } } } } }
bool COgreWindowContext::Initialize( const GUI::CString& title , const GUI::CVideoSettings& videoSettings , const GUI::CString& ogreRenderSystem ) {GUCEF_TRACE; // Do not initialize twice Shutdown(); // First create a regular O/S window if ( m_osWindow->WindowCreate( title , 0 , 0 , videoSettings.GetResolutionWidthInPixels() , videoSettings.GetResolutionHeightInPixels() ) ) { // Display the new window m_osWindow->Show(); m_osWindow->SendToForegound(); m_osWindow->GrabFocus(); // Now proceed with setting up the Ogre specifics // We grab the O/S window identifier 'the handle' // This is passed to Ogre to tie things together CORE::Int64 windowRef = 0; CORE::CString windowIntStr = m_osWindow->GetProperty( "WINDOWINT" ); if ( !windowIntStr.IsNULLOrEmpty() ) { windowRef = CORE::StringToInt64( windowIntStr ); } Ogre::NameValuePairList options; options[ "externalWindowHandle" ] = Ogre::StringConverter::toString( (size_t) windowRef ); Ogre::Root* ogreRoot = Ogre::Root::getSingletonPtr(); if ( ogreRoot == nullptr ) { ogreRoot = OGRE_NEW Ogre::Root( "", "", "" ); } if ( !ogreRoot->isInitialised() ) { // Load any Ogre plugins not loaded yet from the bootstrap group CORE::CCoreGlobal::Instance()->GetPluginControl().LoadPluginGroup( "Ogre" ); const Ogre::RenderSystemList& rsList = ogreRoot->getAvailableRenderers(); if ( rsList.size() == 0 ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: No Ogre render systems are available, cannot initialize" ); return false; } Ogre::RenderSystem* renderSystem = nullptr; Ogre::RenderSystemList::const_iterator i = rsList.begin(); while ( i != rsList.end() ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Available Ogre render system: " + (*i)->getFriendlyName() ); if ( ogreRenderSystem == (*i)->getName() ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Found desired/preferred Ogre render system: " + (*i)->getFriendlyName() ); renderSystem = (*i); } ++i; } if ( renderSystem == nullptr ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: Preferred Ogre render systems not available, using first available alternative: " + (*rsList.begin())->getFriendlyName() ); renderSystem = *rsList.begin(); } ogreRoot->setRenderSystem( renderSystem ); m_sceneManager = ogreRoot->createSceneManager( Ogre::ST_GENERIC ); m_renderWindow = ogreRoot->initialise( false, title ); } m_renderWindow = ogreRoot->createRenderWindow( title, videoSettings.GetResolutionWidthInPixels(), videoSettings.GetResolutionHeightInPixels(), videoSettings.GetFullscreenState(), &options ); // Grab the main app pulse generator and set the update interval for the context to the desired refresh rate CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator(); pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() ); SubscribeTo( &pulseGenerator ); GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Succesfully created Ogre rendering context" ); m_initialized = true; return true; } return false; }
bool CAndroidGLESWindowContext::Initialize( const GUI::CVideoSettings& videoSettings ) {GUCEF_TRACE; // Do not initialize twice Shutdown(); // @TODO: get the app from somewhere struct android_app* app = NULL; EGLint bitDepth = (EGLint) videoSettings.GetResolutionDepthInBits() / 3; /* * Here specify the attributes of the desired configuration. * Below, we select an EGLConfig with at least <bitDepth> bits per color * component compatible with on-screen windows * if <bitDepth> is 0 then the smallest available size is used. */ const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE, bitDepth, EGL_GREEN_SIZE, bitDepth, EGL_RED_SIZE, bitDepth, EGL_NONE }; EGLint w, h, format; EGLint numConfigs; EGLConfig config; m_display = eglGetDisplay( EGL_DEFAULT_DISPLAY ); eglInitialize( m_display, 0, 0 ); /* Here, the application chooses the configuration it desires. In this * sample, we have a very simplified selection process, where we pick * the first EGLConfig that matches our criteria */ eglChooseConfig( m_display, attribs, &config, 1, &numConfigs ); /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). * As soon as we picked a EGLConfig, we can safely reconfigure the * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */ eglGetConfigAttrib( m_display, config, EGL_NATIVE_VISUAL_ID, &format ); ANativeWindow_setBuffersGeometry( app->window, 0, 0, format ); m_surface = eglCreateWindowSurface( m_display, config, app->window, NULL ); m_context = eglCreateContext( m_display, config, NULL, NULL ); if ( eglMakeCurrent( m_display, m_surface, m_surface, m_context ) == EGL_FALSE ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "eglMakeCurrent failed" ); return false; } eglQuerySurface( m_display, m_surface, EGL_WIDTH, &w ); eglQuerySurface( m_display, m_surface, EGL_HEIGHT, &h ); //engine->width = w; //engine->height = h; // Initialize GL state. glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); glEnable( GL_CULL_FACE ); glShadeModel( GL_SMOOTH ); glDisable( GL_DEPTH_TEST ); return true; }
bool CCEGUIDriver::LoadConfig( const CORE::CDataNode& treeroot ) {GUCEF_TRACE; const CORE::CDataNode* ceguiConfig = treeroot.Find( "CEGUI" ); if ( nullptr == ceguiConfig ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "CGUIDriver:LoadConfig: Cannot find CEGUI config and as such will not be able to initialize" ); return false; } m_schemeToUse = ceguiConfig->GetAttributeValueOrChildValueByName( "Scheme" ); m_defaultFont = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultFont" ); m_defaultCursorImage = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultCursorImage" ); // the default is the fallback resource group if none is passed to the adapter CORE::CString defaultResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultResourceGroup" ); if ( defaultResourceGroup.IsNULLOrEmpty() ) defaultResourceGroup = "CEGUI"; m_vfsResourceProvider.setDefaultResourceGroup( defaultResourceGroup ); CORE::CString imageSetsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "ImageSetsResourceGroup" ); CORE::CString fontsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "FontsResourceGroup" ); CORE::CString schemesResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "SchemesResourceGroup" ); CORE::CString lookNFeelResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "LookNFeelsResourceGroup" ); CORE::CString layoutsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "LayoutsResourceGroup" ); CORE::CString animationsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "AnimationsResourceGroup" ); CORE::CString scriptsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "ScriptsResourceGroup" ); m_schemasResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "SchemasResourceGroup" ); // set the default resource groups to be used CEGUI::ImageManager::setImagesetDefaultResourceGroup( imageSetsResourceGroup ); CEGUI::Font::setDefaultResourceGroup( fontsResourceGroup ); CEGUI::Scheme::setDefaultResourceGroup( schemesResourceGroup ); CEGUI::WidgetLookManager::setDefaultResourceGroup( lookNFeelResourceGroup ); CEGUI::WindowManager::setDefaultResourceGroup( layoutsResourceGroup ); CEGUI::AnimationManager::setDefaultResourceGroup( animationsResourceGroup ); CEGUI::ScriptModule::setDefaultResourceGroup( scriptsResourceGroup ); // setup default group for validation schemas CEGUI::System* ceguiSystem = CEGUI::System::getSingletonPtr(); if ( nullptr != ceguiSystem ) { CEGUI::XMLParser* parser = ceguiSystem->getXMLParser(); if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" ) ) parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup ); } const CORE::CDataNode* ceguiVfsConfig = treeroot.Search( "CEGUI/VFSAdapter", '/', false ); if ( nullptr != ceguiVfsConfig ) { CORE::CDataNode::TConstDataNodeSet grpNodes = ceguiVfsConfig->FindChildrenOfType( "ResourceGroup" ); CORE::CDataNode::TConstDataNodeSet::iterator i = grpNodes.begin(); while ( i != grpNodes.end() ) { CORE::CString groupName = (*i)->GetAttributeValueOrChildValueByName( "Name" ); CORE::CString vfsPath = (*i)->GetAttributeValueOrChildValueByName( "Path" ); m_vfsResourceProvider.setResourceGroupDirectory( groupName, vfsPath ); ++i; } } return true; }