diff --git a/README.txt b/README.txt index 61fb98971..8702d8c31 100644 --- a/README.txt +++ b/README.txt @@ -147,32 +147,30 @@ still images, and a QTKit plugin will need to be developed to handle animations. --- Release notes on IOS build, by Thomas Hoghart +-- Release notes on iOS build, by Thomas Hoghart -* Manually set the relevant OSG_BUILD_PLATFORM_IPHONE... option in root - CMakeLists file. Can only have one or the other at the moment. -* Run CMake -* Disable all OpenGL types accodrding to OSG_GLES1_AVALIABLE or - OSG_GLES2_AVALIABLE. Also disable OSG_GLU_AVAILABLE -* Disable OSG_GL_DISPLAYLISTS_AVALIABLE +* Run CMake with either OSG_BUILD_PLATFORM_IPHONE or OSG_BUILD_PLATFORM_IPHONE_SIMULATOR set: + $ mkdir build-iOS ; cd build-iOS + $ ccmake -DOSG_BUILD_PLATFORM_IPHONE_SIMULATOR=YES -G Xcode .. +* Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device +* Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS + This will give us the static build we need for iPhone. +* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE, OSG_GLU_AVAILABLE +* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE * Ensure OSG_WINDOWING_SYSTEM is set to IOS -* Change FREETYPE include and library paths to an IPhone version +* Change FREETYPE include and library paths to an iPhone version (OpenFrameworks has one bundled with its distribution) -* Under DYNAMIC ensure you untick DYNAMIC_OPENSCENEGRAPH and - DYNAMIC_OPENTHREADS. This will give us the static build we need - for IPhone -* Under CMake ensure the CMake_OSX_SYSROOT points to your - IOS SDK. Also check that the architecture is armv6/7 for - device or i386 for Simulator. -* Generate the XCode project -* Find osgDB FileUtis.cpp, open the 'Get Info' panel, change File Type +* Ensure that CMake_OSX_SYSROOT points to your iOS SDK. +* Generate the Xcode project +* Open the Xcode project + $ open OpenSceneGraph.xcodeproj +* Under Sources -> osgDB, select FileUtils.cpp and open the 'Get Info' panel, change File Type to source.cpp.objcpp + +Known issues: * When Linking final app against ive plugin, you need to add -lz to the 'Other linker flags' list. - -known Issues: * Apps and exes don't get created * You can only select Simulator, or Device projects. In the XCode project you will see both types but the sdk they link will be the same. - diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b8e62cea1..6cb6e0603 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -243,8 +243,8 @@ ELSE(DYNAMIC_OPENSCENEGRAPH) ADD_SUBDIRECTORY(osgstaticviewer) # IPHONE_PORT@tom - IF(OSG_BUILD_PLATFORM_IPHONE || OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) - ADD_SUBDIRECTORY(osgViewerIPhone) + IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + ADD_SUBDIRECTORY(osgviewerIPhone) ENDIF() # IPHONE_PORT@tom diff --git a/examples/osgviewerIPhone/CMakeLists.txt b/examples/osgviewerIPhone/CMakeLists.txt index caf96be59..0aaf24cb6 100644 --- a/examples/osgviewerIPhone/CMakeLists.txt +++ b/examples/osgviewerIPhone/CMakeLists.txt @@ -6,8 +6,12 @@ SET(TARGET_SRC osgIPhoneViewer-Info.plist ) -#INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR} ) -SET(TARGET_LIBRARIES_VARS Foundation.framework QuartzCore.framework UIKit.framework) - -#### end var setup ### +#backup setting +SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES}) +SET(OSG_BUILD_APPLICATION_BUNDLES TRUE) SETUP_EXAMPLE(osgViewerIPhone) +#restore setting +SET(OSG_BUILD_APPLICATION_BUNDLES {$TMP_OSG_BUILD_APPLICATION_BUNDLES}) + +SET(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES -framework UIKit") + diff --git a/include/osgViewer/api/IOS/GraphicsWindowIOS b/include/osgViewer/api/IOS/GraphicsWindowIOS index 84302a2e8..0ba56de9a 100755 --- a/include/osgViewer/api/IOS/GraphicsWindowIOS +++ b/include/osgViewer/api/IOS/GraphicsWindowIOS @@ -39,31 +39,34 @@ class UIView; #include -// we may not include any cocoa-header here, because this will pollute the name-sapce and tend to compile-errors +// Do not include any cocoa-header here, because this will pollute the name-space and causes compile errors namespace osgViewer { - +/** + * Implementation of a GraphicsWindow for the iOS platform. + */ class GraphicsWindowIOS : public osgViewer::GraphicsWindow { public: - class Implementation; + class Implementation; - GraphicsWindowIOS(osg::GraphicsContext::Traits* traits) - : GraphicsWindow(), + GraphicsWindowIOS(osg::GraphicsContext::Traits* traits) : GraphicsWindow(), _valid(false), _initialized(false), _realized(false), + _window(NULL), + _view(NULL), + _viewController(NULL), + _context(NULL), _ownsWindow(true), _adaptToDeviceOrientation(true), - _viewContentScaleFactor(-1.0f), - _window(NULL), - _context(NULL) + _viewContentScaleFactor(-1.0f) { _traits = traits; init(); - + if (valid()) { setState( new osg::State ); @@ -116,11 +119,9 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow /** Get focus on if the pointer is in this window.*/ virtual void grabFocusIfPointerInWindow(); - - /** Raise the window to the top.*/ - virtual void raiseWindow(); - bool requestClose() {return false; } + /** Raise the window to the top.*/ + virtual void raiseWindow(); virtual void resizedImplementation(int x, int y, int width, int height); @@ -137,19 +138,19 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow WindowData(UIWindow* window = NULL, bool adaptToDeviceOrientation = true, float scaleFactor = -1.0f) : _window(window), _adaptToDeviceOrientation(adaptToDeviceOrientation), - _viewContentScaleFactor(scaleFactor) + _viewContentScaleFactor(scaleFactor) { } void setAdaptToDeviceOrientation(bool flag) { _adaptToDeviceOrientation = flag; } - - void setViewContentScaleFactor(float scaleFactor) { _viewContentScaleFactor = scaleFactor; } + + void setViewContentScaleFactor(float scaleFactor) { _viewContentScaleFactor = scaleFactor; } private: UIWindow* _window; bool _adaptToDeviceOrientation; - float _viewContentScaleFactor; + float _viewContentScaleFactor; friend class GraphicsWindowIOS; @@ -167,12 +168,12 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow bool adaptToDeviceOrientation() const { return _adaptToDeviceOrientation; } void setAdaptToDeviceOrientation(bool flag) { _adaptToDeviceOrientation = flag; } - - - // - //helper funs for converting points to pixels - osg::Vec2 pointToPixel(const osg::Vec2& point); - osg::Vec2 pixelToPoint(const osg::Vec2& pixel); + + + // + //helper funs for converting points to pixels + osg::Vec2 pointToPixel(const osg::Vec2& point); + osg::Vec2 pixelToPoint(const osg::Vec2& pixel); protected: @@ -194,13 +195,13 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow GraphicsWindowIOSWindow* _window; GraphicsWindowIOSGLView* _view; GraphicsWindowIOSGLViewController* _viewController; - EAGLContext* _context; + EAGLContext* _context; bool _updateContext; - - bool _ownsWindow, _adaptToDeviceOrientation; - - float _viewContentScaleFactor; - + + bool _ownsWindow, _adaptToDeviceOrientation; + + float _viewContentScaleFactor; + }; } diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index b3db32ea9..54cd41460 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -32,6 +32,14 @@ ELSE () ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC) ENDIF() +IF (APPLE) + IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + # compile FileUtils.cpp as objective-c++ + SET_SOURCE_FILES_PROPERTIES(FileUtils.cpp + PROPERTIES COMPILE_FLAGS "-x objective-c++" + ) + ENDIF() +ENDIF() SET(LIB_NAME osgDB)